Nebula
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9
10#include "PxConfig.h"
11#include "characterkinematic/PxExtended.h"
12#include "foundation/PxVec3.h"
13#include "math/vector.h"
14#include "foundation/PxVec4.h"
15#include "foundation/PxMat44.h"
16#include "math/transform.h"
17
18//------------------------------------------------------------------------------
21inline physx::PxVec3
23{
24 return physx::PxVec3(vec.x, vec.y, vec.z);
25}
26
27//--------------------------------------------------------------------------
30inline physx::PxExtendedVec3
32{
33 return physx::PxExtendedVec3(vec.x, vec.y, vec.z);
34}
35
36//------------------------------------------------------------------------------
39inline physx::PxVec3
41{
42 return physx::PxVec3(vec.x, vec.y, vec.z);
43}
44
45//------------------------------------------------------------------------------
48inline Math::vector
49Px2NebVec(const physx::PxVec3& vec)
50{
51 return Math::vector(vec.x, vec.y, vec.z);
52}
53
54//------------------------------------------------------------------------------
57inline Math::vec4
58Px2Nebfloat4(const physx::PxVec4& vec)
59{
60 return Math::vec4(vec.x, vec.y, vec.z, vec.w);
61}
62
63//------------------------------------------------------------------------------
66inline Math::point
67Px2NebPoint(const physx::PxVec3& vec)
68{
69 return Math::point(vec.x, vec.y, vec.z);
70}
71
72//------------------------------------------------------------------------------
75inline physx::PxVec4
77{
78 return physx::PxVec4(vec.x, vec.y, vec.z, vec.w);
79}
80
81//------------------------------------------------------------------------------
84inline physx::PxQuat
86{
87 return physx::PxQuat(vec.x, vec.y, vec.z, vec.w);
88}
89
90//------------------------------------------------------------------------------
93inline Math::quat
94Px2NebQuat(const physx::PxQuat& vec)
95{
96 return Math::quat(vec.x, vec.y, vec.z, vec.w);
97}
98
99//------------------------------------------------------------------------------
102inline physx::PxMat44
104{
105 return physx::PxMat44(Neb2PxVec4(mat.row0), Neb2PxVec4(mat.row1), Neb2PxVec4(mat.row2), Neb2PxVec4(mat.row3));
106}
107
108//------------------------------------------------------------------------------
111inline physx::PxTransform
113{
114 return physx::PxTransform(Neb2PxMat(mat));
115}
116
117//------------------------------------------------------------------------------
120inline physx::PxTransform
121Neb2PxTrans(const Math::vec3& position, const Math::quat& orientation)
122{
123 return physx::PxTransform(Neb2PxVec(position), Neb2PxQuat(orientation));
124}
125
126//------------------------------------------------------------------------------
129inline physx::PxTransform
131{
132 n_assert(trans.scale == Math::_plus1);
133 return physx::PxTransform(Neb2PxVec(trans.position), Neb2PxQuat(trans.rotation));
134}
135
136inline Math::transform
137Px2NebTrans(const physx::PxTransform& trans)
138{
139 return Math::transform(Px2NebVec(trans.p), Px2NebQuat(trans.q));
140}
141
142//------------------------------------------------------------------------------
145inline Math::mat4
146Px2NebMat(const physx::PxTransform& mat)
147{
148 Math::quat q = Px2NebQuat(mat.q);
149 Math::vec4 p = Px2NebPoint(mat.p);
151 m.position = p;
152 return m;
153}
Simple transform using position, quaternion, and scale.
Definition transform.h:18
Math::vec3 position
Definition transform.h:31
Math::vec3 scale
Definition transform.h:33
Math::quat rotation
Definition transform.h:32
#define n_assert(exp)
Definition debug.h:50
mat4 rotationquat(const quat &q)
TODO: rewrite using SSE.
Definition mat4.cc:178
static const __m128 _plus1
Definition vec3.h:34
A 4x4 single point precision float matrix.
Definition mat4.h:49
vec4 row3
Definition mat4.h:143
vec4 position
Definition mat4.h:123
vec4 row1
Definition mat4.h:141
vec4 row0
Definition mat4.h:140
vec4 row2
Definition mat4.h:142
Represents a 3D point in space.
Definition point.h:22
float z
Definition point.h:78
float x
Definition point.h:78
float y
Definition point.h:78
A quaternion is usually used to represent an orientation in 3D space.
Definition quat.h:30
float y
Definition quat.h:78
float z
Definition quat.h:78
float w
Definition quat.h:78
float x
Definition quat.h:78
A 3D vector.
Definition vec3.h:40
float x
Definition vec3.h:96
float z
Definition vec3.h:96
float y
Definition vec3.h:96
A 4D vector.
Definition vec4.h:24
float y
Definition vec4.h:95
float z
Definition vec4.h:95
float w
Definition vec4.h:95
float x
Definition vec4.h:95
A vector is a 3D direction in space.
Definition vector.h:22
float z
Definition vector.h:85
float x
Definition vector.h:85
float y
Definition vector.h:85
Math::quat Px2NebQuat(const physx::PxQuat &vec)
Definition utils.h:94
Math::vector Px2NebVec(const physx::PxVec3 &vec)
Definition utils.h:49
Math::point Px2NebPoint(const physx::PxVec3 &vec)
Definition utils.h:67
physx::PxMat44 Neb2PxMat(const Math::mat4 &mat)
Definition utils.h:103
Math::vec4 Px2Nebfloat4(const physx::PxVec4 &vec)
Definition utils.h:58
Math::mat4 Px2NebMat(const physx::PxTransform &mat)
Definition utils.h:146
Math::transform Px2NebTrans(const physx::PxTransform &trans)
Definition utils.h:137
physx::PxTransform Neb2PxTrans(const Math::mat4 &mat)
Definition utils.h:112
physx::PxVec4 Neb2PxVec4(const Math::vec4 &vec)
Definition utils.h:76
physx::PxExtendedVec3 Neb2PxExtentedVec3(const Math::vec3 &vec)
Definition utils.h:31
physx::PxQuat Neb2PxQuat(const Math::quat &vec)
Definition utils.h:85
physx::PxVec3 Neb2PxVec(const Math::vector &vec)
PhysX utils for conversion of datatypes.
Definition utils.h:22
physx::PxVec3 Neb2PxPnt(const Math::point &vec)
Definition utils.h:40