31 #ifndef PX_PHYSICS_EXTENSIONS_MASS_PROPERTIES_H 32 #define PX_PHYSICS_EXTENSIONS_MASS_PROPERTIES_H 92 centerOfMass =
PxVec3(0.0f);
102 centerOfMass =
PxVec3(0.0f);
112 PxReal a = r*r*r * (8.0f / 15.0f) + h*r*r * (3.0f / 2.0f) + h*h*r * (4.0f / 3.0f) + h*h*h * (2.0f / 3.0f);
113 PxReal b = r*r*r * (8.0f / 15.0f) + h*r*r;
115 centerOfMass =
PxVec3(0.0f);
123 PxMat33 unscaledInertiaTensorNonCOM;
124 PxMat33 unscaledInertiaTensorCOM;
129 unscaledInertiaTensorCOM[0][0] = unscaledInertiaTensorNonCOM[0][0] - unscaledMass*
PxReal((unscaledCoM.
y*unscaledCoM.
y+unscaledCoM.
z*unscaledCoM.
z));
130 unscaledInertiaTensorCOM[1][1] = unscaledInertiaTensorNonCOM[1][1] - unscaledMass*
PxReal((unscaledCoM.
z*unscaledCoM.
z+unscaledCoM.
x*unscaledCoM.
x));
131 unscaledInertiaTensorCOM[2][2] = unscaledInertiaTensorNonCOM[2][2] - unscaledMass*
PxReal((unscaledCoM.
x*unscaledCoM.
x+unscaledCoM.
y*unscaledCoM.
y));
132 unscaledInertiaTensorCOM[0][1] = unscaledInertiaTensorCOM[1][0] = (unscaledInertiaTensorNonCOM[0][1] + unscaledMass*
PxReal(unscaledCoM.
x*unscaledCoM.
y));
133 unscaledInertiaTensorCOM[1][2] = unscaledInertiaTensorCOM[2][1] = (unscaledInertiaTensorNonCOM[1][2] + unscaledMass*
PxReal(unscaledCoM.
y*unscaledCoM.
z));
134 unscaledInertiaTensorCOM[0][2] = unscaledInertiaTensorCOM[2][0] = (unscaledInertiaTensorNonCOM[0][2] + unscaledMass*
PxReal(unscaledCoM.
z*unscaledCoM.
x));
139 inertiaTensor = scaleInertia(unscaledInertiaTensorCOM, s.
rotation, s.
scale);
154 PX_ASSERT(inertiaTensor.column0.isFinite() && inertiaTensor.column1.isFinite() && inertiaTensor.column2.isFinite());
181 inertiaTensor = translateInertia(inertiaTensor, mass, t);
184 PX_ASSERT(inertiaTensor.column0.isFinite() && inertiaTensor.column1.isFinite() && inertiaTensor.column2.isFinite());
260 PxMat33 localInertiaT = rotateInertia(inertia, scaleRotation);
261 PxVec3 diagonal(localInertiaT[0][0], localInertiaT[1][1], localInertiaT[2][2]);
266 PxReal xx = scaledxyz2.y + scaledxyz2.z,
267 yy = scaledxyz2.z + scaledxyz2.x,
268 zz = scaledxyz2.x + scaledxyz2.y;
270 PxReal xy = localInertiaT[0][1] * scale.
x * scale.
y,
271 xz = localInertiaT[0][2] * scale.
x * scale.
z,
272 yz = localInertiaT[1][2] * scale.
y * scale.
z;
278 PxMat33 scaledIT = rotateInertia(scaledInertia * (scale.
x * scale.
y * scale.
z), scaleRotation.
getConjugate());
293 PxReal combinedMass = 0.0f;
297 for(
PxU32 i = 0; i < count; i++)
300 PX_ASSERT(props[i].centerOfMass.isFinite());
303 combinedMass += props[i].
mass;
305 combinedCoM += comTm * props[i].
mass;
308 combinedCoM /= combinedMass;
310 for(
PxU32 i = 0; i < count; i++)
313 combinedInertiaT += translateInertia(rotateInertia(props[i].inertiaTensor, transforms[i].q), props[i].mass, combinedCoM - comTm);
Definition: GuContactBuffer.h:37
PX_CUDA_CALLABLE PX_INLINE PxQuat getConjugate() const
Definition: PxQuat.h:247
PxMassProperties(const PxGeometry &geometry)
Compute mass properties based on a provided geometry structure.
Definition: PxMassProperties.h:83
PxConvexMesh * convexMesh
A reference to the convex mesh object.
Definition: PxConvexMeshGeometry.h:126
PX_CUDA_CALLABLE PX_INLINE bool isFinite() const
returns true if all 3 elems of the vector are finite (not NAN or INF, etc.)
Definition: PxVec3.h:156
virtual PX_PHYSX_COMMON_API void getMassInformation(PxReal &mass, PxMat33 &localInertia, PxVec3 &localCenterOfMass) const =0
Returns the mass properties of the mesh assuming unit density.
PxMeshScale scale
The scaling transformation (from vertex space to shape space).
Definition: PxConvexMeshGeometry.h:125
PX_FORCE_INLINE void translate(const PxVec3 &t)
Translate the center of mass by a given vector and adjust the inertia tensor accordingly.
Definition: PxMassProperties.h:177
Class representing the geometry of a capsule.
Definition: PxCapsuleGeometry.h:54
A class expressing a nonuniform scaling transformation.
Definition: PxMeshScale.h:68
PxVec3 halfExtents
Half of the width, height, and depth of the box.
Definition: PxBoxGeometry.h:88
static const float PxPi
Definition: PxMath.h:58
PX_CUDA_CALLABLE PX_FORCE_INLINE float dot(const PxVec3 &v) const
returns the scalar product of this and other.
Definition: PxVec3.h:276
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:364
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition: PxQuat.h:49
float PxReal
Definition: PxSimpleTypes.h:78
A class representing the geometry of a sphere.
Definition: PxSphereGeometry.h:49
static PxMat33 scaleInertia(const PxMat33 &inertia, const PxQuat &scaleRotation, const PxVec3 &scale)
Non-uniform scaling of the inertia tensor.
Definition: PxMassProperties.h:254
PX_FORCE_INLINE PxMassProperties()
Default constructor.
Definition: PxMassProperties.h:69
Definition: PxGeometry.h:57
PxReal radius
The radius of the sphere.
Definition: PxSphereGeometry.h:72
Definition: PxGeometry.h:61
PxQuat rotation
The orientation of the scaling axes.
Definition: PxMeshScale.h:165
A geometry object.
Definition: PxGeometry.h:75
Definition: PxGeometry.h:55
internal use only!
Definition: PxGeometry.h:62
static PX_FORCE_INLINE PxMat33 rotateInertia(const PxMat33 &inertia, const PxQuat &q)
Rotate an inertia tensor around the center of mass.
Definition: PxMassProperties.h:235
PX_CUDA_CALLABLE static PX_INLINE const PxMat33 createDiagonal(const PxVec3 &d)
Construct from diagonal, off-diagonals are zero.
Definition: PxMat33.h:176
float y
Definition: PxVec3.h:381
Utility class to compute and manipulate mass and inertia tensor properties.
Definition: PxMassProperties.h:63
PxVec3 scale
A nonuniform scaling.
Definition: PxMeshScale.h:164
PxReal mass
The mass of the object.
Definition: PxMassProperties.h:326
PxU8 geometry[sizeof(PxGeometry)]
Definition: PxGeometryHelpers.h:215
internal use only!
Definition: PxGeometry.h:63
PX_FOUNDATION_API PxVec3 PxDiagonalize(const PxMat33 &m, PxQuat &axes)
PX_CUDA_CALLABLE bool isUnit() const
returns true if finite and magnitude is close to unit
Definition: PxQuat.h:132
PxVec3 column2
Definition: PxMat33.h:353
3x3 matrix class
Definition: PxMat33.h:90
static PX_FORCE_INLINE PxVec3 getMassSpaceInertia(const PxMat33 &inertia, PxQuat &massFrame)
Get the entries of the diagonalized inertia tensor and the corresponding reference rotation...
Definition: PxMassProperties.h:195
static PX_FORCE_INLINE PxMat33 translateInertia(const PxMat33 &inertia, const PxReal mass, const PxVec3 &t)
Translate an inertia tensor using the parallel axis theorem.
Definition: PxMassProperties.h:213
static PxMassProperties sum(const PxMassProperties *props, const PxTransform *transforms, const PxU32 count)
Sum up individual mass properties.
Definition: PxMassProperties.h:291
PxReal radius
The radius of the capsule.
Definition: PxCapsuleGeometry.h:83
PxVec3 column0
Definition: PxMat33.h:353
PX_CUDA_CALLABLE PX_FORCE_INLINE bool PxIsFinite(float f)
returns true if the passed number is a finite floating point number as opposed to INF...
Definition: PxMath.h:292
PxReal halfHeight
half of the capsule's height, measured between the centers of the hemispherical ends.
Definition: PxCapsuleGeometry.h:88
Definition: PxGeometry.h:59
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 rotate(const PxVec3 &v) const
Definition: PxQuat.h:287
Definition: PxGeometry.h:58
#define PX_ASSERT(exp)
Definition: PxAssert.h:61
Definition: PxGeometry.h:60
PX_CUDA_CALLABLE bool isFinite() const
returns true if all elements are finite (not NAN or INF, etc.)
Definition: PxQuat.h:124
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxMat33 getTranspose() const
Get transposed matrix.
Definition: PxMat33.h:190
uint32_t PxU32
Definition: Px.h:48
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 rotateInv(const PxVec3 &v) const
Definition: PxQuat.h:301
PX_FORCE_INLINE PxMassProperties(const PxReal m, const PxMat33 &inertiaT, const PxVec3 &com)
Construct from individual elements.
Definition: PxMassProperties.h:74
Definition: PxGeometry.h:56
PxMat33 inertiaTensor
The inertia tensor of the object.
Definition: PxMassProperties.h:324
float z
Definition: PxVec3.h:381
PX_FORCE_INLINE PxMassProperties operator*(const PxReal scale) const
Scale mass properties.
Definition: PxMassProperties.h:165
PxVec3 column1
Definition: PxMat33.h:353
Convex mesh geometry class.
Definition: PxConvexMeshGeometry.h:80
Class representing the geometry of a box.
Definition: PxBoxGeometry.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 multiply(const PxVec3 &a) const
a[i] * b[i], for all i.
Definition: PxVec3.h:336
3 Element vector class.
Definition: PxVec3.h:49
PxVec3 centerOfMass
The center of mass of the object.
Definition: PxMassProperties.h:325
float x
Definition: PxVec3.h:381