Rapier C — 3D / f64 0.36.0+c.0
Loading...
Searching...
No Matches
Events, contacts, and debug drawing

Event collectors own their recorded events. More...

Data Structures

struct  R3CollisionEvent
 Collision start/stop flags match Rapier CollisionEventFlags. More...
struct  R3ContactForceEvent
 Contact-force event, enabled by flags and the collider force threshold. More...
struct  R3ContactModification
 Mutable per-manifold properties. More...
struct  R3DebugLine
 World-space line segment produced by physics debug rendering. More...
struct  R3ContactPair
 Current narrow-phase pair and accumulated solver impulse summary. More...
struct  R3IntersectionPair
 Sensor intersection state for a collider pair. More...
struct  R3ContactPoint
 One manifold contact and its normal solver impulse. More...
struct  R3OptionalContactPair
 Optional contact pair; check found before reading the pair. More...
struct  R3OptionalIntersectionPair
 Optional intersection pair; check found before reading the pair. More...
struct  R3ContactManifold
 Geometric contact manifold of a contact pair: contacts sharing one normal. More...
struct  R3SolverContact
 Contact seen by the constraint solver. More...
struct  R3EventCallbacks
 Callbacks invoked while stepping, in addition to collecting the events. More...
struct  R3DebugRenderStyle
 Debug-render colors and sizes. More...

Macros

#define R3_DEBUG_COLLIDER_SHAPES   1
 Debug-render flag: collider shapes.
#define R3_DEBUG_RIGID_BODY_AXES   2
 Debug-render flag: rigid body axes.
#define R3_DEBUG_MULTIBODY_JOINTS   4
 Debug-render flag: multibody joints.
#define R3_DEBUG_IMPULSE_JOINTS   8
 Debug-render flag: impulse joints.
#define R3_DEBUG_SOLVER_CONTACTS   16
 Debug-render flag: solver contacts.
#define R3_DEBUG_CONTACTS   32
 Debug-render flag: contacts.
#define R3_DEBUG_COLLIDER_AABBS   64
 Debug-render flag: collider aabbs.
#define R3_DEBUG_SOFT_BODIES   128
 Debug-render flag: soft bodies.
#define R3_DEBUG_PSEUDO_NORMALS   256
 Debug-render flag: pseudo normals.
#define R3_DEBUG_SOFT_VOLUME_CONTACTS   512
 Debug-render flag: soft volume contacts.
#define R3_DEBUG_SOFT_BODY_STRESS   1024
 Debug-render flag: soft body stress.
#define R3_COLLISION_EVENT_SENSOR   1
 Collision event flag: at least one of the colliders was a sensor when the event fired.
#define R3_COLLISION_EVENT_REMOVED   2
 Collision event flag: the collision stopped because at least one collider was removed.

Typedefs

typedef struct R3EventCollector R3EventCollector
 Events accumulate across steps until r3EventCollector_Clear: reading them never drains the collector, allowing two-call buffer sizing.
typedef struct R3SoftBodyTearEvent R3SoftBodyTearEvent
 Owned copy of a tear event.
typedef struct R3CollisionEvent R3CollisionEvent
 Collision start/stop flags match Rapier CollisionEventFlags.
typedef struct R3ContactForceEvent R3ContactForceEvent
 Contact-force event, enabled by flags and the collider force threshold.
typedef struct R3ContactModification R3ContactModification
 Mutable per-manifold properties.
typedef struct R3DebugLine R3DebugLine
 World-space line segment produced by physics debug rendering.
typedef struct R3ContactPair R3ContactPair
 Current narrow-phase pair and accumulated solver impulse summary.
typedef struct R3IntersectionPair R3IntersectionPair
 Sensor intersection state for a collider pair.
typedef struct R3ContactPoint R3ContactPoint
 One manifold contact and its normal solver impulse.
typedef struct R3OptionalContactPair R3OptionalContactPair
 Optional contact pair; check found before reading the pair.
typedef struct R3OptionalIntersectionPair R3OptionalIntersectionPair
 Optional intersection pair; check found before reading the pair.
typedef struct R3ContactManifold R3ContactManifold
 Geometric contact manifold of a contact pair: contacts sharing one normal.
typedef struct R3SolverContact R3SolverContact
 Contact seen by the constraint solver.
typedef void(*) R3CollisionEventCallback(void *user_data, const struct R3ReadContext *read, const struct R3CollisionEvent *event, const struct R3ContactPoint *contacts, size_t contact_count)
 Called during the step for each collision event, after it was added to the collector.
typedef void(*) R3ContactForceEventCallback(void *user_data, const struct R3ReadContext *read, const struct R3ContactForceEvent *event)
 Called during the step for each contact-force event, after it was added to the collector.
typedef struct R3EventCallbacks R3EventCallbacks
 Callbacks invoked while stepping, in addition to collecting the events.
typedef struct R3DebugRenderStyle R3DebugRenderStyle
 Debug-render colors and sizes.

Functions

struct R3EventCollector * r3NewEventCollector (void)
 Allocate an empty event collector; release it with r3FreeEventCollector.
R3Status r3FreeEventCollector (struct R3EventCollector *events)
 Release an owned event collector.
R3Status r3EventCollector_Clear (struct R3EventCollector *events)
 Discard all collected events.
size_t r3EventCollector_CollisionEvents (const struct R3EventCollector *events, struct R3CollisionEvent *buffer, size_t capacity)
 Copy the collision start/stop events collected since the last clear, without removing them.
size_t r3EventCollector_ContactForceEvents (const struct R3EventCollector *events, struct R3ContactForceEvent *buffer, size_t capacity)
 Copy the contact-force events collected since the last clear, without removing them.
size_t r3EventCollector_TearEventCount (const struct R3EventCollector *events)
 Return the number of soft-body tear events collected since the last clear.
struct R3SoftBodyTearEvent * r3EventCollector_TearEvent (const struct R3EventCollector *events, size_t index)
 Return an owned copy of a queued tear event; release with r3FreeSoftBodyTearEvent.
size_t r3DebugRender (const struct R3World *world, uint32_t mode, struct R3DebugLine *buffer, size_t capacity)
 Copy the debug-render lines of the world with the default style.
size_t r3ContactPairs (const struct R3World *world, struct R3ContactPair *buffer, size_t capacity)
 Copy current narrow-phase contact pairs, including pairs without active solver contacts.
struct R3ContactPair r3ContactPair (struct R3ColliderHandle collider1, struct R3ColliderHandle collider2)
 Return the narrow-phase contact pair for two colliders, or report R3_NOT_FOUND.
size_t r3IntersectionPairs (const struct R3World *world, struct R3IntersectionPair *buffer, size_t capacity)
 Copy current sensor intersection pairs from the narrow phase.
size_t r3ContactPoints (struct R3ColliderHandle collider1, struct R3ColliderHandle collider2, struct R3ContactPoint *buffer, size_t capacity)
 Contact points in collider-local space; normal in world space.
struct R3OptionalContactPair r3TryContactPair (struct R3ColliderHandle collider1, struct R3ColliderHandle collider2)
 Return the narrow-phase contact pair for two colliders, with found = 0 if the broad phase found no potential contact between them (R3_OK).
struct R3IntersectionPair r3IntersectionPair (struct R3ColliderHandle collider1, struct R3ColliderHandle collider2)
 Return the intersection state of two colliders involving a sensor, or report R3_NOT_FOUND if the broad phase found no potential intersection.
struct R3OptionalIntersectionPair r3TryIntersectionPair (struct R3ColliderHandle collider1, struct R3ColliderHandle collider2)
 Return the intersection state of two colliders involving a sensor, with found = 0 if the broad phase found no potential intersection (R3_OK).
size_t r3Collider_ContactPairs (struct R3ColliderHandle handle, struct R3ContactPair *buffer, size_t capacity)
 Copy the narrow-phase contact pairs involving the collider, including pairs without active solver contacts.
size_t r3Collider_IntersectionPairs (struct R3ColliderHandle handle, struct R3IntersectionPair *buffer, size_t capacity)
 Copy the intersection pairs involving the collider, in the narrow-phase order.
size_t r3ContactManifolds (struct R3ColliderHandle collider1, struct R3ColliderHandle collider2, struct R3ContactManifold *buffer, size_t capacity)
 Copy the geometric contact manifolds of a contact pair, or report R3_NOT_FOUND without a pair.
size_t r3SolverContacts (struct R3ColliderHandle collider1, struct R3ColliderHandle collider2, size_t manifold_index, struct R3SolverContact *buffer, size_t capacity)
 Copy the solver contacts of one manifold of a contact pair, or report R3_NOT_FOUND without a pair.
R3Status r3EventCollector_SetCallbacks (struct R3EventCollector *events, const struct R3EventCallbacks *callbacks)
 Replace the callbacks invoked while stepping with this collector; NULL removes them.
struct R3DebugRenderStyle r3DefaultDebugRenderStyle (void)
 Return native default debug-render style.
size_t r3DebugRenderWithStyle (const struct R3World *world, uint32_t mode, const struct R3DebugRenderStyle *style, struct R3DebugLine *buffer, size_t capacity)
 Copy the debug-render lines of the world drawn with the given style.

Detailed Description

Event collectors own their recorded events.

Enable event flags on colliders and pass a collector when stepping. Copying events does not drain the collector; Clear discards them. Contact-force events also honor the collider force threshold.

Macro Definition Documentation

◆ R3_COLLISION_EVENT_REMOVED

#define R3_COLLISION_EVENT_REMOVED   2

Collision event flag: the collision stopped because at least one collider was removed.

◆ R3_COLLISION_EVENT_SENSOR

#define R3_COLLISION_EVENT_SENSOR   1

Collision event flag: at least one of the colliders was a sensor when the event fired.

◆ R3_DEBUG_COLLIDER_AABBS

#define R3_DEBUG_COLLIDER_AABBS   64

Debug-render flag: collider aabbs.

◆ R3_DEBUG_COLLIDER_SHAPES

#define R3_DEBUG_COLLIDER_SHAPES   1

Debug-render flag: collider shapes.

◆ R3_DEBUG_CONTACTS

#define R3_DEBUG_CONTACTS   32

Debug-render flag: contacts.

◆ R3_DEBUG_IMPULSE_JOINTS

#define R3_DEBUG_IMPULSE_JOINTS   8

Debug-render flag: impulse joints.

◆ R3_DEBUG_MULTIBODY_JOINTS

#define R3_DEBUG_MULTIBODY_JOINTS   4

Debug-render flag: multibody joints.

◆ R3_DEBUG_PSEUDO_NORMALS

#define R3_DEBUG_PSEUDO_NORMALS   256

Debug-render flag: pseudo normals.

◆ R3_DEBUG_RIGID_BODY_AXES

#define R3_DEBUG_RIGID_BODY_AXES   2

Debug-render flag: rigid body axes.

◆ R3_DEBUG_SOFT_BODIES

#define R3_DEBUG_SOFT_BODIES   128

Debug-render flag: soft bodies.

◆ R3_DEBUG_SOFT_BODY_STRESS

#define R3_DEBUG_SOFT_BODY_STRESS   1024

Debug-render flag: soft body stress.

◆ R3_DEBUG_SOFT_VOLUME_CONTACTS

#define R3_DEBUG_SOFT_VOLUME_CONTACTS   512

Debug-render flag: soft volume contacts.

◆ R3_DEBUG_SOLVER_CONTACTS

#define R3_DEBUG_SOLVER_CONTACTS   16

Debug-render flag: solver contacts.

Typedef Documentation

◆ R3CollisionEvent

typedef struct R3CollisionEvent R3CollisionEvent

Collision start/stop flags match Rapier CollisionEventFlags.

◆ R3CollisionEventCallback

typedef void(*) R3CollisionEventCallback(void *user_data, const struct R3ReadContext *read, const struct R3CollisionEvent *event, const struct R3ContactPoint *contacts, size_t contact_count)

Called during the step for each collision event, after it was added to the collector.

contacts holds the geometric contacts of the pair at that time (none for sensors), in the event's collider order; it is borrowed for this call only.

◆ R3ContactForceEvent

typedef struct R3ContactForceEvent R3ContactForceEvent

Contact-force event, enabled by flags and the collider force threshold.

◆ R3ContactForceEventCallback

typedef void(*) R3ContactForceEventCallback(void *user_data, const struct R3ReadContext *read, const struct R3ContactForceEvent *event)

Called during the step for each contact-force event, after it was added to the collector.

◆ R3ContactManifold

typedef struct R3ContactManifold R3ContactManifold

Geometric contact manifold of a contact pair: contacts sharing one normal.

Local data follow the pair's own collider1/collider2 order (see r3ContactPair).

◆ R3ContactModification

typedef struct R3ContactModification R3ContactModification

Mutable per-manifold properties.

Set enabled=0 to discard all its solver contacts.

◆ R3ContactPair

typedef struct R3ContactPair R3ContactPair

Current narrow-phase pair and accumulated solver impulse summary.

◆ R3ContactPoint

typedef struct R3ContactPoint R3ContactPoint

One manifold contact and its normal solver impulse.

◆ R3DebugLine

typedef struct R3DebugLine R3DebugLine

World-space line segment produced by physics debug rendering.

◆ R3DebugRenderStyle

typedef struct R3DebugRenderStyle R3DebugRenderStyle

Debug-render colors and sizes.

Colors are HSLA: hue in degrees, then saturation, lightness and alpha in [0, 1]; multipliers scale each component. Initialize with r3DefaultDebugRenderStyle.

◆ R3EventCallbacks

typedef struct R3EventCallbacks R3EventCallbacks

Callbacks invoked while stepping, in addition to collecting the events.

They follow the R3PhysicsHooks rules: never unwind or retain arguments, read through the ReadContext, never mutate the world, and be safe for concurrent invocation in parallel builds. NULL callbacks are skipped.

◆ R3EventCollector

Events accumulate across steps until r3EventCollector_Clear: reading them never drains the collector, allowing two-call buffer sizing.

Optional callbacks also see each event during the step.

◆ R3IntersectionPair

typedef struct R3IntersectionPair R3IntersectionPair

Sensor intersection state for a collider pair.

◆ R3OptionalContactPair

typedef struct R3OptionalContactPair R3OptionalContactPair

Optional contact pair; check found before reading the pair.

◆ R3OptionalIntersectionPair

typedef struct R3OptionalIntersectionPair R3OptionalIntersectionPair

Optional intersection pair; check found before reading the pair.

◆ R3SoftBodyTearEvent

Owned copy of a tear event.

Read particle remapping before rebuilding render meshes.

◆ R3SolverContact

typedef struct R3SolverContact R3SolverContact

Contact seen by the constraint solver.

Points are world-space, on each body's surface.

Function Documentation

◆ r3Collider_ContactPairs()

size_t r3Collider_ContactPairs ( struct R3ColliderHandle handle,
struct R3ContactPair * buffer,
size_t capacity )

Copy the narrow-phase contact pairs involving the collider, including pairs without active solver contacts.

The collider may be either collider1 or collider2 of each pair.

See also
Arrays and output buffers

◆ r3Collider_IntersectionPairs()

size_t r3Collider_IntersectionPairs ( struct R3ColliderHandle handle,
struct R3IntersectionPair * buffer,
size_t capacity )

Copy the intersection pairs involving the collider, in the narrow-phase order.

The collider may be either collider1 or collider2 of each pair.

See also
Arrays and output buffers

◆ r3ContactManifolds()

size_t r3ContactManifolds ( struct R3ColliderHandle collider1,
struct R3ColliderHandle collider2,
struct R3ContactManifold * buffer,
size_t capacity )

Copy the geometric contact manifolds of a contact pair, or report R3_NOT_FOUND without a pair.

Their order matches the manifold_index of r3ContactPoints. Soft pairs have no rigid manifolds.

See also
Arrays and output buffers

◆ r3ContactPair()

struct R3ContactPair r3ContactPair ( struct R3ColliderHandle collider1,
struct R3ColliderHandle collider2 )

Return the narrow-phase contact pair for two colliders, or report R3_NOT_FOUND.

Its collider1 and collider2 follow the narrow-phase order, which may differ from the argument order.

◆ r3ContactPairs()

size_t r3ContactPairs ( const struct R3World * world,
struct R3ContactPair * buffer,
size_t capacity )

Copy current narrow-phase contact pairs, including pairs without active solver contacts.

See also
Arrays and output buffers

◆ r3ContactPoints()

size_t r3ContactPoints ( struct R3ColliderHandle collider1,
struct R3ColliderHandle collider2,
struct R3ContactPoint * buffer,
size_t capacity )

Contact points in collider-local space; normal in world space.

Geometric manifolds may be recycled. local_p1/local_p2 follow the pair's own collider1/collider2 order (see r3ContactPair), which may differ from the argument order. For clustered solver impulses use contact pair totals. Soft pairs have no rigid manifolds.

See also
Arrays and output buffers

◆ r3DebugRender()

size_t r3DebugRender ( const struct R3World * world,
uint32_t mode,
struct R3DebugLine * buffer,
size_t capacity )

Copy the debug-render lines of the world with the default style.

mode combines R3_DEBUG_* bits; colors are HSLA (hue in degrees), matching Rapier DebugColor.

See also
Arrays and output buffers

◆ r3DebugRenderWithStyle()

size_t r3DebugRenderWithStyle ( const struct R3World * world,
uint32_t mode,
const struct R3DebugRenderStyle * style,
struct R3DebugLine * buffer,
size_t capacity )

Copy the debug-render lines of the world drawn with the given style.

mode combines R3_DEBUG_* bits. NULL style uses the default style.

See also
Arrays and output buffers

◆ r3DefaultDebugRenderStyle()

struct R3DebugRenderStyle r3DefaultDebugRenderStyle ( void )

Return native default debug-render style.

This POD value owns no resources.

◆ r3EventCollector_Clear()

R3Status r3EventCollector_Clear ( struct R3EventCollector * events)

Discard all collected events.

Does not change the world or the callbacks.

◆ r3EventCollector_CollisionEvents()

size_t r3EventCollector_CollisionEvents ( const struct R3EventCollector * events,
struct R3CollisionEvent * buffer,
size_t capacity )

Copy the collision start/stop events collected since the last clear, without removing them.

See also
Arrays and output buffers

◆ r3EventCollector_ContactForceEvents()

size_t r3EventCollector_ContactForceEvents ( const struct R3EventCollector * events,
struct R3ContactForceEvent * buffer,
size_t capacity )

Copy the contact-force events collected since the last clear, without removing them.

See also
Arrays and output buffers

◆ r3EventCollector_SetCallbacks()

R3Status r3EventCollector_SetCallbacks ( struct R3EventCollector * events,
const struct R3EventCallbacks * callbacks )

Replace the callbacks invoked while stepping with this collector; NULL removes them.

They take effect from the next Step or DetectCollisions call.

◆ r3EventCollector_TearEvent()

struct R3SoftBodyTearEvent * r3EventCollector_TearEvent ( const struct R3EventCollector * events,
size_t index )

Return an owned copy of a queued tear event; release with r3FreeSoftBodyTearEvent.

Does not remove the queued event.

◆ r3EventCollector_TearEventCount()

size_t r3EventCollector_TearEventCount ( const struct R3EventCollector * events)

Return the number of soft-body tear events collected since the last clear.

◆ r3FreeEventCollector()

R3Status r3FreeEventCollector ( struct R3EventCollector * events)

Release an owned event collector.

NULL is allowed. Do not pass borrowed pointers or free the object twice.

◆ r3IntersectionPair()

struct R3IntersectionPair r3IntersectionPair ( struct R3ColliderHandle collider1,
struct R3ColliderHandle collider2 )

Return the intersection state of two colliders involving a sensor, or report R3_NOT_FOUND if the broad phase found no potential intersection.

The result keeps the argument order.

◆ r3IntersectionPairs()

size_t r3IntersectionPairs ( const struct R3World * world,
struct R3IntersectionPair * buffer,
size_t capacity )

Copy current sensor intersection pairs from the narrow phase.

See also
Arrays and output buffers

◆ r3NewEventCollector()

struct R3EventCollector * r3NewEventCollector ( void )

Allocate an empty event collector; release it with r3FreeEventCollector.

◆ r3SolverContacts()

size_t r3SolverContacts ( struct R3ColliderHandle collider1,
struct R3ColliderHandle collider2,
size_t manifold_index,
struct R3SolverContact * buffer,
size_t capacity )

Copy the solver contacts of one manifold of a contact pair, or report R3_NOT_FOUND without a pair.

Points are resolved through the bodies' current poses. With contact clustering (3D composite shapes), the solver may use merged manifolds instead; use contact pair totals then.

See also
Arrays and output buffers

◆ r3TryContactPair()

struct R3OptionalContactPair r3TryContactPair ( struct R3ColliderHandle collider1,
struct R3ColliderHandle collider2 )

Return the narrow-phase contact pair for two colliders, with found = 0 if the broad phase found no potential contact between them (R3_OK).

The pair's collider1 and collider2 follow the narrow-phase order, which may differ from the argument order.

◆ r3TryIntersectionPair()

struct R3OptionalIntersectionPair r3TryIntersectionPair ( struct R3ColliderHandle collider1,
struct R3ColliderHandle collider2 )

Return the intersection state of two colliders involving a sensor, with found = 0 if the broad phase found no potential intersection (R3_OK).

The pair keeps the argument order.