10#ifdef USE_BULLET_PHYSIC_ENGINE
12#include <btBulletCollisionCommon.h>
13#include <btBulletDynamicsCommon.h>
26 inline static btVector3 irrVectorToBulletVector(
const core::vector3df& toConvert)
28 return btVector3(toConvert.
X, toConvert.
Y, toConvert.
Z);
36 inline static core::vector3df bulletVectorToIrrVector(
const btVector3& toConvert)
46 inline static void quaternionToEuler(
const btQuaternion& TQuat, btVector3& TEuler)
48 btScalar W = TQuat.getW();
49 btScalar X = TQuat.getX();
50 btScalar Y = TQuat.getY();
51 btScalar Z = TQuat.getZ();
52 float WSquared = W * W;
53 float XSquared = X * X;
54 float YSquared = Y * Y;
55 float ZSquared = Z * Z;
56 TEuler.setX(atan2f(2.0f * (Y * Z + X * W), -XSquared - YSquared + ZSquared + WSquared));
57 TEuler.setY(asinf(-2.0f * (X * Z - Y * W)));
58 TEuler.setZ(atan2f(2.0f * (X * Y + Z * W), XSquared - YSquared - ZSquared + WSquared));
69 btVector3 bulletEuler;
70 quaternionToEuler(TQuat, bulletEuler);
71 return Bullet::bulletVectorToIrrVector(bulletEuler);
79 inline static core::vector3df bulletTransformToIrrRotation(
const btTransform& tr)
84 float ptr[16] __attribute__((aligned(16)));
85 tr.getOpenGLMatrix(ptr);
88 for (
int i = 0; i < 16; i++)
95 tr.getOpenGLMatrix(ptr);
105 inline static void bulletTransformToIrrMatrix(
const btTransform& tr,
core::matrix4& mat)
108 float ptr[16] __attribute__((aligned(16)));
109 tr.getOpenGLMatrix(ptr);
112 for (
int i = 0; i < 16; i++)
117 tr.getOpenGLMatrix(ptr);
126 inline static btTransform irrRotationToBulletTransform(
const core::vector3df& rotation)
131 tr.setFromOpenGLMatrix(mat.
pointer());
141 inline static btTransform glMatrixToBulletTransform(
float* matrix)
144 tr.setFromOpenGLMatrix(matrix);
const T * pointer() const
Returns pointer to internal array.
Definition matrix4.h:99
CMatrix4< T > & setRotationDegrees(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.h:816
core::vector3d< T > getRotationDegrees() const
Returns the rotation, as set by setRotation().
Definition matrix4.h:863
T X
X coordinate of the vector.
Definition vector3d.h:408
T Z
Z coordinate of the vector.
Definition vector3d.h:414
T Y
Y coordinate of the vector.
Definition vector3d.h:411
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
const f32 RADTODEG
32bit constant for converting from radians to degrees (formally known as GRAD_PI)
Definition irrMath.h:77
float f32
32 bit floating point variable.
Definition irrTypes.h:104