DetPhysDocs日本語

detphys_rt.hreal-time rollback sessions (version 8)

FunctionDescription
detphys_rt_abi_versionThis header's version
detphys_rt_config_defaultDefault settings (delay 0, N 10, hash check every tick, each hash in 2 packets, dyn, 1 worker, 4 bases, time sync at 1 tick, 100 ms keepalive, 5000 ms peer timeout)
detphys_rt_createCreates a session (creates the world, registers shapes, calls begin)
detphys_rt_create_kinematicSame, also passing a kinematic table (moving concave shapes)Usage: Concepts › Moving concave shapes
detphys_rt_destroyDestroys it
detphys_rt_pollReads what arrived; sends acks and resync stateUsage: Concepts › Transports
detphys_rt_advancePasses your input and advances one tick (rolling back and re-simulating if needed). Returns ADVANCED / STALLED / SYNC_WAIT / DELAY_WAITUsage: Concepts › Real time (rollback)
detphys_rt_next_input_tickThe tick the next advance's input goes toUsage: Concepts › Real time (rollback)
detphys_rt_next_confirmedTakes the oldest confirmed tick record (tick, hash), for replays and logs
detphys_rt_get_statsCounters for rollbacks, re-simulation, waits, hash checks, resyncs, bytes and timeUsage: Desyncs › Desyncs are repaired automatically first
detphys_rt_worldCurrent world (including predictions; read it for drawing)Usage: Concepts › Real time (rollback)
detphys_rt_read_stateCurrent game state words
detphys_rt_errorReason when in ERROR
detphys_rt_auto_delay_defaultDefault automatic input delay (off, 0–6, jitter × 1, raise after 500 ms, lower after 3000 ms)
detphys_rt_set_auto_delaySets automatic input delay (NULL = off)Usage: Concepts › Zero input delay and automatic input delay
detphys_rt_debug_nudge_atTest only: shifts the state by 1 ULP after that tickUsage: Determinism rules › How to check
detphys_rt_set_debugTurns the desync debugger on / offUsage: Desyncs › Turning the desync debugger on
detphys_rt_debug_countNumber of reportsUsage: Desyncs › Reading the report
detphys_rt_debug_getReads a report
detphys_rt_debug_bundlePacks a report and both recordings into a bundle
detphys_rt_debug_statsRecording and exchange counters
detphys_rt_get_tag_infoReads what a peer with a mismatching config check sends (the same detphys_tag_info as turn-based). Read it when DETPHYS_RT_FRAME_TAG_MISMATCH is set. Version 7
StructDescription
detphys_rt_sessionA session (opaque)
detphys_rt_configSettings (session id, shapes, peer, world, input delay 0–30, prediction window 0–60, hash checks, snapshots, workers, network values)Usage: Concepts › 3D
detphys_rt_ruleA rule (1–16 input words, 0–64 state words, params, begin, apply_inputs, after_tick, predict)Usage: Concepts › Rules
detphys_rt_ctxValues passed to callbacks (world, params, state, tick, peer, re-simulating)
detphys_rt_frameResult of advance (tick, input tick, confirmed tick, re-simulated ticks, flags [DETPHYS_RT_FRAME_*; version 7 added DETPHYS_RT_FRAME_TAG_MISMATCH], round trip)Usage: Desyncs › Desyncs are repaired automatically first
detphys_rt_confirmedA confirmed tick record
detphys_rt_statsSession counters
detphys_rt_auto_delayAutomatic input delay settings

Built-in rule: push (version 5)

A real-time rule where two players (circles) push boxes and concave shapes with a 2-word input [move −100..100, buttons (1 = jump, 2 = dash)]. The callbacks live inside the core (C++), so an engine only creates the session. Unity's DetPhysRtSession.CreatePush and Godot's DetPhysRtSession.create_push call it too. With the same settings, every engine and device produces the same confirmed-tick hashes, so they connect to each other. A moving field (field) adds a spinning gear (DETPHYS_RULE_PUSH_FIELD_GEAR), a sliding platform (PLATFORM) and a lift (LIFT) made of concave shapes; the session creates and owns their kinematic table.

FunctionDescription
detphys_rule_push_desc_defaultDefault push settings (60 boxes, 12 concave shapes, 8 meshes, half floor width 12000 mm, no moving field, REPEAT prediction)
detphys_rt_create_pushCreates a push session (the simplest entry point; with a moving field it also creates the table and destroys it with detphys_rt_destroy). NULL on failureUsage: Transports and room codes › Usage (the same for every transport)
detphys_rt_rule_pushWrites only the push rule (to wrap the rule or use your own table; with a moving field put the table in rule.user and call detphys_rt_create_kinematic)
detphys_rule_push_get_layoutIDs of the bodies begin creates (floor 0, walls 1 and 2, players 3 and 4, boxes, shapes, moving field), without creating a sessionUsage: Concepts › Rules
detphys_rt_kinematicThe kinematic table a session is moving (read only; NULL if none)
StructDescription
detphys_rule_push_descPush settings (144 B: box and shape counts, seed, floor / wall / player sizes, force, speed, jump, dash, moving field field [GEAR 1, PLATFORM 2, LIFT 4, ALL 7], speed %, drop height, mesh indices, predict [REPEAT / RELEASED], table split settings kinematic_*)
detphys_rule_push_layoutThe body ID layout and the params size (88 or 120 bytes)

Constants: DETPHYS_RULE_PUSH_ID, DETPHYS_RULE_PUSH_INPUT_WORDS (2), DETPHYS_RULE_PUSH_STATE_WORDS (4), DETPHYS_RULE_PUSH_TAG_* (box 1, shape 2, field 3, player 100 + peer).

3D sessions (version 6)

The tick flow, prediction, rollback, hash checks, resync, rejoin and automatic delay are the same as in 2D; the world is 3D (detphys3d.h). Differences:

  • World settings are a detphys3d_world_desc. The config's world, meshes, worker_count and snapshot_base_slots are not used (mesh_count must be 0); register convex hulls in begin, in the same order on both peers (their contents are part of the config check).
  • Full snapshots are recommended for the state ring (detphys_rt_config_default3d sets FULL). The checked hash is detphys3d_world_hash plus the state words.
  • Resync and rejoin send a transfer (detphys3d_world_transfer_*, which also carries the shape registry and the hull table), so the receiver can restore even when its registry drifted during prediction.
  • The desync debugger (detphys_rt_set_debug) works in 3D too (when detphys_debug_abi_version() is 3 or later; recordings use the 3D format and reports the 3D fields; see 5. Troubleshooting desyncs).
  • Pass a 3D kinematic table with detphys_rt_create3d_kinematic in detphys3d_kinematic.h (see the detphys3d_kinematic.h section below).
FunctionDescription
detphys_rt_config_default3dFills session settings (snapshot FULL) and 3D world settings with defaults (either may be NULL)
detphys_rt_create3dCreates a 3D session (NULL world settings = defaults). Then poll → advance → next_confirmed as in 2DUsage: Concepts › 3D
detphys_rt_world3dThe current 3D world (includes prediction; read it for drawing). For 3D sessions detphys_rt_world returns NULLUsage: Concepts › 3D
detphys_rt_get_resync_infoWhat was sent / received on resync and rejoin (counts, registry rebuilds, size, restore time). Works for 2D too
StructDescription
detphys_rt_rule3dA 3D rule (same layout as detphys_rt_rule; callbacks receive detphys_rt_ctx3d; 72 B)
detphys_rt_ctx3dValues passed to callbacks (same layout as detphys_rt_ctx; only world is a detphys3d_world*)
detphys_rt_resync_infoResync status (dimensions 2 / 3, sent, received, registry_rebuilds, hull_replacements, last size, tick and time)

Built-in rule: 3D push (version 8)

A 3D real-time rule where two players (spheres) push boxes, spheres and convex hulls (6 kinds made from the seed) inside a floor with four walls, with a 3-word input [move x, move z (−100..100), buttons (1 = jump, 2 = dash, 4 = drop a box)]. As with the 2D push rule, the callbacks live inside the core (C++), so an engine only creates the session. The params and rule id are the same as the C# rule of Unity's "3D push" sample, so with the same settings the confirmed-tick hashes are the same and those peers connect. With the turntable (field = DETPHYS_RULE_PUSH3D_FIELD_TURNTABLE) a concave table (a 16-sided disc with three low walls) spins as a function of the tick; the session creates and owns its 3D kinematic table (read it with detphys_rt_kinematic3d).

FunctionDescription
detphys_rule_push3d_desc_defaultDefault 3D push settings (40 boxes, 8 spheres, 12 hulls, up to 24 dropped boxes per player, seed 0x5EED0036, no turntable [800 mrad/s, center (0, +7 m)], REPEAT prediction)
detphys_rt_create_push3dCreates a 3D push session (the simplest entry point; NULL world settings = defaults; with the turntable it also creates the table and destroys it with detphys_rt_destroy). NULL on failureUsage: Quick start › 3D push (Box3D, real time, zero input delay)
detphys_rt_rule_push3dWrites only the 3D push rule (a detphys_rt_rule3d; to wrap the rule or use your own table; with the turntable put a detphys3d_kinematic* in rule.user and call detphys_rt_create3d_kinematic)
detphys_rule_push3d_get_layoutIDs of the bodies and hulls begin creates (floor 0, walls 1–4, players 5 and 6, boxes, spheres, hulls, turntable, then boxes dropped during the match), without creating a session
detphys_rule_push3d_auto_inputsThe samples' automatic inputs (ticks 0..ticks, 3 words per tick), for comparing with the reference hashes
StructDescription
detphys_rule_push3d_desc3D push settings (144 B: box / sphere / hull counts, boxes that can be dropped, seed, floor / wall / player sizes, force, speed, jump, dash, drop interval, object sizes, density and friction, turntable field [NONE 0, TURNTABLE 1], spin and center, predict [DETPHYS_RULE_PUSH_PREDICT_*], table split settings kinematic_*)
detphys_rule_push3d_layoutThe body ID layout (turntable table_body, dropped boxes first_dropped), hull IDs (stones hull_types, turntable disc table_hull) and the params size (88 or 104 bytes)

Constants: DETPHYS_RULE_PUSH3D_ID, DETPHYS_RULE_PUSH3D_INPUT_WORDS (3), DETPHYS_RULE_PUSH3D_STATE_WORDS (8), DETPHYS_RULE_PUSH3D_BUTTON_*, DETPHYS_RULE_PUSH3D_TAG_* (box 1, sphere 2, hull 3, turntable 7, dropped box 50 + peer, player 100 + peer), DETPHYS_RULE_PUSH3D_FIELD_*.

DetPhys is not affiliated with Box2D or Box3D and is not endorsed or recommended by Box2D, Box3D or their author. It uses Box2D v3 and Box3D, both under the MIT license, as its physics.

LicensesMatches the current versions (2026-11)

© 2026 PetafProductsContactPrivacy

This site uses no analytics or tracking.

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