PxSimulationEventCallback Class Referenceabstract

An interface class that the user can implement in order to receive simulation events. More...

#include <PxSimulationEventCallback.h>

Public Member Functions

virtual void onConstraintBreak (PxConstraintInfo *constraints, PxU32 count)=0
 This is called when a breakable constraint breaks. More...
 
virtual void onWake (PxActor **actors, PxU32 count)=0
 This is called with the actors which have just been woken up. More...
 
virtual void onSleep (PxActor **actors, PxU32 count)=0
 This is called with the actors which have just been put to sleep. More...
 
virtual void onContact (const PxContactPairHeader &pairHeader, const PxContactPair *pairs, PxU32 nbPairs)=0
 This is called when certain contact events occur. More...
 
virtual void onTrigger (PxTriggerPair *pairs, PxU32 count)=0
 This is called with the current trigger pair events. More...
 
virtual void onAdvance (const PxRigidBody *const *bodyBuffer, const PxTransform *poseBuffer, const PxU32 count)=0
 Provides early access to the new pose of moving rigid bodies. More...
 
virtual ~PxSimulationEventCallback ()
 

Detailed Description

An interface class that the user can implement in order to receive simulation events.

With the exception of onAdvance(), the events get sent during the call to either PxScene::fetchResults() or PxScene::flushSimulation() with sendPendingReports=true. onAdvance() gets called while the simulation is running (that is between PxScene::simulate(), onAdvance() and PxScene::fetchResults()).

Note
SDK state should not be modified from within the callbacks. In particular objects should not be created or destroyed. If state modification is needed then the changes should be stored to a buffer and performed after the simulation step.

Threading: With the exception of onAdvance(), it is not necessary to make these callbacks thread safe as they will only be called in the context of the user thread.

See also
PxScene.setSimulationEventCallback() PxScene.getSimulationEventCallback()

Constructor & Destructor Documentation

◆ ~PxSimulationEventCallback()

virtual PxSimulationEventCallback::~PxSimulationEventCallback ( )
inlinevirtual

Member Function Documentation

◆ onAdvance()

virtual void PxSimulationEventCallback::onAdvance ( const PxRigidBody *const *  bodyBuffer,
const PxTransform poseBuffer,
const PxU32  count 
)
pure virtual

Provides early access to the new pose of moving rigid bodies.

When this call occurs, rigid bodies having the PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW flag set, were moved by the simulation and their new poses can be accessed through the provided buffers.

Note
The provided buffers are valid and can be read until the next call to PxScene::simulate() or PxScene::collide().
Buffered user changes to the rigid body pose will not yet be reflected in the provided data. More important, the provided data might contain bodies that have been deleted while the simulation was running. It is the user's responsibility to detect and avoid dereferencing such bodies.
This callback gets triggered while the simulation is running. If the provided rigid body references are used to read properties of the object, then the callback has to guarantee no other thread is writing to the same body at the same time.
The code in this callback should be lightweight as it can block the simulation, that is, the PxScene::fetchResults() call.
Parameters
[in]bodyBufferThe rigid bodies that moved and requested early pose reporting.
[in]poseBufferThe integrated rigid body poses of the bodies listed in bodyBuffer.
[in]countThe number of entries in the provided buffers.
See also
PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW

◆ onConstraintBreak()

virtual void PxSimulationEventCallback::onConstraintBreak ( PxConstraintInfo constraints,
PxU32  count 
)
pure virtual

This is called when a breakable constraint breaks.

Note
The user should not release the constraint shader inside this call!
No event will get reported if the constraint breaks but gets deleted while the time step is still being simulated.
Parameters
[in]constraints- The constraints which have been broken.
[in]count- The number of constraints
See also
PxConstraint PxConstraintDesc.linearBreakForce PxConstraintDesc.angularBreakForce

◆ onContact()

virtual void PxSimulationEventCallback::onContact ( const PxContactPairHeader pairHeader,
const PxContactPair pairs,
PxU32  nbPairs 
)
pure virtual

This is called when certain contact events occur.

The method will be called for a pair of actors if one of the colliding shape pairs requested contact notification. You request which events are reported using the filter shader/callback mechanism (see PxSimulationFilterShader, PxSimulationFilterCallback, PxPairFlag).

Do not keep references to the passed objects, as they will be invalid after this function returns.

Parameters
[in]pairHeaderInformation on the two actors whose shapes triggered a contact report.
[in]pairsThe contact pairs of two actors for which contact reports have been requested. See PxContactPair.
[in]nbPairsThe number of provided contact pairs.
See also
PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxContactPair PxPairFlag PxSimulationFilterShader PxSimulationFilterCallback

◆ onSleep()

virtual void PxSimulationEventCallback::onSleep ( PxActor **  actors,
PxU32  count 
)
pure virtual

This is called with the actors which have just been put to sleep.

Note
Only supported by rigid bodies yet.
Only called on actors for which the PxActorFlag eSEND_SLEEP_NOTIFIES has been set.
Only the latest sleep state transition happening between fetchResults() of the previous frame and fetchResults() of the current frame will get reported. For example, let us assume actor A is asleep, then A->wakeUp() gets called, then later A->putToSleep() gets called. At the next simulate/fetchResults() step only an onSleep() event will get triggered because that was the last transition (assuming the simulation does not wake the actor up).
If an actor gets newly added to a scene with properties such that it is asleep and the sleep state does not get changed by the user or simulation, then an onSleep() event will get sent at the next simulate/fetchResults() step.
Parameters
[in]actors- The actors which have just been put to sleep.
[in]count- The number of actors
See also
PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxActorFlag PxActor.setActorFlag()

◆ onTrigger()

virtual void PxSimulationEventCallback::onTrigger ( PxTriggerPair pairs,
PxU32  count 
)
pure virtual

This is called with the current trigger pair events.

Shapes which have been marked as triggers using PxShapeFlag::eTRIGGER_SHAPE will send events according to the pair flag specification in the filter shader (see PxPairFlag, PxSimulationFilterShader).

Note
Trigger shapes will no longer send notification events for interactions with other trigger shapes.
Parameters
[in]pairs- The trigger pair events.
[in]count- The number of trigger pair events.
See also
PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxPairFlag PxSimulationFilterShader PxShapeFlag PxShape.setFlag()

◆ onWake()

virtual void PxSimulationEventCallback::onWake ( PxActor **  actors,
PxU32  count 
)
pure virtual

This is called with the actors which have just been woken up.

Note
Only supported by rigid bodies yet.
Only called on actors for which the PxActorFlag eSEND_SLEEP_NOTIFIES has been set.
Only the latest sleep state transition happening between fetchResults() of the previous frame and fetchResults() of the current frame will get reported. For example, let us assume actor A is awake, then A->putToSleep() gets called, then later A->wakeUp() gets called. At the next simulate/fetchResults() step only an onWake() event will get triggered because that was the last transition.
If an actor gets newly added to a scene with properties such that it is awake and the sleep state does not get changed by the user or simulation, then an onWake() event will get sent at the next simulate/fetchResults() step.
Parameters
[in]actors- The actors which just woke up.
[in]count- The number of actors
See also
PxScene.setSimulationEventCallback() PxSceneDesc.simulationEventCallback PxActorFlag PxActor.setActorFlag()

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