|
JSim 2026.06.01-p(1)
|
Stable C ABI for constructing, configuring, stepping, and querying JSim worlds. More...
#include <stdint.h>Go to the source code of this file.
Functions | |
| void | c_doThing (void) |
| No-op sanity probe for link/load validation. | |
| uint64_t | c_rsCreateWorld (double fixed_dt_s, int enable_gravity) |
| Creates a new physics world and returns its opaque handle. | |
| void | c_rsDestroyWorld (uint64_t world_handle) |
| Destroys a previously created world and releases all associated resources. | |
| int | c_rsCreateBody (uint64_t world_handle, double mass_kg) |
| Creates a new rigid body in a world. | |
| int | c_rsCreateGamepiece (uint64_t world_handle, double radius_m, double mass_kg, double restitution) |
| Creates a new generic gamepiece using sphere hitbox parameters. | |
| int | c_rsCreateGamepieceWithType (uint64_t world_handle, int type, double radius_m, double mass_kg, double restitution) |
| Creates a new generic gamepiece with an explicit type tag. | |
| int | c_rsCreateGamepieceWithTypeName (uint64_t world_handle, const char *type_name, double radius_m, double mass_kg, double restitution) |
| Creates a new generic gamepiece with a human-readable type name. | |
| const char * | c_rsGetGamepieceTypeName (uint64_t world_handle, int gamepiece_index) |
| Reads the registered type name for a gamepiece. | |
| int | c_rsPickGamepiece (uint64_t world_handle, int gamepiece_index, double intake_x, double intake_y, double intake_z, double capture_radius, double carry_offset_x, double carry_offset_y, double carry_offset_z) |
| Request pickup of a gamepiece into a carrier. | |
| int | c_rsPlaceGamepiece (uint64_t world_handle, int gamepiece_index, double x_m, double y_m, double z_m) |
| Place a gamepiece at a world position and mark grounded. | |
| int | c_rsOuttakeGamepiece (uint64_t world_handle, int gamepiece_index, double px, double py, double pz, double vx, double vy, double vz) |
| Outtake a gamepiece from a muzzle pose with velocity (launch). | |
| int | c_rsSetBodyPosition (uint64_t world_handle, int body_index, double x_m, double y_m, double z_m) |
| Sets a body's world-space position. | |
| int | c_rsSetBodyLinearVelocity (uint64_t world_handle, int body_index, double vx_mps, double vy_mps, double vz_mps) |
| Sets a body's world-space linear velocity. | |
| int | c_rsSetBodyOrientation (uint64_t world_handle, int body_index, double qw, double qx, double qy, double qz) |
| Set a rigid body's orientation. | |
| int | c_rsGetBodyOrientation (uint64_t world_handle, int body_index, double *out_qw, double *out_qx, double *out_qy, double *out_qz) |
| Read a rigid body's orientation quaternion. | |
| int | c_rsSetBodyGravityEnabled (uint64_t world_handle, int body_index, int enabled) |
| Enables or disables gravity for a single body. | |
| int | c_rsSetBodyMaterial (uint64_t world_handle, int body_index, double restitution, double friction_kinetic, double friction_static, double collision_damping) |
| Sets per-body material coefficients used in contact response. | |
| int | c_rsSetBodyMaterialId (uint64_t world_handle, int body_index, int32_t material_id) |
| Assigns a numeric material id to a body. | |
| int | c_rsSetBodyCollisionFilter (uint64_t world_handle, int body_index, uint32_t collision_layer_bits, uint32_t collision_mask_bits) |
| Sets broad-phase collision filtering for a body. | |
| int | c_rsSetBodyAerodynamicSphere (uint64_t world_handle, int body_index, double radius_m, double drag_coefficient) |
| Configures spherical aerodynamic metadata for a body. | |
| int | c_rsSetBodyAerodynamicBox (uint64_t world_handle, int body_index, double x_m, double y_m, double z_m, double drag_coefficient) |
| Configures box aerodynamic metadata for a body. | |
| int | c_rsSetGamepiecePosition (uint64_t world_handle, int gamepiece_index, double x_m, double y_m, double z_m) |
| Sets a gamepiece's world-space position. | |
| int | c_rsSetGamepieceLinearVelocity (uint64_t world_handle, int gamepiece_index, double vx_mps, double vy_mps, double vz_mps) |
| Sets a gamepiece's world-space linear velocity. | |
| int | c_rsGetGamepiecePosition (uint64_t world_handle, int gamepiece_index, double *x_m, double *y_m, double *z_m) |
| Reads a gamepiece's world-space position. | |
| int | c_rsGetGamepieceLinearVelocity (uint64_t world_handle, int gamepiece_index, double *vx_mps, double *vy_mps, double *vz_mps) |
| Reads a gamepiece's world-space linear velocity. | |
| int | c_rsSetWorldAerodynamics (uint64_t world_handle, int enabled, double air_density_kgpm3, double linear_drag_coefficient_n_per_mps, double magnus_coefficient, double default_drag_coefficient, double default_drag_reference_area_m2) |
| Configures world-level aerodynamic constants and feature toggle. | |
| int | c_rsSetMaterialInteraction (uint64_t world_handle, int32_t material_a_id, int32_t material_b_id, double restitution, double friction, int enabled) |
| Adds or updates a material-pair interaction override. | |
| int | c_rsStepWorld (uint64_t world_handle, int steps) |
| Advances the world by steps fixed timesteps. | |
| int | c_rsSetWorldGravity (uint64_t world_handle, double gx_mps2, double gy_mps2, double gz_mps2) |
| Sets world gravity acceleration vector. | |
| int | c_rsGetBodyPosition (uint64_t world_handle, int body_index, double *x_m, double *y_m, double *z_m) |
| Reads a body's world-space position. | |
| int | c_rsGetBodyLinearVelocity (uint64_t world_handle, int body_index, double *vx_mps, double *vy_mps, double *vz_mps) |
| Reads a body's world-space linear velocity. | |
| int | c_rsGetBodyPose7Array (uint64_t world_handle, double *out_pose7, int max_bodies) |
| Exports body poses as a tightly packed 7-tuple array. | |
| int | c_rsGetBodyVelocity6Array (uint64_t world_handle, double *out_velocity6, int max_bodies) |
| Exports body velocities as a tightly packed 6-tuple array. | |
| int | c_rsGetBodyState13Array (uint64_t world_handle, double *out_state13, int max_bodies) |
| Exports full body state as a tightly packed 13-tuple array. | |
| int | c_rsCreateAssembly (uint64_t world_handle) |
| Creates and registers a rigid assembly container. | |
Stable C ABI for constructing, configuring, stepping, and querying JSim worlds.
This header is intentionally C-compatible so it can be consumed from JNI, Python/ctypes, C#, Rust FFI, and other foreign-function interfaces without requiring C++ name mangling support.
General conventions:
Error model:
Threading model:
| void c_doThing | ( | void | ) |
No-op sanity probe for link/load validation.
This function exists primarily as a simple symbol to validate library load paths in integration tests and downstream wrappers.
| int c_rsCreateAssembly | ( | uint64_t | world_handle | ) |
Creates and registers a rigid assembly container.
| world_handle | Target world handle. |
| int c_rsCreateBody | ( | uint64_t | world_handle, |
| double | mass_kg ) |
Creates a new rigid body in a world.
| world_handle | Target world handle. |
| mass_kg | Body mass in kilograms. |
| int c_rsCreateGamepiece | ( | uint64_t | world_handle, |
| double | radius_m, | ||
| double | mass_kg, | ||
| double | restitution ) |
Creates a new generic gamepiece using sphere hitbox parameters.
| world_handle | Target world handle. |
| radius_m | Sphere hitbox radius in meters. |
| mass_kg | Gamepiece mass in kilograms. |
| restitution | Coefficient of restitution in [0, 1]. |
| int c_rsCreateGamepieceWithType | ( | uint64_t | world_handle, |
| int | type, | ||
| double | radius_m, | ||
| double | mass_kg, | ||
| double | restitution ) |
Creates a new generic gamepiece with an explicit type tag.
| world_handle | Target world handle. |
| type | Integer type tag (application-defined). For Java usage, map from GamePieceType.ordinal(). |
| radius_m | Sphere hitbox radius in meters (ignored for non-spherical types currently). |
| mass_kg | Gamepiece mass in kilograms. |
| restitution | Coefficient of restitution in [0, 1]. |
| int c_rsCreateGamepieceWithTypeName | ( | uint64_t | world_handle, |
| const char * | type_name, | ||
| double | radius_m, | ||
| double | mass_kg, | ||
| double | restitution ) |
Creates a new generic gamepiece with a human-readable type name.
This API lets callers register/import named gamepiece types (for example "generic_sphere", "generic_cube", "fuel_rebuilt_2026"). The driver will store the provided name for use by higher-level tooling; core physics will continue to use spherical defaults until specific type implementations are available.
| world_handle | Target world handle. |
| type_name | Null-terminated UTF-8 name for the gamepiece type. May be NULL to indicate unnamed/default. |
| radius_m | Sphere hitbox radius in meters (ignored for non-spherical types currently). |
| mass_kg | Gamepiece mass in kilograms. |
| restitution | Coefficient of restitution in [0, 1]. |
| uint64_t c_rsCreateWorld | ( | double | fixed_dt_s, |
| int | enable_gravity ) |
Creates a new physics world and returns its opaque handle.
| fixed_dt_s | Fixed simulation timestep in seconds. Typical FRC values are 0.005-0.02. |
| enable_gravity | Non-zero enables gravity by default; zero disables it. |
| void c_rsDestroyWorld | ( | uint64_t | world_handle | ) |
Destroys a previously created world and releases all associated resources.
| world_handle | Opaque world handle returned by c_rsCreateWorld(). |
Safe behavior:
| int c_rsGetBodyLinearVelocity | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double * | vx_mps, | ||
| double * | vy_mps, | ||
| double * | vz_mps ) |
Reads a body's world-space linear velocity.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| vx_mps | Output pointer for x velocity in meters/second. |
| vy_mps | Output pointer for y velocity in meters/second. |
| vz_mps | Output pointer for z velocity in meters/second. |
| int c_rsGetBodyOrientation | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double * | out_qw, | ||
| double * | out_qx, | ||
| double * | out_qy, | ||
| double * | out_qz ) |
Read a rigid body's orientation quaternion.
| int c_rsGetBodyPose7Array | ( | uint64_t | world_handle, |
| double * | out_pose7, | ||
| int | max_bodies ) |
Exports body poses as a tightly packed 7-tuple array.
| world_handle | Target world handle. |
| out_pose7 | Output buffer of length at least (7 * max_bodies). |
| max_bodies | Maximum number of bodies to write. |
Layout per body i:
| int c_rsGetBodyPosition | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double * | x_m, | ||
| double * | y_m, | ||
| double * | z_m ) |
Reads a body's world-space position.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| x_m | Output pointer for x position in meters. |
| y_m | Output pointer for y position in meters. |
| z_m | Output pointer for z position in meters. |
| int c_rsGetBodyState13Array | ( | uint64_t | world_handle, |
| double * | out_state13, | ||
| int | max_bodies ) |
Exports full body state as a tightly packed 13-tuple array.
| world_handle | Target world handle. |
| out_state13 | Output buffer of length at least (13 * max_bodies). |
| max_bodies | Maximum number of bodies to write. |
Layout per body i:
| int c_rsGetBodyVelocity6Array | ( | uint64_t | world_handle, |
| double * | out_velocity6, | ||
| int | max_bodies ) |
Exports body velocities as a tightly packed 6-tuple array.
| world_handle | Target world handle. |
| out_velocity6 | Output buffer of length at least (6 * max_bodies). |
| max_bodies | Maximum number of bodies to write. |
Layout per body i:
| int c_rsGetGamepieceLinearVelocity | ( | uint64_t | world_handle, |
| int | gamepiece_index, | ||
| double * | vx_mps, | ||
| double * | vy_mps, | ||
| double * | vz_mps ) |
Reads a gamepiece's world-space linear velocity.
| world_handle | Target world handle. |
| gamepiece_index | Zero-based gamepiece index. |
| vx_mps | Output pointer for x velocity in meters/second. |
| vy_mps | Output pointer for y velocity in meters/second. |
| vz_mps | Output pointer for z velocity in meters/second. |
| int c_rsGetGamepiecePosition | ( | uint64_t | world_handle, |
| int | gamepiece_index, | ||
| double * | x_m, | ||
| double * | y_m, | ||
| double * | z_m ) |
Reads a gamepiece's world-space position.
| world_handle | Target world handle. |
| gamepiece_index | Zero-based gamepiece index. |
| x_m | Output pointer for x position in meters. |
| y_m | Output pointer for y position in meters. |
| z_m | Output pointer for z position in meters. |
| const char * c_rsGetGamepieceTypeName | ( | uint64_t | world_handle, |
| int | gamepiece_index ) |
Reads the registered type name for a gamepiece.
| world_handle | Target world handle. |
| gamepiece_index | Zero-based gamepiece index. |
| int c_rsOuttakeGamepiece | ( | uint64_t | world_handle, |
| int | gamepiece_index, | ||
| double | px, | ||
| double | py, | ||
| double | pz, | ||
| double | vx, | ||
| double | vy, | ||
| double | vz ) |
Outtake a gamepiece from a muzzle pose with velocity (launch).
| int c_rsPickGamepiece | ( | uint64_t | world_handle, |
| int | gamepiece_index, | ||
| double | intake_x, | ||
| double | intake_y, | ||
| double | intake_z, | ||
| double | capture_radius, | ||
| double | carry_offset_x, | ||
| double | carry_offset_y, | ||
| double | carry_offset_z ) |
Request pickup of a gamepiece into a carrier.
| world_handle | Target world handle. |
| gamepiece_index | Zero-based gamepiece index returned by c_rsCreateGamepiece(). |
| intake_x | Intake world x position. |
| intake_y | Intake world y position. |
| intake_z | Intake world z position. |
| capture_radius | Capture radius in meters. |
| carry_offset_x | Carry offset x in meters. |
| carry_offset_y | Carry offset y in meters. |
| carry_offset_z | Carry offset z in meters. |
| int c_rsPlaceGamepiece | ( | uint64_t | world_handle, |
| int | gamepiece_index, | ||
| double | x_m, | ||
| double | y_m, | ||
| double | z_m ) |
Place a gamepiece at a world position and mark grounded.
| int c_rsSetBodyAerodynamicBox | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double | x_m, | ||
| double | y_m, | ||
| double | z_m, | ||
| double | drag_coefficient ) |
Configures box aerodynamic metadata for a body.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| x_m | Box size along body-local x in meters. |
| y_m | Box size along body-local y in meters. |
| z_m | Box size along body-local z in meters. |
| drag_coefficient | Dimensionless drag coefficient (Cd). |
| int c_rsSetBodyAerodynamicSphere | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double | radius_m, | ||
| double | drag_coefficient ) |
Configures spherical aerodynamic metadata for a body.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| radius_m | Sphere radius in meters. |
| drag_coefficient | Dimensionless drag coefficient (Cd). |
| int c_rsSetBodyCollisionFilter | ( | uint64_t | world_handle, |
| int | body_index, | ||
| uint32_t | collision_layer_bits, | ||
| uint32_t | collision_mask_bits ) |
Sets broad-phase collision filtering for a body.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| collision_layer_bits | Bitmask describing layers this body belongs to. |
| collision_mask_bits | Bitmask describing layers this body can interact with. |
A pair (A, B) is considered eligible only if both expressions are non-zero:
| int c_rsSetBodyGravityEnabled | ( | uint64_t | world_handle, |
| int | body_index, | ||
| int | enabled ) |
Enables or disables gravity for a single body.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| enabled | Non-zero to enable gravity for this body, zero to disable. |
| int c_rsSetBodyLinearVelocity | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double | vx_mps, | ||
| double | vy_mps, | ||
| double | vz_mps ) |
Sets a body's world-space linear velocity.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| vx_mps | Velocity x component in meters/second. |
| vy_mps | Velocity y component in meters/second. |
| vz_mps | Velocity z component in meters/second. |
| int c_rsSetBodyMaterial | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double | restitution, | ||
| double | friction_kinetic, | ||
| double | friction_static, | ||
| double | collision_damping ) |
Sets per-body material coefficients used in contact response.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| restitution | Coefficient of restitution, generally in [0, 1]. |
| friction_kinetic | Kinetic friction coefficient, typically >= 0. |
| friction_static | Static friction coefficient, typically >= 0. |
| collision_damping | Additional collision damping term, typically >= 0. |
| int c_rsSetBodyMaterialId | ( | uint64_t | world_handle, |
| int | body_index, | ||
| int32_t | material_id ) |
Assigns a numeric material id to a body.
| world_handle | Target world handle. |
| body_index | Zero-based body index. |
| material_id | Application-defined material identifier. |
The material id is used by world-level material interaction tables to override restitution/friction for specific material pairs.
| int c_rsSetBodyOrientation | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double | qw, | ||
| double | qx, | ||
| double | qy, | ||
| double | qz ) |
Set a rigid body's orientation.
| int c_rsSetBodyPosition | ( | uint64_t | world_handle, |
| int | body_index, | ||
| double | x_m, | ||
| double | y_m, | ||
| double | z_m ) |
Sets a body's world-space position.
| world_handle | Target world handle. |
| body_index | Zero-based body index returned by c_rsCreateBody(). |
| x_m | Position x in meters. |
| y_m | Position y in meters. |
| z_m | Position z in meters. |
| int c_rsSetGamepieceLinearVelocity | ( | uint64_t | world_handle, |
| int | gamepiece_index, | ||
| double | vx_mps, | ||
| double | vy_mps, | ||
| double | vz_mps ) |
Sets a gamepiece's world-space linear velocity.
| world_handle | Target world handle. |
| gamepiece_index | Zero-based gamepiece index. |
| vx_mps | Velocity x component in meters/second. |
| vy_mps | Velocity y component in meters/second. |
| vz_mps | Velocity z component in meters/second. |
| int c_rsSetGamepiecePosition | ( | uint64_t | world_handle, |
| int | gamepiece_index, | ||
| double | x_m, | ||
| double | y_m, | ||
| double | z_m ) |
Sets a gamepiece's world-space position.
| world_handle | Target world handle. |
| gamepiece_index | Zero-based gamepiece index. |
| x_m | Position x in meters. |
| y_m | Position y in meters. |
| z_m | Position z in meters. |
| int c_rsSetMaterialInteraction | ( | uint64_t | world_handle, |
| int32_t | material_a_id, | ||
| int32_t | material_b_id, | ||
| double | restitution, | ||
| double | friction, | ||
| int | enabled ) |
Adds or updates a material-pair interaction override.
| world_handle | Target world handle. |
| material_a_id | First material id in the pair. |
| material_b_id | Second material id in the pair. |
| restitution | Pair-specific restitution coefficient. |
| friction | Pair-specific friction coefficient. |
| enabled | Non-zero enables this interaction entry; zero disables it. |
Pair lookup is symmetric: (A, B) and (B, A) resolve to the same entry.
| int c_rsSetWorldAerodynamics | ( | uint64_t | world_handle, |
| int | enabled, | ||
| double | air_density_kgpm3, | ||
| double | linear_drag_coefficient_n_per_mps, | ||
| double | magnus_coefficient, | ||
| double | default_drag_coefficient, | ||
| double | default_drag_reference_area_m2 ) |
Configures world-level aerodynamic constants and feature toggle.
| world_handle | Target world handle. |
| enabled | Non-zero enables aerodynamic forces; zero disables them. |
| air_density_kgpm3 | Air density in kg/m^3. |
| linear_drag_coefficient_n_per_mps | Linear drag coefficient in N/(m/s). |
| magnus_coefficient | Magnus lift scale factor. |
| default_drag_coefficient | Default dimensionless Cd when body value is unset. |
| default_drag_reference_area_m2 | Default area in m^2 when body geometry is unset. |
| int c_rsSetWorldGravity | ( | uint64_t | world_handle, |
| double | gx_mps2, | ||
| double | gy_mps2, | ||
| double | gz_mps2 ) |
Sets world gravity acceleration vector.
| world_handle | Target world handle. |
| gx_mps2 | Gravity x component in m/s^2. |
| gy_mps2 | Gravity y component in m/s^2. |
| gz_mps2 | Gravity z component in m/s^2. |
| int c_rsStepWorld | ( | uint64_t | world_handle, |
| int | steps ) |
Advances the world by steps fixed timesteps.
| world_handle | Target world handle. |
| steps | Number of fixed-dt integration steps; must be >= 0. |