DetPhysDocs日本語

detphys3d_kinematic.h3D moving concave shapes (version 1)

This header brings the ideas of the 2D detphys_kinematic.h 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_kinematic_desc), statistics (detphys_kinematic_stats), segment easing (DETPHYS_EASE_*), motion flags (DETPHYS_MOTION_*) and session flags (DETPHYS_KINEMATIC_SESSION_*) 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.

FunctionDescription
detphys3d_kinematic_abi_versionThis header's version (DETPHYS3D_KINEMATIC_ABI_VERSION)
detphys3d_motion_desc_defaultDefault motion (FIXED, SMOOTH, spin axis y)
detphys3d_kinematic_createCreates 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_destroyDestroys it
detphys3d_kinematic_addCreates a kinematic body with a motion and returns its ID. The shape is body->shape (add more with detphys3d_world_add_shape for a convex compound)Usage: Concepts › Moving concave shapes (3D)
detphys3d_kinematic_bindGives 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_unbindRemoves a motion (the body stays and keeps moving with its last velocity; set it to 0 with detphys3d_world_set_velocity to stop it)
detphys3d_kinematic_clearRemoves all motions (bodies stay in the world; the session calls this before begin)
detphys3d_kinematic_updateSnaps to the current tick's pose and sets the velocity and angular velocity that reach the next tick's pose (call after every detphys3d_world_step; calling it again changes nothing)
detphys3d_kinematic_stepAdvances one tick (instead of detphys3d_world_step; fast ticks are split into up to max_subticks pieces, then it updates). Returns the number of pieces
detphys3d_kinematic_pose_atThe 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_QUAT_ONE and rounded (it follows the continuous rotation, so qw is not always ≥ 0)
detphys3d_kinematic_checkWhether 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_statsSplit counts and other statistics (the same detphys_kinematic_stats as 2D)
detphys3d_kinematic_session_defaultDefault settings for passing a table to a session
detphys_rt_create3d_kinematicSame as detphys_rt_create3d, also passing a 3D tableUsage: Concepts › Moving concave shapes (3D)
detphys_turn_create_rule3d_kinematicSame as detphys_turn_create_rule3d, also passing a 3D table (emptied before begin_match of every match)Usage: Concepts › Moving concave shapes (3D)
detphys_rt_kinematic3dThe 3D table a real-time session is moving (read only; NULL if none)
detphys_turn_kinematic3dThe 3D table a turn-based session is moving (read only; NULL if none)
StructDescription
detphys3d_kinematicA 3D kinematic table (opaque)Usage: Concepts › Moving concave shapes
detphys3d_motion_descA 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_pointA POINTS point (position in mm, angle around the spin axis in mrad, ticks to the next point). 24 B
detphys3d_kinematic_poseA pose returned by a callback (position [µm], integer quaternion). 40 B
detphys3d_kinematic_sessionSettings for passing a table to a session (the table, flags NO_PRE_UPDATE / NO_SPLIT)

Type: detphys3d_motion_fn (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_KINEMATIC_ABI_VERSION (1), paths DETPHYS3D_PATH_FIXED (0), DETPHYS3D_PATH_PINGPONG (1), DETPHYS3D_PATH_ORBIT (2), DETPHYS3D_PATH_POINTS (3), DETPHYS3D_PATH_CALLBACK (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_kinematic_step (with NO_SPLIT: detphys3d_world_step → update) → after_tick.
  • 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.

↑↓ to choose, Enter to open, Esc to close