detphys3d_kinematic.h3D moving concave shapes (version 1)
This header brings the ideas of the 2D detphys_ to 3D worlds (detphys3d.h). It only adds things; the functions and versions of the other headers did not change (the calls that pass a table to 3D sessions are in this header too). The table settings (detphys_), statistics (detphys_), segment easing (DETPHYS_EASE_*), motion flags (DETPHYS_MOTION_*) and session flags (DETPHYS_) are the 2D ones. Values are integers in mm, mrad, mrad/s and ticks; orientations are integer quaternions. See 3. Concepts for the ideas and usage.
| Function | Description |
|---|---|
detphys3d_kinematic_abi_version | This header's version (DETPHYS3D_) |
detphys3d_motion_desc_default | Default motion (FIXED, SMOOTH, spin axis y) |
detphys3d_kinematic_create | Creates a kinematic table (NULL = defaults: split up to 4 times, 20 mm). One per world. It may be destroyed before or after the world |
detphys3d_kinematic_destroy | Destroys it |
detphys3d_kinematic_add | Creates a kinematic body with a motion and returns its ID. The shape is body->shape (add more with detphys3d_ for a convex compound)Usage: Concepts › Moving concave shapes (3D) |
detphys3d_kinematic_bind | Gives an existing kinematic body a motion (replacing any previous one; snaps it to the current tick's pose at once and lifts the angular speed limit) |
detphys3d_kinematic_unbind | Removes a motion (the body stays and keeps moving with its last velocity; set it to 0 with detphys3d_ to stop it) |
detphys3d_kinematic_clear | Removes all motions (bodies stay in the world; the session calls this before begin) |
detphys3d_kinematic_update | Snaps to the current tick's pose and sets the velocity and angular velocity that reach the next tick's pose (call after every detphys3d_; calling it again changes nothing) |
detphys3d_kinematic_step | Advances one tick (instead of detphys3d_; fast ticks are split into up to max_subticks pieces, then it updates). Returns the number of pieces |
detphys3d_kinematic_pose_at | The motion function's pose (also inside a tick with sub_milli 0–999, for interpolated drawing). The orientation is an integer quaternion scaled by DETPHYS3D_ and rounded (it follows the continuous rotation, so qw is not always ≥ 0) |
detphys3d_kinematic_check | Whether the raw bits of position, orientation, velocity and angular velocity in the world equal the values rebuilt from the functions (returns the number of differing bodies; 0 = all equal)Usage: Desyncs › With moving concave shapes |
detphys3d_kinematic_get_stats | Split counts and other statistics (the same detphys_ as 2D) |
detphys3d_kinematic_session_default | Default settings for passing a table to a session |
detphys_rt_create3d_kinematic | Same as detphys_, also passing a 3D tableUsage: Concepts › Moving concave shapes (3D) |
detphys_turn_create_rule3d_kinematic | Same as detphys_, also passing a 3D table (emptied before begin_match of every match)Usage: Concepts › Moving concave shapes (3D) |
detphys_rt_kinematic3d | The 3D table a real-time session is moving (read only; NULL if none) |
detphys_turn_kinematic3d | The 3D table a turn-based session is moving (read only; NULL if none) |
| Struct | Description |
|---|---|
detphys3d_kinematic | A 3D kinematic table (opaque)Usage: Concepts › Moving concave shapes |
detphys3d_motion_desc | A motion (path DETPHYS3D_PATH_*, ease, flags, positions A / B, initial orientation [integer quaternion], spin axis, spin, orbit, ticks per one way, hold ticks at both ends hold_a_ticks / hold_b_ticks, phase, points, callback). 128 BUsage: Concepts › Moving concave shapes (3D) |
detphys3d_motion_point | A POINTS point (position in mm, angle around the spin axis in mrad, ticks to the next point). 24 B |
detphys3d_kinematic_pose | A pose returned by a callback (position [µm], integer quaternion). 40 B |
detphys3d_kinematic_session | Settings for passing a table to a session (the table, flags NO_PRE_UPDATE / NO_SPLIT) |
Type: detphys3d_ (the shape of a CALLBACK motion function: receives user, the body ID and the tick, writes the pose and returns 0; negative = failure).
Constants: DETPHYS3D_ (1), paths DETPHYS3D_ (0), DETPHYS3D_ (1), DETPHYS3D_ (2), DETPHYS3D_ (3), DETPHYS3D_ (4).
- One tick (the same on every peer and during re-simulation): update (at the start of the tick; skipped with
NO_PRE_UPDATE) → the rule's apply_inputs (apply_input in turn-based play) →detphys3d_(withkinematic_ step NO_SPLIT:detphys3d_→ update) → after_tick.world_ step - Keep the table alive longer than the session, and make one per peer and per session (the session does not copy it; do not share it with other worlds).
- The table's split settings, flags and motions (its contents after begin) are part of the config check, so peers with different motions do not connect. Sessions without a table keep the same check values as before.
- Change the table (add / bind / unbind / clear) only inside begin (
begin_match). The table is not rolled back; to change a motion during a match, make the motion itself a function of the tick (stops with POINTS, or CALLBACK computing from the tick). - Nothing is needed after a rollback (snapshot restore): the snapshot holds the function's values. The table is in neither the snapshot nor the state ring.
- Structs contain only fixed-width integers and pointers, with no implicit padding on 64-bit.