Skip to main content

Module recording

Module recording 

Source

Structs§

RecHeader
File header, fixed 32 bytes, little-endian. (b2RecHeader)
RecPlayer
Incremental player. Owns a private copy of the recording bytes and drives replay one step at a time. (b2RecPlayer)
RecPlayerInfo
Static metadata describing a recording, resolved once when the player opens the file. (b2RecPlayerInfo)
RecQueryHit
One result of a recorded spatial query. (b2RecQueryHit)
RecQueryInfo
A spatial query recorded during a replayed frame, exposed for inspection. (b2RecQueryInfo)
Recording
User-owned recording buffer. The world appends into it while recording; the user saves and destroys it. (b2Recording — the mutex is dropped in the serial port)
ReplayResult
Result of a replay pass. (b2RecPlayer diagnostics, condensed)
SnapHeader
Snapshot image header. (b2SnapHeader)
SnapReader
Bounds-checked little-endian reader over a snapshot image. A short or corrupt image trips ok instead of panicking, mirroring the C b2SnapReader contract. (b2SnapReader)

Enums§

RecQueryType
The kind of a recorded spatial query, matching the public query and cast functions. (b2RecQueryType / b2RecQueryKind — the C internal and public enums are value-identical, so the Rust port keeps one.)

Constants§

OP_BODY_APPLY_ANGULAR_IMPULSE
OP_BODY_APPLY_FORCE
OP_BODY_APPLY_FORCE_TO_CENTER
OP_BODY_APPLY_LINEAR_IMPULSE
OP_BODY_APPLY_LINEAR_IMPULSE_TO_CENTER
OP_BODY_APPLY_MASS_FROM_SHAPES
OP_BODY_APPLY_TORQUE
OP_BODY_CLEAR_FORCES
OP_BODY_DISABLE
OP_BODY_ENABLE
OP_BODY_ENABLE_CONTACT_EVENTS
OP_BODY_ENABLE_CONTACT_RECYCLING
OP_BODY_ENABLE_HIT_EVENTS
OP_BODY_ENABLE_SLEEP
OP_BODY_SET_ANGULAR_DAMPING
OP_BODY_SET_ANGULAR_VELOCITY
OP_BODY_SET_AWAKE
OP_BODY_SET_BULLET
OP_BODY_SET_GRAVITY_SCALE
OP_BODY_SET_LINEAR_DAMPING
OP_BODY_SET_LINEAR_VELOCITY
OP_BODY_SET_MASS_DATA
OP_BODY_SET_MOTION_LOCKS
OP_BODY_SET_NAME
OP_BODY_SET_SLEEP_THRESHOLD
OP_BODY_SET_TARGET_TRANSFORM
OP_BODY_SET_TRANSFORM
OP_BODY_SET_TYPE
OP_BODY_WAKE_TOUCHING
OP_CHAIN_SET_SURFACE_MATERIAL
OP_CREATE_BODY
OP_CREATE_CAPSULE_SHAPE
OP_CREATE_CHAIN
OP_CREATE_CHAIN_SEGMENT_SHAPE
OP_CREATE_CIRCLE_SHAPE
OP_CREATE_DISTANCE_JOINT
OP_CREATE_FILTER_JOINT
OP_CREATE_MOTOR_JOINT
OP_CREATE_POLYGON_SHAPE
OP_CREATE_PRISMATIC_JOINT
OP_CREATE_REVOLUTE_JOINT
OP_CREATE_SEGMENT_SHAPE
OP_CREATE_WELD_JOINT
OP_CREATE_WHEEL_JOINT
OP_DESTROY_BODY
OP_DESTROY_CHAIN
OP_DESTROY_JOINT
OP_DESTROY_SHAPE
OP_DESTROY_WORLD
OP_DISTANCE_ENABLE_LIMIT
OP_DISTANCE_ENABLE_MOTOR
OP_DISTANCE_ENABLE_SPRING
OP_DISTANCE_SET_LENGTH
OP_DISTANCE_SET_LENGTH_RANGE
OP_DISTANCE_SET_MAX_MOTOR_FORCE
OP_DISTANCE_SET_MOTOR_SPEED
OP_DISTANCE_SET_SPRING_DAMPING_RATIO
OP_DISTANCE_SET_SPRING_FORCE_RANGE
OP_DISTANCE_SET_SPRING_HERTZ
OP_JOINT_SET_COLLIDE_CONNECTED
OP_JOINT_SET_CONSTRAINT_TUNING
OP_JOINT_SET_FORCE_THRESHOLD
OP_JOINT_SET_LOCAL_FRAME_A
OP_JOINT_SET_LOCAL_FRAME_B
OP_JOINT_SET_TORQUE_THRESHOLD
OP_JOINT_WAKE_BODIES
OP_MOTOR_SET_ANGULAR_DAMPING_RATIO
OP_MOTOR_SET_ANGULAR_HERTZ
OP_MOTOR_SET_ANGULAR_VELOCITY
OP_MOTOR_SET_LINEAR_DAMPING_RATIO
OP_MOTOR_SET_LINEAR_HERTZ
OP_MOTOR_SET_LINEAR_VELOCITY
OP_MOTOR_SET_MAX_SPRING_FORCE
OP_MOTOR_SET_MAX_SPRING_TORQUE
OP_MOTOR_SET_MAX_VELOCITY_FORCE
OP_MOTOR_SET_MAX_VELOCITY_TORQUE
OP_PRISMATIC_ENABLE_LIMIT
OP_PRISMATIC_ENABLE_MOTOR
OP_PRISMATIC_ENABLE_SPRING
OP_PRISMATIC_SET_LIMITS
OP_PRISMATIC_SET_MAX_MOTOR_FORCE
OP_PRISMATIC_SET_MOTOR_SPEED
OP_PRISMATIC_SET_SPRING_DAMPING_RATIO
OP_PRISMATIC_SET_SPRING_HERTZ
OP_PRISMATIC_SET_TARGET_TRANSLATION
OP_QUERY_CAST_MOVER
OP_QUERY_CAST_RAY
OP_QUERY_CAST_RAY_CLOSEST
OP_QUERY_CAST_SHAPE
OP_QUERY_COLLIDE_MOVER
OP_QUERY_OVERLAP_AABB
OP_QUERY_OVERLAP_SHAPE
OP_RECORDING_BOUNDS
OP_REVOLUTE_ENABLE_LIMIT
OP_REVOLUTE_ENABLE_MOTOR
OP_REVOLUTE_ENABLE_SPRING
OP_REVOLUTE_SET_LIMITS
OP_REVOLUTE_SET_MAX_MOTOR_TORQUE
OP_REVOLUTE_SET_MOTOR_SPEED
OP_REVOLUTE_SET_SPRING_DAMPING_RATIO
OP_REVOLUTE_SET_SPRING_HERTZ
OP_REVOLUTE_SET_TARGET_ANGLE
OP_SHAPE_APPLY_WIND
OP_SHAPE_ENABLE_CONTACT_EVENTS
OP_SHAPE_ENABLE_HIT_EVENTS
OP_SHAPE_ENABLE_PRE_SOLVE_EVENTS
OP_SHAPE_ENABLE_SENSOR_EVENTS
OP_SHAPE_RAY_CAST
OP_SHAPE_SET_CAPSULE
OP_SHAPE_SET_CHAIN_SEGMENT
OP_SHAPE_SET_CIRCLE
OP_SHAPE_SET_DENSITY
OP_SHAPE_SET_FILTER
OP_SHAPE_SET_FRICTION
OP_SHAPE_SET_POLYGON
OP_SHAPE_SET_RESTITUTION
OP_SHAPE_SET_SEGMENT
OP_SHAPE_SET_SURFACE_MATERIAL
OP_SHAPE_SET_USER_MATERIAL
OP_SHAPE_TEST_POINT
OP_STATE_HASH
OP_STEP
OP_WELD_SET_ANGULAR_DAMPING_RATIO
OP_WELD_SET_ANGULAR_HERTZ
OP_WELD_SET_LINEAR_DAMPING_RATIO
OP_WELD_SET_LINEAR_HERTZ
OP_WHEEL_ENABLE_LIMIT
OP_WHEEL_ENABLE_MOTOR
OP_WHEEL_ENABLE_SPRING
OP_WHEEL_SET_LIMITS
OP_WHEEL_SET_MAX_MOTOR_TORQUE
OP_WHEEL_SET_MOTOR_SPEED
OP_WHEEL_SET_SPRING_DAMPING_RATIO
OP_WHEEL_SET_SPRING_HERTZ
OP_WORLD_ENABLE_CONTINUOUS
OP_WORLD_ENABLE_SLEEPING
OP_WORLD_ENABLE_SPECULATIVE
OP_WORLD_ENABLE_WARM_STARTING
OP_WORLD_EXPLODE
OP_WORLD_REBUILD_STATIC_TREE
OP_WORLD_SET_CONTACT_RECYCLE_DISTANCE
OP_WORLD_SET_CONTACT_TUNING
OP_WORLD_SET_GRAVITY
OP_WORLD_SET_HIT_EVENT_THRESHOLD
OP_WORLD_SET_MAXIMUM_LINEAR_SPEED
OP_WORLD_SET_RESTITUTION_THRESHOLD
REC_MAGIC
Magic value ‘B2RC’ in little-endian. (B2_REC_MAGIC)
REC_VERSION_MAJOR
Recording format version. Any mismatch refuses to load. The minor tracks op stream layout changes that keep the 32 byte header shape. (B2_REC_VERSION_MAJOR/MINOR)
REC_VERSION_MINOR
SNAP_FLAG_DOUBLE_PRECISION
Image was built with double-precision world positions. (B2_SNAP_FLAG_DOUBLE_PRECISION)
SNAP_FLAG_VALIDATION
Image was built with validation (debug assertions). (B2_SNAP_FLAG_VALIDATION)
SNAP_FNV_INIT
FNV-1a 64-bit initial value. (B2_SNAP_FNV_INIT)
SNAP_FNV_PRIME
FNV-1a 64-bit prime. (B2_SNAP_FNV_PRIME)
SNAP_MAGIC
Snapshot image magic, ‘BNS2’. (B2_SNAP_MAGIC)
SNAP_VERSION
Bump this if any serialized data structure changes. (B2_SNAP_VERSION — restarted at 1 for the Rust field-order format)

Functions§

compute_layout_hash
Layout hash seeds from all serialized structs. Changing any struct size updates the hash and refuses older images, same role as C’s b2ComputeLayoutHash over its memcpy’d structs.
create_world_from_snapshot
Create a new world from a snapshot image. Returns None on an incompatible or corrupt image. (b2CreateWorldFromSnapshot)
fnv_mix_position
Mix a world position at full width, or the determinism gates would validate only to float precision and pass vacuously far from the origin. (b2FnvMixPosition)
hash_world_state
Deterministic hash over all body transforms and velocities. Called by both recorder and replayer to verify simulation reproduces exactly. (b2HashWorldState)
hash_world_state_deep
Deep world-state hash: transforms and velocities plus index bookkeeping, contact manifold impulses, joint impulses, and id-pool occupancy. Used by the snapshot tests to prove a restore reproduced the full solver state, not just the visible motion. (b2HashWorldStateDeep)
load_recording_from_file
Load a recording buffer saved by save_recording_to_file. (b2LoadRecordingFromFile)
rec_patch_u32
Backfill a reserved u32 slot. (b2RecPatchU32)
rec_reserve_u32
Reserve a u32 slot for backfill (query hit counts). Returns its offset. (b2RecReserveU32)
rec_w_aabb
rec_w_bodydef
rec_w_bodyid
rec_w_bool
rec_w_capsule
rec_w_chaindef
Variable-length def: point and material arrays are length-prefixed and inlined. (b2RecW_CHAINDEF)
rec_w_chainid
rec_w_chainseg
rec_w_circle
rec_w_distancejointdef
rec_w_explosiondef
rec_w_f32
rec_w_f64
rec_w_filter
rec_w_filterjointdef
rec_w_i32
rec_w_jointid
rec_w_locks
rec_w_massdata
rec_w_material
rec_w_motorjointdef
rec_w_planeresult
rec_w_polygon
rec_w_position
rec_w_prismaticjointdef
rec_w_queryfilter
rec_w_rayresult
rec_w_revolutejointdef
rec_w_rot
rec_w_segment
rec_w_shapedef
rec_w_shapeid
rec_w_shapeproxy
rec_w_str
Length-prefixed string; 0xFFFF marks NULL in C. Rust strings are never null, so that sentinel only appears when reading C recordings. (b2RecW_STR)
rec_w_treestats
rec_w_u8
rec_w_u16
rec_w_u32
rec_w_u64
rec_w_vec2
rec_w_weldjointdef
rec_w_wheeljointdef
rec_w_worldcastoutput
rec_w_worldid
rec_w_worldxf
rec_w_xf
replay_buffer
(b2ReplayFile core loop, serial)
save_recording_to_file
Persist a recording buffer. The library never opens files while recording; this lets a host save a finished session. (b2SaveRecordingToFile)
serialize_world
Serialize the complete simulation state. (b2SerializeWorld)
validate_replay
Replay a recording buffer against a world restored from its seed snapshot, verifying every recorded StateHash. Unknown opcodes are skipped by their framed size, like C’s b2RecDispatchOne, so a stream containing not-yet-dispatched mutation ops still advances. Returns true only when the whole stream reads cleanly and no hash diverges. (b2ValidateReplay)
world_restore
Restore simulation state from a snapshot image into an existing world, preserving host wiring (callbacks, user data). Returns false and leaves the world untouched on an incompatible or corrupt image. (b2World_Restore / b2DeserializeIntoShell)
world_snapshot
Serialize the world into a fresh image. (b2World_Snapshot — returns the image instead of filling a caller buffer)
world_start_recording
Start recording this world’s session into the given recording buffer. No-op if a session is already active (the recording is returned unused). (b2World_StartRecording)
world_stop_recording
Stop the active recording session and return the finished buffer. (b2World_StopRecording)