PxRigidBodyExt Class Reference

utility functions for use with PxRigidBody and subclasses More...

#include <PxRigidBodyExt.h>

Static Public Member Functions

static bool updateMassAndInertia (PxRigidBody &body, const PxReal *shapeDensities, PxU32 shapeDensityCount, const PxVec3 *massLocalPose=NULL, bool includeNonSimShapes=false)
 Computation of mass properties for a rigid body actor. More...
 
static bool updateMassAndInertia (PxRigidBody &body, PxReal density, const PxVec3 *massLocalPose=NULL, bool includeNonSimShapes=false)
 Computation of mass properties for a rigid body actor. More...
 
static bool setMassAndUpdateInertia (PxRigidBody &body, const PxReal *shapeMasses, PxU32 shapeMassCount, const PxVec3 *massLocalPose=NULL, bool includeNonSimShapes=false)
 Computation of mass properties for a rigid body actor. More...
 
static bool setMassAndUpdateInertia (PxRigidBody &body, PxReal mass, const PxVec3 *massLocalPose=NULL, bool includeNonSimShapes=false)
 Computation of mass properties for a rigid body actor. More...
 
static PxMassProperties computeMassPropertiesFromShapes (const PxShape *const *shapes, PxU32 shapeCount)
 Compute the mass, inertia tensor and center of mass from a list of shapes. More...
 
static void addForceAtPos (PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
 Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in global coordinates, to the actor. More...
 
static void addForceAtLocalPos (PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
 Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in local coordinates, to the actor. More...
 
static void addLocalForceAtPos (PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
 Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular point in global coordinates, to the actor. More...
 
static void addLocalForceAtLocalPos (PxRigidBody &body, const PxVec3 &force, const PxVec3 &pos, PxForceMode::Enum mode=PxForceMode::eFORCE, bool wakeup=true)
 Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular point in local coordinates, to the actor. More...
 
static PxVec3 getVelocityAtPos (const PxRigidBody &body, const PxVec3 &pos)
 Computes the velocity of a point given in world coordinates if it were attached to the specified body and moving with it. More...
 
static PxVec3 getLocalVelocityAtLocalPos (const PxRigidBody &body, const PxVec3 &pos)
 Computes the velocity of a point given in local coordinates if it were attached to the specified body and moving with it. More...
 
static PxVec3 getVelocityAtOffset (const PxRigidBody &body, const PxVec3 &pos)
 Computes the velocity of a point (offset from the origin of the body) given in world coordinates if it were attached to the specified body and moving with it. More...
 
static bool linearSweepSingle (PxRigidBody &body, PxScene &scene, const PxVec3 &unitDir, const PxReal distance, PxHitFlags outputFlags, PxSweepHit &closestHit, PxU32 &shapeIndex, const PxQueryFilterData &filterData=PxQueryFilterData(), PxQueryFilterCallback *filterCall=NULL, const PxQueryCache *cache=NULL, const PxReal inflation=0.0f)
 Performs a linear sweep through space with the body's geometry objects. More...
 
static PxU32 linearSweepMultiple (PxRigidBody &body, PxScene &scene, const PxVec3 &unitDir, const PxReal distance, PxHitFlags outputFlags, PxSweepHit *touchHitBuffer, PxU32 *touchHitShapeIndices, PxU32 touchHitBufferSize, PxSweepHit &block, PxI32 &blockingShapeIndex, bool &overflow, const PxQueryFilterData &filterData=PxQueryFilterData(), PxQueryFilterCallback *filterCall=NULL, const PxQueryCache *cache=NULL, const PxReal inflation=0.0f)
 Performs a linear sweep through space with the body's geometry objects, returning all overlaps. More...
 
static void computeVelocityDeltaFromImpulse (const PxRigidBody &body, const PxVec3 &impulsiveForce, const PxVec3 &impulsiveTorque, PxVec3 &deltaLinearVelocity, PxVec3 &deltaAngularVelocity)
 Compute the change to linear and angular velocity that would occur if an impulsive force and torque were to be applied to a specified rigid body. More...
 
static void computeVelocityDeltaFromImpulse (const PxRigidBody &body, const PxTransform &globalPose, const PxVec3 &point, const PxVec3 &impulse, const PxReal invMassScale, const PxReal invInertiaScale, PxVec3 &deltaLinearVelocity, PxVec3 &deltaAngularVelocity)
 Computes the linear and angular velocity change vectors for a given impulse at a world space position taking a mass and inertia scale into account. More...
 
static void computeLinearAngularImpulse (const PxRigidBody &body, const PxTransform &globalPose, const PxVec3 &point, const PxVec3 &impulse, const PxReal invMassScale, const PxReal invInertiaScale, PxVec3 &linearImpulse, PxVec3 &angularImpulse)
 Computes the linear and angular impulse vectors for a given impulse at a world space position taking a mass and inertia scale into account. More...
 

Detailed Description

utility functions for use with PxRigidBody and subclasses

See also
PxRigidBody PxRigidDynamic PxArticulationLink

Member Function Documentation

◆ addForceAtLocalPos()

static void PxRigidBodyExt::addForceAtLocalPos ( PxRigidBody body,
const PxVec3 force,
const PxVec3 pos,
PxForceMode::Enum  mode = PxForceMode::eFORCE,
bool  wakeup = true 
)
static

Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in local coordinates, to the actor.

Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame.

Note
if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation

PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point.

Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default).

Parameters
[in]bodyThe rigid body to apply the force to.
[in]forceForce/impulse to add, defined in the global frame. Range: force vector
[in]posPosition in the local frame to add the force at. Range: position vector
[in]modeThe mode to use when applying the force/impulse(see PxForceMode).
[in]wakeupSpecify if the call should wake up the actor.
See also
PxForceMode
addForceAtPos() addLocalForceAtPos() addLocalForceAtLocalPos()

◆ addForceAtPos()

static void PxRigidBodyExt::addForceAtPos ( PxRigidBody body,
const PxVec3 force,
const PxVec3 pos,
PxForceMode::Enum  mode = PxForceMode::eFORCE,
bool  wakeup = true 
)
static

Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in global coordinates, to the actor.

Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame.

Note
if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation

PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point.

Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default).

Parameters
[in]bodyThe rigid body to apply the force to.
[in]forceForce/impulse to add, defined in the global frame. Range: force vector
[in]posPosition in the global frame to add the force at. Range: position vector
[in]modeThe mode to use when applying the force/impulse(see PxForceMode).
[in]wakeupSpecify if the call should wake up the actor.
See also
PxForceMode
addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos()

◆ addLocalForceAtLocalPos()

static void PxRigidBodyExt::addLocalForceAtLocalPos ( PxRigidBody body,
const PxVec3 force,
const PxVec3 pos,
PxForceMode::Enum  mode = PxForceMode::eFORCE,
bool  wakeup = true 
)
static

Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular point in local coordinates, to the actor.

Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame.

Note
if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation

PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point.

Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default).

Parameters
[in]bodyThe rigid body to apply the force to.
[in]forceForce/impulse to add, defined in the local frame. Range: force vector
[in]posPosition in the local frame to add the force at. Range: position vector
[in]modeThe mode to use when applying the force/impulse(see PxForceMode).
[in]wakeupSpecify if the call should wake up the actor.
See also
PxForceMode
addForceAtPos() addForceAtLocalPos() addLocalForceAtPos()

◆ addLocalForceAtPos()

static void PxRigidBodyExt::addLocalForceAtPos ( PxRigidBody body,
const PxVec3 force,
const PxVec3 pos,
PxForceMode::Enum  mode = PxForceMode::eFORCE,
bool  wakeup = true 
)
static

Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular point in global coordinates, to the actor.

Note that if the force does not act along the center of mass of the actor, this will also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a total external force on an object by calling this once every frame.

Note
if this call is used to apply a force or impulse to an articulation link, only the link is updated, not the entire articulation

PxForceMode determines if the force is to be conventional or impulsive. Only eFORCE and eIMPULSE are supported, as the force required to produce a given velocity change or acceleration is underdetermined given only the desired change at a given point.

Sleeping: This call wakes the actor if it is sleeping and the wakeup parameter is true (default).

Parameters
[in]bodyThe rigid body to apply the force to.
[in]forceForce/impulse to add, defined in the local frame. Range: force vector
[in]posPosition in the global frame to add the force at. Range: position vector
[in]modeThe mode to use when applying the force/impulse(see PxForceMode).
[in]wakeupSpecify if the call should wake up the actor.
See also
PxForceMode
addForceAtPos() addForceAtLocalPos() addLocalForceAtLocalPos()

◆ computeLinearAngularImpulse()

static void PxRigidBodyExt::computeLinearAngularImpulse ( const PxRigidBody body,
const PxTransform globalPose,
const PxVec3 point,
const PxVec3 impulse,
const PxReal  invMassScale,
const PxReal  invInertiaScale,
PxVec3 linearImpulse,
PxVec3 angularImpulse 
)
static

Computes the linear and angular impulse vectors for a given impulse at a world space position taking a mass and inertia scale into account.

This function is useful for extracting the respective linear and angular impulses from a contact or joint when the mass/inertia ratios have been adjusted.

Parameters
[in]bodyThe rigid body
[in]globalPoseThe body's world space transform
[in]pointThe point in world space where the impulse is applied
[in]impulseThe impulse vector in world space
[in]invMassScaleThe inverse mass scale
[in]invInertiaScaleThe inverse inertia scale
[out]linearImpulseThe linear impulse
[out]angularImpulseThe angular impulse

◆ computeMassPropertiesFromShapes()

static PxMassProperties PxRigidBodyExt::computeMassPropertiesFromShapes ( const PxShape *const *  shapes,
PxU32  shapeCount 
)
static

Compute the mass, inertia tensor and center of mass from a list of shapes.

Parameters
[in]shapesThe shapes to compute the mass properties from.
[in]shapeCountThe number of provided shapes.
Returns
The mass properties from the combined shapes.
See also
PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass

◆ computeVelocityDeltaFromImpulse() [1/2]

static void PxRigidBodyExt::computeVelocityDeltaFromImpulse ( const PxRigidBody body,
const PxVec3 impulsiveForce,
const PxVec3 impulsiveTorque,
PxVec3 deltaLinearVelocity,
PxVec3 deltaAngularVelocity 
)
static

Compute the change to linear and angular velocity that would occur if an impulsive force and torque were to be applied to a specified rigid body.

The rigid body is left unaffected unless a subsequent independent call is executed that actually applies the computed changes to velocity and angular velocity.

Note
if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account.
See also
PxRigidBody::getLinearVelocity, PxRigidBody::setLinearVelocity, PxRigidBody::getAngularVelocity, PxRigidBody::setAngularVelocity
Parameters
[in]bodyThe body under consideration.
[in]impulsiveForceThe impulsive force that would be applied to the specified rigid body.
[in]impulsiveTorqueThe impulsive torque that would be applied to the specified rigid body.
[out]deltaLinearVelocityThe change in linear velocity that would arise if impulsiveForce was to be applied to the specified rigid body.
[out]deltaAngularVelocityThe change in angular velocity that would arise if impulsiveTorque was to be applied to the specified rigid body.

◆ computeVelocityDeltaFromImpulse() [2/2]

static void PxRigidBodyExt::computeVelocityDeltaFromImpulse ( const PxRigidBody body,
const PxTransform globalPose,
const PxVec3 point,
const PxVec3 impulse,
const PxReal  invMassScale,
const PxReal  invInertiaScale,
PxVec3 deltaLinearVelocity,
PxVec3 deltaAngularVelocity 
)
static

Computes the linear and angular velocity change vectors for a given impulse at a world space position taking a mass and inertia scale into account.

This function is useful for extracting the respective linear and angular velocity changes from a contact or joint when the mass/inertia ratios have been adjusted.

Note
if this call is used to determine the velocity delta for an articulation link, only the mass properties of the link are taken into account.
Parameters
[in]bodyThe rigid body
[in]globalPoseThe body's world space transform
[in]pointThe point in world space where the impulse is applied
[in]impulseThe impulse vector in world space
[in]invMassScaleThe inverse mass scale
[in]invInertiaScaleThe inverse inertia scale
[out]deltaLinearVelocityThe linear velocity change
[out]deltaAngularVelocityThe angular velocity change

◆ getLocalVelocityAtLocalPos()

static PxVec3 PxRigidBodyExt::getLocalVelocityAtLocalPos ( const PxRigidBody body,
const PxVec3 pos 
)
static

Computes the velocity of a point given in local coordinates if it were attached to the specified body and moving with it.

Parameters
[in]bodyThe rigid body the point is attached to.
[in]posPosition we wish to determine the velocity for, defined in the local frame. Range: position vector
Returns
The velocity of point in the local frame.
See also
getLocalPointVelocity()

◆ getVelocityAtOffset()

static PxVec3 PxRigidBodyExt::getVelocityAtOffset ( const PxRigidBody body,
const PxVec3 pos 
)
static

Computes the velocity of a point (offset from the origin of the body) given in world coordinates if it were attached to the specified body and moving with it.

Parameters
[in]bodyThe rigid body the point is attached to.
[in]posPosition (offset from the origin of the body) we wish to determine the velocity for, defined in the global frame. Range: position vector
Returns
The velocity of point (offset from the origin of the body) in the global frame.
See also
getLocalPointVelocity()

◆ getVelocityAtPos()

static PxVec3 PxRigidBodyExt::getVelocityAtPos ( const PxRigidBody body,
const PxVec3 pos 
)
static

Computes the velocity of a point given in world coordinates if it were attached to the specified body and moving with it.

Parameters
[in]bodyThe rigid body the point is attached to.
[in]posPosition we wish to determine the velocity for, defined in the global frame. Range: position vector
Returns
The velocity of point in the global frame.
See also
getLocalPointVelocity()

◆ linearSweepMultiple()

static PxU32 PxRigidBodyExt::linearSweepMultiple ( PxRigidBody body,
PxScene scene,
const PxVec3 unitDir,
const PxReal  distance,
PxHitFlags  outputFlags,
PxSweepHit touchHitBuffer,
PxU32 touchHitShapeIndices,
PxU32  touchHitBufferSize,
PxSweepHit block,
PxI32 &  blockingShapeIndex,
bool &  overflow,
const PxQueryFilterData filterData = PxQueryFilterData(),
PxQueryFilterCallback filterCall = NULL,
const PxQueryCache cache = NULL,
const PxReal  inflation = 0.0f 
)
static

Performs a linear sweep through space with the body's geometry objects, returning all overlaps.

Note
Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored.

This function sweeps all shapes attached to a given rigid body through space and reports all objects in the scene that intersect any of the shapes' swept paths until there are no more objects to report or a blocking hit is encountered.

Parameters
[in]bodyThe rigid body to sweep.
[in]sceneThe scene object to process the query.
[in]unitDirNormalized direction of the sweep.
[in]distanceSweep distance. Needs to be larger than 0.
[in]outputFlagsSpecifies which properties should be written to the hit information.
[out]touchHitBufferRaycast hit information buffer. If the buffer overflows, an arbitrary subset of touch hits is returned (typically the query should be restarted with a larger buffer).
[out]touchHitShapeIndicesAfter the query is completed, touchHitShapeIndices[i] will contain the body index that caused the hit stored in hitBuffer[i]
[in]touchHitBufferSizeSize of both touch hit buffers in elements.
[out]blockClosest blocking hit is returned via this reference.
[out]blockingShapeIndexSet to -1 if if a blocking hit was not found, otherwise set to closest blocking hit shape index. The touching hits are reported separately in hitBuffer.
[out]overflowSet to true if touchHitBuffer didn't have enough space for all results. Touch hits will be incomplete if overflow occurred. Possible solution is to restart the query with a larger buffer.
[in]filterDataIf any word in filterData.data is non-zero then filterData.data will be used for filtering, otherwise shape->getQueryFilterData() will be used instead.
[in]filterCallCustom filtering logic (optional). Only used if the corresponding PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking.
[in]cacheCached hit shape (optional). Ray is tested against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
[in]inflationThis parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
Returns
the number of touching hits. If overflow is set to true, the results are incomplete. In case of overflow there are also no guarantees that all touching hits returned are closer than the blocking hit.
See also
PxScene PxQueryFlags PxFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxSweepHit

◆ linearSweepSingle()

static bool PxRigidBodyExt::linearSweepSingle ( PxRigidBody body,
PxScene scene,
const PxVec3 unitDir,
const PxReal  distance,
PxHitFlags  outputFlags,
PxSweepHit closestHit,
PxU32 shapeIndex,
const PxQueryFilterData filterData = PxQueryFilterData(),
PxQueryFilterCallback filterCall = NULL,
const PxQueryCache cache = NULL,
const PxReal  inflation = 0.0f 
)
static

Performs a linear sweep through space with the body's geometry objects.

Note
Supported geometries are: box, sphere, capsule, convex. Other geometry types will be ignored.
If eTOUCH is returned from the filter callback, it will trigger an error and the hit will be discarded.

The function sweeps all shapes attached to a given rigid body through space and reports the nearest object in the scene which intersects any of of the shapes swept paths. Information about the closest intersection is written to a PxSweepHit structure.

Parameters
[in]bodyThe rigid body to sweep.
[in]sceneThe scene object to process the query.
[in]unitDirNormalized direction of the sweep.
[in]distanceSweep distance. Needs to be larger than 0.
[in]outputFlagsSpecifies which properties should be written to the hit information.
[out]closestHitClosest hit result.
[out]shapeIndexIndex of the body shape that caused the closest hit.
[in]filterDataIf any word in filterData.data is non-zero then filterData.data will be used for filtering, otherwise shape->getQueryFilterData() will be used instead.
[in]filterCallCustom filtering logic (optional). Only used if the corresponding PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking.
[in]cacheCached hit shape (optional). Ray is tested against cached shape first then against the scene. Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
[in]inflationThis parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
Returns
True if a blocking hit was found.
See also
PxScene PxQueryFlags PxFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxSweepHit

◆ setMassAndUpdateInertia() [1/2]

static bool PxRigidBodyExt::setMassAndUpdateInertia ( PxRigidBody body,
const PxReal *  shapeMasses,
PxU32  shapeMassCount,
const PxVec3 massLocalPose = NULL,
bool  includeNonSimShapes = false 
)
static

Computation of mass properties for a rigid body actor.

This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the sum of all user-supplied shape mass values, and the inertia and center of mass are computed according to the rigid body's shapes and the per shape mass input values.

If no collision shapes are found, the inertia tensor is set to (1,1,1)

Note
If a single mass value should be used for the actor as a whole then the overloaded method setMassAndUpdateInertia() with a single mass parameter can be used instead.
See also
updateMassAndInertia for more details.
Parameters
[in,out]bodyThe rigid body for which to set the mass and centre of mass local pose properties.
[in]shapeMassesThe per shape mass values. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set. Other shapes are ignored. The mass values must be greater than 0.
[in]shapeMassCountThe number of provided mass values.
[in]massLocalPoseThe center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
[in]includeNonSimShapesTrue if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
Returns
Boolean. True on success else false.
See also
PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass

◆ setMassAndUpdateInertia() [2/2]

static bool PxRigidBodyExt::setMassAndUpdateInertia ( PxRigidBody body,
PxReal  mass,
const PxVec3 massLocalPose = NULL,
bool  includeNonSimShapes = false 
)
static

Computation of mass properties for a rigid body actor.

This method sets the mass, inertia and center of mass of a rigid body. The mass is set to the user-supplied value, and the inertia and center of mass are computed according to the rigid body's shapes and the input mass.

If no collision shapes are found, the inertia tensor is set to (1,1,1)

See also
updateMassAndInertia for more details.
Parameters
[in,out]bodyThe rigid body for which to set the mass and centre of mass local pose properties.
[in]massThe mass of the body. Must be greater than 0.
[in]massLocalPoseThe center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
[in]includeNonSimShapesTrue if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
Returns
Boolean. True on success else false.
See also
PxRigidBody::setCMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass

◆ updateMassAndInertia() [1/2]

static bool PxRigidBodyExt::updateMassAndInertia ( PxRigidBody body,
const PxReal *  shapeDensities,
PxU32  shapeDensityCount,
const PxVec3 massLocalPose = NULL,
bool  includeNonSimShapes = false 
)
static

Computation of mass properties for a rigid body actor.

To simulate a dynamic rigid actor, the SDK needs a mass and an inertia tensor.

This method offers functionality to compute the necessary mass and inertia properties based on the shapes declared in the PxRigidBody descriptor and some additionally specified parameters. For each shape, the shape geometry, the shape positioning within the actor and the specified shape density are used to compute the body's mass and inertia properties.

This method will set the mass, center of mass, and inertia tensor

if no collision shapes are found, the inertia tensor is set to (1,1,1) and the mass to 1

if massLocalPose is non-NULL, the rigid body's center of mass parameter will be set to the user provided value (massLocalPose) and the inertia tensor will be resolved at that point.

Note
If all shapes of the actor have the same density then the overloaded method updateMassAndInertia() with a single density parameter can be used instead.
Parameters
[in,out]bodyThe rigid body.
[in]shapeDensitiesThe per shape densities. There must be one entry for each shape which has the PxShapeFlag::eSIMULATION_SHAPE set (or for all shapes if includeNonSimShapes is set to true). Other shapes are ignored. The density values must be greater than 0.
[in]shapeDensityCountThe number of provided density values.
[in]massLocalPoseThe center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
[in]includeNonSimShapesTrue if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
Returns
Boolean. True on success else false.
See also
PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass

◆ updateMassAndInertia() [2/2]

static bool PxRigidBodyExt::updateMassAndInertia ( PxRigidBody body,
PxReal  density,
const PxVec3 massLocalPose = NULL,
bool  includeNonSimShapes = false 
)
static

Computation of mass properties for a rigid body actor.

See previous method for details.

Parameters
[in,out]bodyThe rigid body.
[in]densityThe density of the body. Used to compute the mass of the body. The density must be greater than 0.
[in]massLocalPoseThe center of mass relative to the actor frame. If set to null then (0,0,0) is assumed.
[in]includeNonSimShapesTrue if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE) should be taken into account.
Returns
Boolean. True on success else false.
See also
PxRigidBody::setMassLocalPose PxRigidBody::setMassSpaceInertiaTensor PxRigidBody::setMass

The documentation for this class was generated from the following file: