Skip to main content

collider_active_hooks

Physics hooks are user-defined callbacks used to filter-out some contact pairs, or modify contacts, based on arbitrary user code. In order to enable a physics hook for a pair of colliders, at least one of the involved colliders must have the corresponding hook set as active. A hook is activated for a collider by setting its corresponding active hooks bit to 1:

The active hooks of a collider can be set when the collider is created or after its creation (the callbacks themselves are given to r3Step as a R3PhysicsHooks, see physics hooks):

/* Set the active hooks when the collider is created. */
R2ColliderDesc collider = r2BallColliderDesc(0.5);
collider.activeHooks = R2_FILTER_CONTACT_PAIRS | R2_MODIFY_SOLVER_CONTACTS;
/* Set the active hooks after the collider creation. */
r2Collider_SetActiveHooks(collider_handle, R2_FILTER_CONTACT_PAIRS | R2_MODIFY_SOLVER_CONTACTS);
assert(r2Collider_ActiveHooks(collider_handle) & R2_FILTER_CONTACT_PAIRS);
assert(r2Collider_ActiveHooks(collider_handle) & R2_MODIFY_SOLVER_CONTACTS);