|
Rapier C — 3D / f32 0.36.0+c.0
|
Controllers compute motion/corrections or apply forces; they do not replace Step. More...
Data Structures | |
| struct | R3CharacterLength |
| CharacterLength counterpart: relative=1 scales with character height, relative=0 uses world units. More... | |
| struct | R3CharacterAutostep |
| Copy of the automatic stepping settings. More... | |
| struct | R3CharacterMovement |
| Allowed character motion and ground-contact state. More... | |
| struct | R3CharacterCollision |
| Collision recorded during character movement. More... | |
| struct | R3PidGains |
| Per-axis proportional, integral, and derivative controller gains. More... | |
| struct | R3PdController |
| Stateless proportional-derivative controller: a PID controller without integral term, stored as a plain value. More... | |
| struct | R3VelocityCorrection |
| Linear and angular velocity correction computed by a controller. More... | |
| struct | R3CharacterControllerSettings |
| Copy of character sliding, slope, and snapping settings. More... | |
| struct | R3WheelTuning |
| Wheel suspension/friction parameters. More... | |
| struct | R3WheelState |
| Copy of the current wheel pose, suspension, and contact state. More... | |
Macros | |
| #define | R3_AXES_MASK_LIN_X 1 |
| Controller axis bit: translation along X. | |
| #define | R3_AXES_MASK_LIN_Y 2 |
| Controller axis bit: translation along Y. | |
| #define | R3_AXES_MASK_LIN_Z 4 |
| Controller axis bit: translation along Z. | |
| #define | R3_AXES_MASK_ANG_X 8 |
| Controller axis bit: rotation about X. | |
| #define | R3_AXES_MASK_ANG_Y 16 |
| Controller axis bit: rotation about Y. | |
| #define | R3_AXES_MASK_ANG_Z 32 |
| Controller axis bit: rotation about Z (the only rotation axis in 2D). | |
Typedefs | |
| typedef struct R3DynamicRayCastVehicleController | R3DynamicRayCastVehicleController |
| Vehicle controller borrowing its chassis world. | |
| typedef struct R3KinematicCharacterController | R3KinematicCharacterController |
| Controller plus reusable collision output from the last move_shape call. | |
| typedef struct R3PidController | R3PidController |
| PID controller with persistent integral state. | |
| typedef struct R3CharacterLength | R3CharacterLength |
| CharacterLength counterpart: relative=1 scales with character height, relative=0 uses world units. | |
| typedef struct R3CharacterAutostep | R3CharacterAutostep |
| Copy of the automatic stepping settings. | |
| typedef struct R3CharacterMovement | R3CharacterMovement |
| Allowed character motion and ground-contact state. | |
| typedef struct R3CharacterCollision | R3CharacterCollision |
| Collision recorded during character movement. | |
| typedef struct R3PidGains | R3PidGains |
| Per-axis proportional, integral, and derivative controller gains. | |
| typedef struct R3PdController | R3PdController |
| Stateless proportional-derivative controller: a PID controller without integral term, stored as a plain value. | |
| typedef struct R3VelocityCorrection | R3VelocityCorrection |
| Linear and angular velocity correction computed by a controller. | |
| typedef struct R3CharacterControllerSettings | R3CharacterControllerSettings |
| Copy of character sliding, slope, and snapping settings. | |
| typedef struct R3WheelTuning | R3WheelTuning |
| Wheel suspension/friction parameters. | |
| typedef struct R3WheelState | R3WheelState |
| Copy of the current wheel pose, suspension, and contact state. | |
Functions | |
| struct R3KinematicCharacterController * | r3NewKinematicCharacterController (void) |
| Allocate a character controller with native defaults; release it with r3FreeKinematicCharacterController. | |
| R3Status | r3FreeKinematicCharacterController (struct R3KinematicCharacterController *controller) |
| Release an owned kinematic character controller. | |
| R3Status | r3KinematicCharacterController_SetUp (struct R3KinematicCharacterController *controller, struct R3Vector up) |
| Set the up direction; it must be finite and nonzero and is normalized on input. | |
| R3Status | r3KinematicCharacterController_SetOffset (struct R3KinematicCharacterController *controller, struct R3CharacterLength offset) |
| Set the collision separation margin; use a positive absolute or relative character length. | |
| R3Status | r3KinematicCharacterController_SetSlide (struct R3KinematicCharacterController *controller, R3Bool enabled) |
| Enable or disable sliding along obstacles. | |
| R3Status | r3KinematicCharacterController_SetSlopes (struct R3KinematicCharacterController *controller, R3Real max_climb_angle, R3Real min_slide_angle) |
| Set the maximum climb angle and minimum slide angle, in radians. | |
| R3Status | r3KinematicCharacterController_SetAutostep (struct R3KinematicCharacterController *controller, R3Bool enabled, struct R3CharacterLength max_height, struct R3CharacterLength min_width, R3Bool include_dynamic_bodies) |
| Configure automatic stepping over obstacles. | |
| R3Status | r3KinematicCharacterController_SetSnapToGround (struct R3KinematicCharacterController *controller, R3Bool enabled, struct R3CharacterLength distance) |
| Configure downward ground snapping. | |
| struct R3Vector | r3KinematicCharacterController_Up (const struct R3KinematicCharacterController *controller) |
| Return the normalized up direction. | |
| struct R3CharacterLength | r3KinematicCharacterController_Offset (const struct R3KinematicCharacterController *controller) |
| Return the collision separation margin. | |
| struct R3CharacterAutostep | r3KinematicCharacterController_Autostep (const struct R3KinematicCharacterController *controller) |
| Return the automatic stepping settings. | |
| R3Status | r3KinematicCharacterController_SetNormalNudgeFactor (struct R3KinematicCharacterController *controller, R3Real value) |
| Set the small distance by which sliding motion is pushed along hit normals to avoid getting stuck; it must be finite and nonnegative. | |
| R3Real | r3KinematicCharacterController_NormalNudgeFactor (const struct R3KinematicCharacterController *controller) |
| Return the normal nudge factor set by SetNormalNudgeFactor. | |
| struct R3CharacterMovement | r3KinematicCharacterController_MoveShape (const struct R3World *world, const struct R3QueryOptions *options, struct R3KinematicCharacterController *controller, R3Real dt, const R3SharedShape *shape, struct R3Pose pose, struct R3Vector desired_translation) |
| Computes movement without moving any collider. | |
| size_t | r3KinematicCharacterController_Collisions (const struct R3KinematicCharacterController *controller, struct R3CharacterCollision *buffer, size_t capacity) |
| Copy collisions recorded by the most recent MoveShape call. | |
| R3Status | r3KinematicCharacterController_SolveCharacterCollisionImpulses (const struct R3KinematicCharacterController *controller, const R3SharedShape *shape, R3Real dt, R3Real mass, const struct R3QueryOptions *options) |
| Applies impulses to the dynamic bodies hit by the most recent MoveShape call. | |
| struct R3PidController * | r3NewPidController (void) |
| Allocate a PID controller with Rapier's defaults: kp = 60, ki = 1 and kd = 0.8 on every axis, all axes controlled, and zero integrals. | |
| R3Status | r3FreePidController (struct R3PidController *controller) |
| Release an owned pid controller. | |
| struct R3PidGains | r3PidController_Gains (const struct R3PidController *controller) |
| Return a copy of the proportional, integral, and derivative gains. | |
| R3Status | r3PidController_SetGains (struct R3PidController *controller, struct R3PidGains gains) |
| Replace the proportional, integral, and derivative gains. | |
| R3Status | r3PidController_SetAxes (struct R3PidController *controller, uint32_t axes) |
| Set the controlled axes, a combination of R3_AXES_MASK_* bits. | |
| uint32_t | r3PidController_Axes (const struct R3PidController *controller) |
| Return the controlled axes as R3_AXES_MASK_* bits. | |
| R3Status | r3PidController_ResetIntegrals (struct R3PidController *controller) |
| Reset to zero the linear and angular errors accumulated by the integral term. | |
| struct R3PdController | r3DefaultPdController (void) |
| Return Rapier's default PD controller: kp = 60 and kd = 0.8 on every axis, all axes controlled. | |
| struct R3VelocityCorrection | r3PdController_RigidBodyCorrection (const struct R3PdController *controller, struct R3RigidBodyHandle body, struct R3Pose target_pose, struct R3Vector target_linvel, R3AngVector target_angvel) |
| Compute the velocity change bringing the body toward the target pose and velocities. | |
| struct R3VelocityCorrection | r3PidController_RigidBodyCorrection (struct R3PidController *controller, R3Real dt, struct R3RigidBodyHandle body, struct R3Pose target_pose, struct R3Vector target_linvel, R3AngVector target_angvel) |
| Compute a velocity correction, preserving the body's state and updating PID integrals. | |
| struct R3CharacterControllerSettings | r3KinematicCharacterController_Settings (const struct R3KinematicCharacterController *controller) |
| Return a copy of slide, slope, and ground-snap settings. | |
| struct R3WheelTuning | r3DefaultWheelTuning (void) |
| Return native default wheel tuning. | |
| struct R3DynamicRayCastVehicleController * | r3NewDynamicRayCastVehicleController (struct R3RigidBodyHandle chassis) |
| Allocate a vehicle controller bound to its chassis body. | |
| R3Status | r3FreeDynamicRayCastVehicleController (struct R3DynamicRayCastVehicleController *controller) |
| Release an owned dynamic ray cast vehicle controller. | |
| size_t | r3DynamicRayCastVehicleController_AddWheel (struct R3DynamicRayCastVehicleController *controller, struct R3Vector connection, struct R3Vector direction, struct R3Vector axle, R3Real rest_length, R3Real radius, const struct R3WheelTuning *tuning) |
| Append a wheel and return its zero-based index. | |
| R3Status | r3DynamicRayCastVehicleController_SetAxes (struct R3DynamicRayCastVehicleController *controller, size_t up, size_t forward) |
| Set the chassis up/forward axis indices (0 = X, 1 = Y, 2 = Z). | |
| R3Status | r3DynamicRayCastVehicleController_SetWheelControls (struct R3DynamicRayCastVehicleController *controller, size_t index, R3Real steering, R3Real engine_force, R3Real brake) |
| Set a wheel engine force, brake force, and steering angle in radians. | |
| R3Status | r3DynamicRayCastVehicleController_UpdateVehicle (struct R3DynamicRayCastVehicleController *controller, R3Real dt, const struct R3QueryOptions *options) |
| Ray-cast wheel contacts and apply vehicle forces for dt seconds. | |
| R3Real | r3DynamicRayCastVehicleController_CurrentVehicleSpeed (const struct R3DynamicRayCastVehicleController *controller) |
| Return signed chassis speed along its forward direction. | |
| size_t | r3DynamicRayCastVehicleController_Wheels (const struct R3DynamicRayCastVehicleController *controller, struct R3WheelState *buffer, size_t capacity) |
| Copy current wheel state in wheel insertion order. | |
Controllers compute motion/corrections or apply forces; they do not replace Step.
Keep referenced worlds and bodies alive for controller operations.
| #define R3_AXES_MASK_ANG_X 8 |
Controller axis bit: rotation about X.
| #define R3_AXES_MASK_ANG_Y 16 |
Controller axis bit: rotation about Y.
| #define R3_AXES_MASK_ANG_Z 32 |
Controller axis bit: rotation about Z (the only rotation axis in 2D).
| #define R3_AXES_MASK_LIN_X 1 |
Controller axis bit: translation along X.
| #define R3_AXES_MASK_LIN_Y 2 |
Controller axis bit: translation along Y.
| #define R3_AXES_MASK_LIN_Z 4 |
Controller axis bit: translation along Z.
| typedef struct R3CharacterAutostep R3CharacterAutostep |
Copy of the automatic stepping settings.
| typedef struct R3CharacterCollision R3CharacterCollision |
Collision recorded during character movement.
| typedef struct R3CharacterControllerSettings R3CharacterControllerSettings |
Copy of character sliding, slope, and snapping settings.
| typedef struct R3CharacterLength R3CharacterLength |
CharacterLength counterpart: relative=1 scales with character height, relative=0 uses world units.
| typedef struct R3CharacterMovement R3CharacterMovement |
Allowed character motion and ground-contact state.
Vehicle controller borrowing its chassis world.
Release with the matching Free function.
| typedef struct R3KinematicCharacterController R3KinematicCharacterController |
Controller plus reusable collision output from the last move_shape call.
Kinematic character controller and its last collision list. Release with the matching Free function.
| typedef struct R3PdController R3PdController |
Stateless proportional-derivative controller: a PID controller without integral term, stored as a plain value.
Initialize with r3DefaultPdController.
| typedef struct R3PidController R3PidController |
PID controller with persistent integral state.
Stateful proportional-integral-derivative controller. Release with the matching Free function.
| typedef struct R3PidGains R3PidGains |
Per-axis proportional, integral, and derivative controller gains.
| typedef struct R3VelocityCorrection R3VelocityCorrection |
Linear and angular velocity correction computed by a controller.
| typedef struct R3WheelState R3WheelState |
Copy of the current wheel pose, suspension, and contact state.
| typedef struct R3WheelTuning R3WheelTuning |
Wheel suspension/friction parameters.
Initialize with r3DefaultWheelTuning.
| struct R3PdController r3DefaultPdController | ( | void | ) |
Return Rapier's default PD controller: kp = 60 and kd = 0.8 on every axis, all axes controlled.
This POD value owns no resources.
| struct R3WheelTuning r3DefaultWheelTuning | ( | void | ) |
Return native default wheel tuning.
This POD value owns no resources.
| size_t r3DynamicRayCastVehicleController_AddWheel | ( | struct R3DynamicRayCastVehicleController * | controller, |
| struct R3Vector | connection, | ||
| struct R3Vector | direction, | ||
| struct R3Vector | axle, | ||
| R3Real | rest_length, | ||
| R3Real | radius, | ||
| const struct R3WheelTuning * | tuning ) |
Append a wheel and return its zero-based index.
Connection, suspension direction, and axle are in chassis-local coordinates.
| R3Real r3DynamicRayCastVehicleController_CurrentVehicleSpeed | ( | const struct R3DynamicRayCastVehicleController * | controller | ) |
Return signed chassis speed along its forward direction.
| R3Status r3DynamicRayCastVehicleController_SetAxes | ( | struct R3DynamicRayCastVehicleController * | controller, |
| size_t | up, | ||
| size_t | forward ) |
Set the chassis up/forward axis indices (0 = X, 1 = Y, 2 = Z).
| R3Status r3DynamicRayCastVehicleController_SetWheelControls | ( | struct R3DynamicRayCastVehicleController * | controller, |
| size_t | index, | ||
| R3Real | steering, | ||
| R3Real | engine_force, | ||
| R3Real | brake ) |
Set a wheel engine force, brake force, and steering angle in radians.
| R3Status r3DynamicRayCastVehicleController_UpdateVehicle | ( | struct R3DynamicRayCastVehicleController * | controller, |
| R3Real | dt, | ||
| const struct R3QueryOptions * | options ) |
Ray-cast wheel contacts and apply vehicle forces for dt seconds.
Does not step the world. NULL options use the default filter. The chassis colliders are always excluded, in addition to the filter's own exclusions. The options' predicate is called once per collider of the world before the update, while the world is locked for writing: it may only use Read* functions.
| size_t r3DynamicRayCastVehicleController_Wheels | ( | const struct R3DynamicRayCastVehicleController * | controller, |
| struct R3WheelState * | buffer, | ||
| size_t | capacity ) |
Copy current wheel state in wheel insertion order.
| R3Status r3FreeDynamicRayCastVehicleController | ( | struct R3DynamicRayCastVehicleController * | controller | ) |
Release an owned dynamic ray cast vehicle controller.
NULL is allowed. Do not pass borrowed pointers or free the object twice.
| R3Status r3FreeKinematicCharacterController | ( | struct R3KinematicCharacterController * | controller | ) |
Release an owned kinematic character controller.
NULL is allowed. Do not pass borrowed pointers or free the object twice.
| R3Status r3FreePidController | ( | struct R3PidController * | controller | ) |
Release an owned pid controller.
NULL is allowed. Do not pass borrowed pointers or free the object twice.
| struct R3CharacterAutostep r3KinematicCharacterController_Autostep | ( | const struct R3KinematicCharacterController * | controller | ) |
Return the automatic stepping settings.
When disabled, enabled is 0 and the other fields hold Rapier's defaults.
| size_t r3KinematicCharacterController_Collisions | ( | const struct R3KinematicCharacterController * | controller, |
| struct R3CharacterCollision * | buffer, | ||
| size_t | capacity ) |
Copy collisions recorded by the most recent MoveShape call.
| struct R3CharacterMovement r3KinematicCharacterController_MoveShape | ( | const struct R3World * | world, |
| const struct R3QueryOptions * | options, | ||
| struct R3KinematicCharacterController * | controller, | ||
| R3Real | dt, | ||
| const R3SharedShape * | shape, | ||
| struct R3Pose | pose, | ||
| struct R3Vector | desired_translation ) |
Computes movement without moving any collider.
Use the returned translation to set the character target. NULL query options use the default filter. Query state reflects the latest Step or DetectCollisions call.
| R3Real r3KinematicCharacterController_NormalNudgeFactor | ( | const struct R3KinematicCharacterController * | controller | ) |
Return the normal nudge factor set by SetNormalNudgeFactor.
| struct R3CharacterLength r3KinematicCharacterController_Offset | ( | const struct R3KinematicCharacterController * | controller | ) |
Return the collision separation margin.
| R3Status r3KinematicCharacterController_SetAutostep | ( | struct R3KinematicCharacterController * | controller, |
| R3Bool | enabled, | ||
| struct R3CharacterLength | max_height, | ||
| struct R3CharacterLength | min_width, | ||
| R3Bool | include_dynamic_bodies ) |
Configure automatic stepping over obstacles.
enabled = 0 disables it.
| R3Status r3KinematicCharacterController_SetNormalNudgeFactor | ( | struct R3KinematicCharacterController * | controller, |
| R3Real | value ) |
Set the small distance by which sliding motion is pushed along hit normals to avoid getting stuck; it must be finite and nonnegative.
Large values cause bumps when sliding on flat ground.
| R3Status r3KinematicCharacterController_SetOffset | ( | struct R3KinematicCharacterController * | controller, |
| struct R3CharacterLength | offset ) |
Set the collision separation margin; use a positive absolute or relative character length.
| R3Status r3KinematicCharacterController_SetSlide | ( | struct R3KinematicCharacterController * | controller, |
| R3Bool | enabled ) |
Enable or disable sliding along obstacles.
| R3Status r3KinematicCharacterController_SetSlopes | ( | struct R3KinematicCharacterController * | controller, |
| R3Real | max_climb_angle, | ||
| R3Real | min_slide_angle ) |
Set the maximum climb angle and minimum slide angle, in radians.
| R3Status r3KinematicCharacterController_SetSnapToGround | ( | struct R3KinematicCharacterController * | controller, |
| R3Bool | enabled, | ||
| struct R3CharacterLength | distance ) |
Configure downward ground snapping.
enabled = 0 disables it.
| struct R3CharacterControllerSettings r3KinematicCharacterController_Settings | ( | const struct R3KinematicCharacterController * | controller | ) |
Return a copy of slide, slope, and ground-snap settings.
| R3Status r3KinematicCharacterController_SetUp | ( | struct R3KinematicCharacterController * | controller, |
| struct R3Vector | up ) |
Set the up direction; it must be finite and nonzero and is normalized on input.
| R3Status r3KinematicCharacterController_SolveCharacterCollisionImpulses | ( | const struct R3KinematicCharacterController * | controller, |
| const R3SharedShape * | shape, | ||
| R3Real | dt, | ||
| R3Real | mass, | ||
| const struct R3QueryOptions * | options ) |
Applies impulses to the dynamic bodies hit by the most recent MoveShape call.
Use the same shape, dt and query options as that call; NULL options use the default filter. Unlike MoveShape, the options' predicate is called once per collider of the world before the impulses are applied, while the world is locked for writing: it may only use Read* functions.
| struct R3Vector r3KinematicCharacterController_Up | ( | const struct R3KinematicCharacterController * | controller | ) |
Return the normalized up direction.
| struct R3DynamicRayCastVehicleController * r3NewDynamicRayCastVehicleController | ( | struct R3RigidBodyHandle | chassis | ) |
Allocate a vehicle controller bound to its chassis body.
The chassis world must outlive the controller. Release with r3FreeDynamicRayCastVehicleController.
| struct R3KinematicCharacterController * r3NewKinematicCharacterController | ( | void | ) |
Allocate a character controller with native defaults; release it with r3FreeKinematicCharacterController.
| struct R3PidController * r3NewPidController | ( | void | ) |
Allocate a PID controller with Rapier's defaults: kp = 60, ki = 1 and kd = 0.8 on every axis, all axes controlled, and zero integrals.
Release with r3FreePidController.
| struct R3VelocityCorrection r3PdController_RigidBodyCorrection | ( | const struct R3PdController * | controller, |
| struct R3RigidBodyHandle | body, | ||
| struct R3Pose | target_pose, | ||
| struct R3Vector | target_linvel, | ||
| R3AngVector | target_angvel ) |
Compute the velocity change bringing the body toward the target pose and velocities.
Neither the body nor the controller is modified.
| uint32_t r3PidController_Axes | ( | const struct R3PidController * | controller | ) |
Return the controlled axes as R3_AXES_MASK_* bits.
| struct R3PidGains r3PidController_Gains | ( | const struct R3PidController * | controller | ) |
Return a copy of the proportional, integral, and derivative gains.
| R3Status r3PidController_ResetIntegrals | ( | struct R3PidController * | controller | ) |
Reset to zero the linear and angular errors accumulated by the integral term.
| struct R3VelocityCorrection r3PidController_RigidBodyCorrection | ( | struct R3PidController * | controller, |
| R3Real | dt, | ||
| struct R3RigidBodyHandle | body, | ||
| struct R3Pose | target_pose, | ||
| struct R3Vector | target_linvel, | ||
| R3AngVector | target_angvel ) |
Compute a velocity correction, preserving the body's state and updating PID integrals.
| R3Status r3PidController_SetAxes | ( | struct R3PidController * | controller, |
| uint32_t | axes ) |
Set the controlled axes, a combination of R3_AXES_MASK_* bits.
Gains are unchanged; unknown bits are rejected.
| R3Status r3PidController_SetGains | ( | struct R3PidController * | controller, |
| struct R3PidGains | gains ) |
Replace the proportional, integral, and derivative gains.