Nebula
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
10#include "PxConfig.h"
11#include "foundation/PxVec3.h"
12#include "math/vector.h"
13#include "foundation/PxVec4.h"
14#include "foundation/PxMat44.h"
15#include "math/transform.h"
16
17//------------------------------------------------------------------------------
20inline physx::PxVec3
22{
23 return physx::PxVec3(vec.x, vec.y, vec.z);
24}
25
26//------------------------------------------------------------------------------
29inline physx::PxVec3
31{
32 return physx::PxVec3(vec.x, vec.y, vec.z);
33}
34
35//------------------------------------------------------------------------------
38inline Math::vector
39Px2NebVec(const physx::PxVec3& vec)
40{
41 return Math::vector(vec.x, vec.y, vec.z);
42}
43
44//------------------------------------------------------------------------------
47inline Math::vec4
48Px2Nebfloat4(const physx::PxVec4& vec)
49{
50 return Math::vec4(vec.x, vec.y, vec.z, vec.w);
51}
52
53//------------------------------------------------------------------------------
56inline Math::point
57Px2NebPoint(const physx::PxVec3& vec)
58{
59 return Math::point(vec.x, vec.y, vec.z);
60}
61
62//------------------------------------------------------------------------------
65inline physx::PxVec4
67{
68 return physx::PxVec4(vec.x, vec.y, vec.z, vec.w);
69}
70
71//------------------------------------------------------------------------------
74inline physx::PxQuat
76{
77 return physx::PxQuat(vec.x, vec.y, vec.z, vec.w);
78}
79
80//------------------------------------------------------------------------------
83inline Math::quat
84Px2NebQuat(const physx::PxQuat& vec)
85{
86 return Math::quat(vec.x, vec.y, vec.z, vec.w);
87}
88
89//------------------------------------------------------------------------------
92inline physx::PxMat44
94{
95 return physx::PxMat44(Neb2PxVec4(mat.row0), Neb2PxVec4(mat.row1), Neb2PxVec4(mat.row2), Neb2PxVec4(mat.row3));
96}
97
98//------------------------------------------------------------------------------
101inline physx::PxTransform
103{
104 return physx::PxTransform(Neb2PxMat(mat));
105}
106
107//------------------------------------------------------------------------------
110inline physx::PxTransform
111Neb2PxTrans(const Math::vec3& position, const Math::quat& orientation)
112{
113 return physx::PxTransform(Neb2PxVec(position), Neb2PxQuat(orientation));
114}
115
116//------------------------------------------------------------------------------
119inline physx::PxTransform
121{
122 n_assert(trans.scale == Math::_plus1);
123 return physx::PxTransform(Neb2PxVec(trans.position), Neb2PxQuat(trans.rotation));
124}
125
126inline Math::transform
127Px2NebTrans(const physx::PxTransform& trans)
128{
129 return Math::transform(Px2NebVec(trans.p), Px2NebQuat(trans.q));
130}
131
132//------------------------------------------------------------------------------
135inline Math::mat4
136Px2NebMat(const physx::PxTransform& mat)
137{
138 Math::quat q = Px2NebQuat(mat.q);
139 Math::vec4 p = Px2NebPoint(mat.p);
141 m.position = p;
142 return m;
143}
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:138
vec4 position
Definition mat4.h:118
vec4 row1
Definition mat4.h:136
vec4 row0
Definition mat4.h:135
vec4 row2
Definition mat4.h:137
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
A 4D vector.
Definition vec4.h:24
float y
Definition vec4.h:93
float z
Definition vec4.h:93
float w
Definition vec4.h:93
float x
Definition vec4.h:93
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:84
Math::vector Px2NebVec(const physx::PxVec3 &vec)
Definition utils.h:39
Math::point Px2NebPoint(const physx::PxVec3 &vec)
Definition utils.h:57
physx::PxMat44 Neb2PxMat(const Math::mat4 &mat)
Definition utils.h:93
Math::vec4 Px2Nebfloat4(const physx::PxVec4 &vec)
Definition utils.h:48
Math::mat4 Px2NebMat(const physx::PxTransform &mat)
Definition utils.h:136
Math::transform Px2NebTrans(const physx::PxTransform &trans)
Definition utils.h:127
physx::PxTransform Neb2PxTrans(const Math::mat4 &mat)
Definition utils.h:102
physx::PxVec4 Neb2PxVec4(const Math::vec4 &vec)
Definition utils.h:66
physx::PxQuat Neb2PxQuat(const Math::quat &vec)
Definition utils.h:75
physx::PxVec3 Neb2PxVec(const Math::vector &vec)
PhysX utils for conversion of datatypes.
Definition utils.h:21
physx::PxVec3 Neb2PxPnt(const Math::point &vec)
Definition utils.h:30