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 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... | |
utility functions for use with PxRigidBody and subclasses
|
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.
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).
[in] | body | The rigid body to apply the force to. |
[in] | force | Force/impulse to add, defined in the global frame. Range: force vector |
[in] | pos | Position in the local frame to add the force at. Range: position vector |
[in] | mode | The mode to use when applying the force/impulse(see PxForceMode). |
[in] | wakeup | Specify if the call should wake up the actor. |
|
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.
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).
[in] | body | The rigid body to apply the force to. |
[in] | force | Force/impulse to add, defined in the global frame. Range: force vector |
[in] | pos | Position in the global frame to add the force at. Range: position vector |
[in] | mode | The mode to use when applying the force/impulse(see PxForceMode). |
[in] | wakeup | Specify if the call should wake up the actor. |
|
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.
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).
[in] | body | The rigid body to apply the force to. |
[in] | force | Force/impulse to add, defined in the local frame. Range: force vector |
[in] | pos | Position in the local frame to add the force at. Range: position vector |
[in] | mode | The mode to use when applying the force/impulse(see PxForceMode). |
[in] | wakeup | Specify if the call should wake up the actor. |
|
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.
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).
[in] | body | The rigid body to apply the force to. |
[in] | force | Force/impulse to add, defined in the local frame. Range: force vector |
[in] | pos | Position in the global frame to add the force at. Range: position vector |
[in] | mode | The mode to use when applying the force/impulse(see PxForceMode). |
[in] | wakeup | Specify if the call should wake up the actor. |
|
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.
[in] | body | The rigid body |
[in] | globalPose | The body's world space transform |
[in] | point | The point in world space where the impulse is applied |
[in] | impulse | The impulse vector in world space |
[in] | invMassScale | The inverse mass scale |
[in] | invInertiaScale | The inverse inertia scale |
[out] | linearImpulse | The linear impulse |
[out] | angularImpulse | The angular impulse |
|
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.
[in] | body | The body under consideration. |
[in] | impulsiveForce | The impulsive force that would be applied to the specified rigid body. |
[in] | impulsiveTorque | The impulsive torque that would be applied to the specified rigid body. |
[out] | deltaLinearVelocity | The change in linear velocity that would arise if impulsiveForce was to be applied to the specified rigid body. |
[out] | deltaAngularVelocity | The change in angular velocity that would arise if impulsiveTorque was to be applied to the specified rigid body. |
|
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.
[in] | body | The rigid body |
[in] | globalPose | The body's world space transform |
[in] | point | The point in world space where the impulse is applied |
[in] | impulse | The impulse vector in world space |
[in] | invMassScale | The inverse mass scale |
[in] | invInertiaScale | The inverse inertia scale |
[out] | deltaLinearVelocity | The linear velocity change |
[out] | deltaAngularVelocity | The angular velocity change |
|
static |
Computes the velocity of a point given in local coordinates if it were attached to the specified body and moving with it.
[in] | body | The rigid body the point is attached to. |
[in] | pos | Position we wish to determine the velocity for, defined in the local frame. Range: position vector |
|
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.
[in] | body | The rigid body the point is attached to. |
[in] | pos | Position (offset from the origin of the body) we wish to determine the velocity for, defined in the global frame. Range: position vector |
|
static |
Computes the velocity of a point given in world coordinates if it were attached to the specified body and moving with it.
[in] | body | The rigid body the point is attached to. |
[in] | pos | Position we wish to determine the velocity for, defined in the global frame. Range: position vector |
|
static |
Performs a linear sweep through space with the body's geometry objects, returning all overlaps.
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.
[in] | body | The rigid body to sweep. |
[in] | scene | The scene object to process the query. |
[in] | unitDir | Normalized direction of the sweep. |
[in] | distance | Sweep distance. Needs to be larger than 0. |
[in] | outputFlags | Specifies which properties should be written to the hit information. |
[out] | touchHitBuffer | Raycast 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] | touchHitShapeIndices | After the query is completed, touchHitShapeIndices[i] will contain the body index that caused the hit stored in hitBuffer[i] |
[in] | touchHitBufferSize | Size of both touch hit buffers in elements. |
[out] | block | Closest blocking hit is returned via this reference. |
[out] | blockingShapeIndex | Set 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] | overflow | Set 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] | filterData | If any word in filterData.data is non-zero then filterData.data will be used for filtering, otherwise shape->getQueryFilterData() will be used instead. |
[in] | filterCall | Custom filtering logic (optional). Only used if the corresponding PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. |
[in] | cache | Cached 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] | inflation | This 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. |
|
static |
Performs a linear sweep through space with the body's geometry objects.
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.
[in] | body | The rigid body to sweep. |
[in] | scene | The scene object to process the query. |
[in] | unitDir | Normalized direction of the sweep. |
[in] | distance | Sweep distance. Needs to be larger than 0. |
[in] | outputFlags | Specifies which properties should be written to the hit information. |
[out] | closestHit | Closest hit result. |
[out] | shapeIndex | Index of the body shape that caused the closest hit. |
[in] | filterData | If any word in filterData.data is non-zero then filterData.data will be used for filtering, otherwise shape->getQueryFilterData() will be used instead. |
[in] | filterCall | Custom filtering logic (optional). Only used if the corresponding PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. |
[in] | cache | Cached 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] | inflation | This 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. |
|
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)
[in,out] | body | The the rigid body for which to set the mass and centre of mass local pose properties. |
[in] | shapeMasses | The 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] | shapeMassCount | The number of provided mass values. |
[in] | massLocalPose | The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
[in] | includeNonSimShapes | True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE, PxShapeFlag::ePARTICLE_DRAIN) should be taken into account. |
|
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)
[in,out] | body | The the rigid body for which to set the mass and centre of mass local pose properties. |
[in] | mass | The mass of the body. Must be greater than 0. |
[in] | massLocalPose | The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
[in] | includeNonSimShapes | True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE, PxShapeFlag::ePARTICLE_DRAIN) should be taken into account. |
|
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.
[in,out] | body | The rigid body. |
[in] | shapeDensities | The 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] | shapeDensityCount | The number of provided density values. |
[in] | massLocalPose | The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
[in] | includeNonSimShapes | True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE, PxShapeFlag::ePARTICLE_DRAIN) should be taken into account. |
|
static |
Computation of mass properties for a rigid body actor.
See previous method for details.
[in,out] | body | The rigid body. |
[in] | density | The density of the body. Used to compute the mass of the body. The density must be greater than 0. |
[in] | massLocalPose | The center of mass relative to the actor frame. If set to null then (0,0,0) is assumed. |
[in] | includeNonSimShapes | True if all kind of shapes (PxShapeFlag::eSCENE_QUERY_SHAPE, PxShapeFlag::eTRIGGER_SHAPE, PxShapeFlag::ePARTICLE_DRAIN) should be taken into account. |