|
Rapier C — 2D / f64 0.36.0+c.0
|
Controllers compute motion/corrections or apply forces; they do not replace Step. More...
Data Structures | |
| struct | R2CharacterLength |
| CharacterLength counterpart: relative=1 scales with character height, relative=0 uses world units. More... | |
| struct | R2CharacterAutostep |
| Copy of the automatic stepping settings. More... | |
| struct | R2CharacterMovement |
| Allowed character motion and ground-contact state. More... | |
| struct | R2CharacterCollision |
| Collision recorded during character movement. More... | |
| struct | R2PidGains |
| Per-axis proportional, integral, and derivative controller gains. More... | |
| struct | R2PdController |
| Stateless proportional-derivative controller: a PID controller without integral term, stored as a plain value. More... | |
| struct | R2VelocityCorrection |
| Linear and angular velocity correction computed by a controller. More... | |
| struct | R2CharacterControllerSettings |
| Copy of character sliding, slope, and snapping settings. More... | |
Macros | |
| #define | R2_AXES_MASK_LIN_X 1 |
| Controller axis bit: translation along X. | |
| #define | R2_AXES_MASK_LIN_Y 2 |
| Controller axis bit: translation along Y. | |
| #define | R2_AXES_MASK_ANG_Z 32 |
| Controller axis bit: rotation about Z (the only rotation axis in 2D). | |
Typedefs | |
| typedef struct R2KinematicCharacterController | R2KinematicCharacterController |
| Controller plus reusable collision output from the last move_shape call. | |
| typedef struct R2PidController | R2PidController |
| PID controller with persistent integral state. | |
| typedef struct R2CharacterLength | R2CharacterLength |
| CharacterLength counterpart: relative=1 scales with character height, relative=0 uses world units. | |
| typedef struct R2CharacterAutostep | R2CharacterAutostep |
| Copy of the automatic stepping settings. | |
| typedef struct R2CharacterMovement | R2CharacterMovement |
| Allowed character motion and ground-contact state. | |
| typedef struct R2CharacterCollision | R2CharacterCollision |
| Collision recorded during character movement. | |
| typedef struct R2PidGains | R2PidGains |
| Per-axis proportional, integral, and derivative controller gains. | |
| typedef struct R2PdController | R2PdController |
| Stateless proportional-derivative controller: a PID controller without integral term, stored as a plain value. | |
| typedef struct R2VelocityCorrection | R2VelocityCorrection |
| Linear and angular velocity correction computed by a controller. | |
| typedef struct R2CharacterControllerSettings | R2CharacterControllerSettings |
| Copy of character sliding, slope, and snapping settings. | |
Functions | |
| struct R2KinematicCharacterController * | r2NewKinematicCharacterController (void) |
| Allocate a character controller with native defaults; release it with r2FreeKinematicCharacterController. | |
| R2Status | r2FreeKinematicCharacterController (struct R2KinematicCharacterController *controller) |
| Release an owned kinematic character controller. | |
| R2Status | r2KinematicCharacterController_SetUp (struct R2KinematicCharacterController *controller, struct R2Vector up) |
| Set the up direction; it must be finite and nonzero and is normalized on input. | |
| R2Status | r2KinematicCharacterController_SetOffset (struct R2KinematicCharacterController *controller, struct R2CharacterLength offset) |
| Set the collision separation margin; use a positive absolute or relative character length. | |
| R2Status | r2KinematicCharacterController_SetSlide (struct R2KinematicCharacterController *controller, R2Bool enabled) |
| Enable or disable sliding along obstacles. | |
| R2Status | r2KinematicCharacterController_SetSlopes (struct R2KinematicCharacterController *controller, R2Real max_climb_angle, R2Real min_slide_angle) |
| Set the maximum climb angle and minimum slide angle, in radians. | |
| R2Status | r2KinematicCharacterController_SetAutostep (struct R2KinematicCharacterController *controller, R2Bool enabled, struct R2CharacterLength max_height, struct R2CharacterLength min_width, R2Bool include_dynamic_bodies) |
| Configure automatic stepping over obstacles. | |
| R2Status | r2KinematicCharacterController_SetSnapToGround (struct R2KinematicCharacterController *controller, R2Bool enabled, struct R2CharacterLength distance) |
| Configure downward ground snapping. | |
| struct R2Vector | r2KinematicCharacterController_Up (const struct R2KinematicCharacterController *controller) |
| Return the normalized up direction. | |
| struct R2CharacterLength | r2KinematicCharacterController_Offset (const struct R2KinematicCharacterController *controller) |
| Return the collision separation margin. | |
| struct R2CharacterAutostep | r2KinematicCharacterController_Autostep (const struct R2KinematicCharacterController *controller) |
| Return the automatic stepping settings. | |
| R2Status | r2KinematicCharacterController_SetNormalNudgeFactor (struct R2KinematicCharacterController *controller, R2Real value) |
| Set the small distance by which sliding motion is pushed along hit normals to avoid getting stuck; it must be finite and nonnegative. | |
| R2Real | r2KinematicCharacterController_NormalNudgeFactor (const struct R2KinematicCharacterController *controller) |
| Return the normal nudge factor set by SetNormalNudgeFactor. | |
| struct R2CharacterMovement | r2KinematicCharacterController_MoveShape (const struct R2World *world, const struct R2QueryOptions *options, struct R2KinematicCharacterController *controller, R2Real dt, const R2SharedShape *shape, struct R2Pose pose, struct R2Vector desired_translation) |
| Computes movement without moving any collider. | |
| size_t | r2KinematicCharacterController_Collisions (const struct R2KinematicCharacterController *controller, struct R2CharacterCollision *buffer, size_t capacity) |
| Copy collisions recorded by the most recent MoveShape call. | |
| R2Status | r2KinematicCharacterController_SolveCharacterCollisionImpulses (const struct R2KinematicCharacterController *controller, const R2SharedShape *shape, R2Real dt, R2Real mass, const struct R2QueryOptions *options) |
| Applies impulses to the dynamic bodies hit by the most recent MoveShape call. | |
| struct R2PidController * | r2NewPidController (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. | |
| R2Status | r2FreePidController (struct R2PidController *controller) |
| Release an owned pid controller. | |
| struct R2PidGains | r2PidController_Gains (const struct R2PidController *controller) |
| Return a copy of the proportional, integral, and derivative gains. | |
| R2Status | r2PidController_SetGains (struct R2PidController *controller, struct R2PidGains gains) |
| Replace the proportional, integral, and derivative gains. | |
| R2Status | r2PidController_SetAxes (struct R2PidController *controller, uint32_t axes) |
| Set the controlled axes, a combination of R2_AXES_MASK_* bits. | |
| uint32_t | r2PidController_Axes (const struct R2PidController *controller) |
| Return the controlled axes as R2_AXES_MASK_* bits. | |
| R2Status | r2PidController_ResetIntegrals (struct R2PidController *controller) |
| Reset to zero the linear and angular errors accumulated by the integral term. | |
| struct R2PdController | r2DefaultPdController (void) |
| Return Rapier's default PD controller: kp = 60 and kd = 0.8 on every axis, all axes controlled. | |
| struct R2VelocityCorrection | r2PdController_RigidBodyCorrection (const struct R2PdController *controller, struct R2RigidBodyHandle body, struct R2Pose target_pose, struct R2Vector target_linvel, R2AngVector target_angvel) |
| Compute the velocity change bringing the body toward the target pose and velocities. | |
| struct R2VelocityCorrection | r2PidController_RigidBodyCorrection (struct R2PidController *controller, R2Real dt, struct R2RigidBodyHandle body, struct R2Pose target_pose, struct R2Vector target_linvel, R2AngVector target_angvel) |
| Compute a velocity correction, preserving the body's state and updating PID integrals. | |
| struct R2CharacterControllerSettings | r2KinematicCharacterController_Settings (const struct R2KinematicCharacterController *controller) |
| Return a copy of slide, slope, and ground-snap settings. | |
Controllers compute motion/corrections or apply forces; they do not replace Step.
Keep referenced worlds and bodies alive for controller operations.
| #define R2_AXES_MASK_ANG_Z 32 |
Controller axis bit: rotation about Z (the only rotation axis in 2D).
| #define R2_AXES_MASK_LIN_X 1 |
Controller axis bit: translation along X.
| #define R2_AXES_MASK_LIN_Y 2 |
Controller axis bit: translation along Y.
| typedef struct R2CharacterAutostep R2CharacterAutostep |
Copy of the automatic stepping settings.
| typedef struct R2CharacterCollision R2CharacterCollision |
Collision recorded during character movement.
| typedef struct R2CharacterControllerSettings R2CharacterControllerSettings |
Copy of character sliding, slope, and snapping settings.
| typedef struct R2CharacterLength R2CharacterLength |
CharacterLength counterpart: relative=1 scales with character height, relative=0 uses world units.
| typedef struct R2CharacterMovement R2CharacterMovement |
Allowed character motion and ground-contact state.
| typedef struct R2KinematicCharacterController R2KinematicCharacterController |
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 R2PdController R2PdController |
Stateless proportional-derivative controller: a PID controller without integral term, stored as a plain value.
Initialize with r2DefaultPdController.
| typedef struct R2PidController R2PidController |
PID controller with persistent integral state.
Stateful proportional-integral-derivative controller. Release with the matching Free function.
| typedef struct R2PidGains R2PidGains |
Per-axis proportional, integral, and derivative controller gains.
| typedef struct R2VelocityCorrection R2VelocityCorrection |
Linear and angular velocity correction computed by a controller.
| struct R2PdController r2DefaultPdController | ( | 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.
| R2Status r2FreeKinematicCharacterController | ( | struct R2KinematicCharacterController * | controller | ) |
Release an owned kinematic character controller.
NULL is allowed. Do not pass borrowed pointers or free the object twice.
| R2Status r2FreePidController | ( | struct R2PidController * | controller | ) |
Release an owned pid controller.
NULL is allowed. Do not pass borrowed pointers or free the object twice.
| struct R2CharacterAutostep r2KinematicCharacterController_Autostep | ( | const struct R2KinematicCharacterController * | controller | ) |
Return the automatic stepping settings.
When disabled, enabled is 0 and the other fields hold Rapier's defaults.
| size_t r2KinematicCharacterController_Collisions | ( | const struct R2KinematicCharacterController * | controller, |
| struct R2CharacterCollision * | buffer, | ||
| size_t | capacity ) |
Copy collisions recorded by the most recent MoveShape call.
| struct R2CharacterMovement r2KinematicCharacterController_MoveShape | ( | const struct R2World * | world, |
| const struct R2QueryOptions * | options, | ||
| struct R2KinematicCharacterController * | controller, | ||
| R2Real | dt, | ||
| const R2SharedShape * | shape, | ||
| struct R2Pose | pose, | ||
| struct R2Vector | 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.
| R2Real r2KinematicCharacterController_NormalNudgeFactor | ( | const struct R2KinematicCharacterController * | controller | ) |
Return the normal nudge factor set by SetNormalNudgeFactor.
| struct R2CharacterLength r2KinematicCharacterController_Offset | ( | const struct R2KinematicCharacterController * | controller | ) |
Return the collision separation margin.
| R2Status r2KinematicCharacterController_SetAutostep | ( | struct R2KinematicCharacterController * | controller, |
| R2Bool | enabled, | ||
| struct R2CharacterLength | max_height, | ||
| struct R2CharacterLength | min_width, | ||
| R2Bool | include_dynamic_bodies ) |
Configure automatic stepping over obstacles.
enabled = 0 disables it.
| R2Status r2KinematicCharacterController_SetNormalNudgeFactor | ( | struct R2KinematicCharacterController * | controller, |
| R2Real | 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.
| R2Status r2KinematicCharacterController_SetOffset | ( | struct R2KinematicCharacterController * | controller, |
| struct R2CharacterLength | offset ) |
Set the collision separation margin; use a positive absolute or relative character length.
| R2Status r2KinematicCharacterController_SetSlide | ( | struct R2KinematicCharacterController * | controller, |
| R2Bool | enabled ) |
Enable or disable sliding along obstacles.
| R2Status r2KinematicCharacterController_SetSlopes | ( | struct R2KinematicCharacterController * | controller, |
| R2Real | max_climb_angle, | ||
| R2Real | min_slide_angle ) |
Set the maximum climb angle and minimum slide angle, in radians.
| R2Status r2KinematicCharacterController_SetSnapToGround | ( | struct R2KinematicCharacterController * | controller, |
| R2Bool | enabled, | ||
| struct R2CharacterLength | distance ) |
Configure downward ground snapping.
enabled = 0 disables it.
| struct R2CharacterControllerSettings r2KinematicCharacterController_Settings | ( | const struct R2KinematicCharacterController * | controller | ) |
Return a copy of slide, slope, and ground-snap settings.
| R2Status r2KinematicCharacterController_SetUp | ( | struct R2KinematicCharacterController * | controller, |
| struct R2Vector | up ) |
Set the up direction; it must be finite and nonzero and is normalized on input.
| R2Status r2KinematicCharacterController_SolveCharacterCollisionImpulses | ( | const struct R2KinematicCharacterController * | controller, |
| const R2SharedShape * | shape, | ||
| R2Real | dt, | ||
| R2Real | mass, | ||
| const struct R2QueryOptions * | 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 R2Vector r2KinematicCharacterController_Up | ( | const struct R2KinematicCharacterController * | controller | ) |
Return the normalized up direction.
| struct R2KinematicCharacterController * r2NewKinematicCharacterController | ( | void | ) |
Allocate a character controller with native defaults; release it with r2FreeKinematicCharacterController.
| struct R2PidController * r2NewPidController | ( | 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 r2FreePidController.
| struct R2VelocityCorrection r2PdController_RigidBodyCorrection | ( | const struct R2PdController * | controller, |
| struct R2RigidBodyHandle | body, | ||
| struct R2Pose | target_pose, | ||
| struct R2Vector | target_linvel, | ||
| R2AngVector | 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 r2PidController_Axes | ( | const struct R2PidController * | controller | ) |
Return the controlled axes as R2_AXES_MASK_* bits.
| struct R2PidGains r2PidController_Gains | ( | const struct R2PidController * | controller | ) |
Return a copy of the proportional, integral, and derivative gains.
| R2Status r2PidController_ResetIntegrals | ( | struct R2PidController * | controller | ) |
Reset to zero the linear and angular errors accumulated by the integral term.
| struct R2VelocityCorrection r2PidController_RigidBodyCorrection | ( | struct R2PidController * | controller, |
| R2Real | dt, | ||
| struct R2RigidBodyHandle | body, | ||
| struct R2Pose | target_pose, | ||
| struct R2Vector | target_linvel, | ||
| R2AngVector | target_angvel ) |
Compute a velocity correction, preserving the body's state and updating PID integrals.
| R2Status r2PidController_SetAxes | ( | struct R2PidController * | controller, |
| uint32_t | axes ) |
Set the controlled axes, a combination of R2_AXES_MASK_* bits.
Gains are unchanged; unknown bits are rejected.
| R2Status r2PidController_SetGains | ( | struct R2PidController * | controller, |
| struct R2PidGains | gains ) |
Replace the proportional, integral, and derivative gains.