PxSimulationFilterCallback

Defined in include/PxFiltering.h

class PxSimulationFilterCallback

Filter callback to specify handling of collision pairs.

This class is provided to implement more complex and flexible collision pair filtering logic, for instance, taking the state of the user application into account. Filter callbacks also give the user the opportunity to track collision pairs and update their filter state.

You might want to check the documentation on PxSimulationFilterShader as well since it includes more general information on filtering.

See also

PxSceneDesc.filterCallback PxSimulationFilterShader

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.

Note

The callbacks may execute in user threads or simulation threads, possibly simultaneously. The corresponding objects may have been deleted by the application earlier in the frame. It is the application’s responsibility to prevent race conditions arising from using the SDK API in the callback while an application thread is making write calls to the scene, and to ensure that the callbacks are thread-safe. Return values which depend on when the callback is called during the frame will introduce nondeterminism into the simulation.

Public Functions

virtual PxFilterFlags pairFound(PxU64 pairID, PxFilterObjectAttributes attributes0, PxFilterData filterData0, const PxActor *a0, const PxShape *s0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, const PxActor *a1, const PxShape *s1, PxPairFlags &pairFlags) = 0

Filter method to specify how a pair of potentially colliding objects should be processed.

This method gets called when the filter flags returned by the filter shader (see PxSimulationFilterShader) indicate that the filter callback should be invoked (PxFilterFlag::eCALLBACK or PxFilterFlag::eNOTIFY set). Return the PxFilterFlag flags and set the PxPairFlag flags to define what the simulation should do with the given collision pair.

See also

PxSimulationFilterShader PxFilterData PxFilterObjectAttributes PxFilterFlag PxPairFlag

Parameters
  • pairID[in] Unique ID of the collision pair used to issue filter status changes for the pair (see statusChange())

  • attributes0[in] The filter attribute of the first object

  • filterData0[in] The custom filter data of the first object

  • a0[in] Actor pointer of the first object

  • s0[in] Shape pointer of the first object (NULL if the object has no shapes)

  • attributes1[in] The filter attribute of the second object

  • filterData1[in] The custom filter data of the second object

  • a1[in] Actor pointer of the second object

  • s1[in] Shape pointer of the second object (NULL if the object has no shapes)

  • pairFlags[inout] In: Pair flags returned by the filter shader. Out: Additional information on how an accepted pair should get processed

Returns

Filter flags defining whether the pair should be discarded, temporarily ignored or processed and whether the pair should be tracked and send a report on pair deletion through the filter callback

virtual void pairLost(PxU64 pairID, PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, bool objectRemoved) = 0

Callback to inform that a tracked collision pair is gone.

This method gets called when a collision pair disappears or gets re-filtered. Only applies to collision pairs which have been marked as filter callback pairs (PxFilterFlag::eNOTIFY set in pairFound()).

See also

pairFound() PxSimulationFilterShader PxFilterData PxFilterObjectAttributes

Parameters
  • pairID[in] Unique ID of the collision pair that disappeared

  • attributes0[in] The filter attribute of the first object

  • filterData0[in] The custom filter data of the first object

  • attributes1[in] The filter attribute of the second object

  • filterData1[in] The custom filter data of the second object

  • objectRemoved[in] True if the pair was lost because one of the objects got removed from the scene

virtual bool statusChange(PxU64 &pairID, PxPairFlags &pairFlags, PxFilterFlags &filterFlags) = 0

Callback to give the opportunity to change the filter state of a tracked collision pair.

This method gets called once per simulation step to let the application change the filter and pair flags of a collision pair that has been reported in pairFound() and requested callbacks by setting PxFilterFlag::eNOTIFY. To request a change of filter status, the target pair has to be specified by its ID, the new filter and pair flags have to be provided and the method should return true.

See also

pairFound() pairLost() PxFilterFlag PxPairFlag

Note

If this method changes the filter status of a collision pair and the pair should keep being tracked by the filter callbacks then PxFilterFlag::eNOTIFY has to be set.

Note

The application is responsible to ensure that this method does not get called for pairs that have been reported as lost, see pairLost().

Parameters
  • pairID[out] ID of the collision pair for which the filter status should be changed

  • pairFlags[out] The new pairFlags to apply to the collision pair

  • filterFlags[out] The new filterFlags to apply to the collision pair

Returns

True if the changes should be applied. In this case the method will get called again. False if no more status changes should be done in the current simulation step. In that case the provided flags will be discarded.

Protected Functions

inline virtual ~PxSimulationFilterCallback()