12 #ifndef hifi_MeshMassProperties_h
13 #define hifi_MeshMassProperties_h
18 #include <btBulletDynamicsCommon.h>
20 typedef std::vector<btVector3> VectorOfPoints;
21 typedef std::vector<uint32_t> VectorOfIndices;
23 #define EXPOSE_HELPER_FUNCTIONS_FOR_UNIT_TEST
24 #ifdef EXPOSE_HELPER_FUNCTIONS_FOR_UNIT_TEST
25 void computeBoxInertia(btScalar mass,
const btVector3& diagonal, btMatrix3x3& I);
30 void computeTetrahedronInertia(btScalar mass, btVector3* points, btMatrix3x3& I);
31 void computeTetrahedronInertiaByBruteForce(btVector3* points, btMatrix3x3& I);
33 btScalar computeTetrahedronVolume(btVector3* points);
35 void applyParallelAxisTheorem(btMatrix3x3& inertia,
const btVector3& shift, btScalar mass);
45 class MeshMassProperties {
50 MeshMassProperties(
const VectorOfPoints& points,
const VectorOfIndices& triangleIndices);
53 void computeMassProperties(
const VectorOfPoints& points,
const VectorOfIndices& triangleIndices);
56 btScalar _volume = 1.0f;
57 btVector3 _centerOfMass = btVector3(0.0f, 0.0f, 0.0f);
58 btMatrix3x3 _inertia = btMatrix3x3(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);