DetPhysDocs日本語

API reference (C ABI)

The core C ABI is the C headers below (2D is detphys_*, 3D is detphys3d_*). The engine layers call these functions too. Common conventions:

Headers

detphys.hworld, step, hash, workers, snapshots (version 2)21
detphys_body.hbodies, shapes, readback for drawing (version 2)23
detphys_turn.hturn-based sessions, transport interface, loopback (version 9)67
detphys_rt.hreal-time rollback sessions (version 8)54
detphys_kinematic.hmoving concave shapes (version 2)22
detphys_debug.hdesync debugger (version 3, recording format DNDR 2, bundle DNDB 1)32
detphys_udp.hUDP transport for LAN11
detphys_link.hconnection interface and room codes (version 1)28
detphys_relay.hconnecting through your own relay (version 1)4
detphys_eos.hEOS P2P transport (version 2)7
detphys_bake.hconcave shape baker (version 1)13
detphys_rule.hppC++ helper for writing rules (header only)
detphys3d.h3D world, bodies, convex hulls, snapshots, transfers (version 2)48
detphys3d_kinematic.h3D moving concave shapes (version 1)23
Engine layer names

Every function and struct

NameDescriptionHeader
detphys3d_abi_versionThis header's version (DETPHYS3D_ABI_VERSION)detphys3d.h
detphys3d_body_descBody settings (type DETPHYS3D_BODY_STATIC / KINEMATIC / DYNAMIC, position, integer quaternion, velocity, angular velocity, damping, gravity scale, flags [BULLET, NO_SLEEP, per-axis LOCK_*], tag, first shape). 176 Bdetphys3d.h
detphys3d_body_desc_defaultDefault body settings (dynamic body)detphys3d.h
detphys3d_body_viewReadback (ID, type, flags, tag, shape, integer position x_mm/y_mm/z_mm, floats for drawing). 96 Bdetphys3d.h
detphys3d_hull_infoInformation about a registered hulldetphys3d.h
detphys3d_kinematicA 3D kinematic table (opaque)detphys3d_kinematic.h
detphys3d_kinematic_abi_versionThis header's version (DETPHYS3D_KINEMATIC_ABI_VERSION)detphys3d_kinematic.h
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)detphys3d_kinematic.h
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.h
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)detphys3d_kinematic.h
detphys3d_kinematic_clearRemoves all motions (bodies stay in the world; the session calls this before begin)detphys3d_kinematic.h
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 worlddetphys3d_kinematic.h
detphys3d_kinematic_destroyDestroys itdetphys3d_kinematic.h
detphys3d_kinematic_get_statsSplit counts and other statistics (the same detphys_kinematic_stats as 2D)detphys3d_kinematic.h
detphys3d_kinematic_poseA pose returned by a callback (position [µm], integer quaternion). 40 Bdetphys3d_kinematic.h
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.h
detphys3d_kinematic_sessionSettings for passing a table to a session (the table, flags NO_PRE_UPDATE / NO_SPLIT)detphys3d_kinematic.h
detphys3d_kinematic_session_defaultDefault settings for passing a table to a sessiondetphys3d_kinematic.h
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 piecesdetphys3d_kinematic.h
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.h
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.h
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 Bdetphys3d_kinematic.h
detphys3d_motion_desc_defaultDefault motion (FIXED, SMOOTH, spin axis y)detphys3d_kinematic.h
detphys3d_motion_pointA POINTS point (position in mm, angle around the spin axis in mrad, ticks to the next point). 24 Bdetphys3d_kinematic.h
detphys3d_shape_descOne shape (DETPHYS3D_SHAPE_BOX / SPHERE / CAPSULE / HULL, size, center, orientation, material). 88 Bdetphys3d.h
detphys3d_shape_desc_defaultDefault shape settings (friction 600, density 1000000 = water, restitution 0, × 1000)detphys3d.h
detphys3d_snapshot_read_infoReads an image header (no world needed)detphys3d.h
detphys3d_transfer_infoTransfer header (sizes of hulls, registry and image, tick; after a restore, flags [DETPHYS3D_TRANSFER_REBUILT_REGISTRY, REPLACED_HULLS])detphys3d.h
detphys3d_transfer_read_infoReads a transfer header (and verifies the checksum)detphys3d.h
detphys3d_worldA 3D world (opaque)detphys3d.h
detphys3d_world_add_bodyCreates a body. Returns its ID (a serial number in creation order)detphys3d.h
detphys3d_world_add_hullBuilds and registers a convex hull from integer points (units_per_meter, 0 = mm). Returns its index; the same contents return the earlier indexdetphys3d.h
detphys3d_world_add_shapeAdds a shape to a body (compound bodies)detphys3d.h
detphys3d_world_apply_angular_impulseApplies an angular impulse (mN·m·s)detphys3d.h
detphys3d_world_apply_forceApplies a force (mN, for the next tick only)detphys3d.h
detphys3d_world_apply_impulseApplies an impulse (mN·s, changes the velocity at once)detphys3d.h
detphys3d_world_apply_torqueApplies a torque (mN·m, for the next tick only)detphys3d.h
detphys3d_world_body_countNumber of bodies created (removed ones included)detphys3d.h
detphys3d_world_body_shapesReads the shapes attached to a bodydetphys3d.h
detphys3d_world_createCreates a world (NULL = defaults). NULL on failuredetphys3d.h
detphys3d_world_descTick rate, substeps, gravity xyz, 1–32 workers, pool (DETPHYS3D_POOL_OWN / BOX3D / EXTERNAL), flags (NO_SLEEP, NO_CONTINUOUS, SSE2), contact tuning (0 = Box3D's defaults). 88 Bdetphys3d.h
detphys3d_world_desc_defaultDefault world settings (60 Hz, 4 substeps, gravity (0, −10000, 0) mm/s², 1 worker, the core's pool)detphys3d.h
detphys3d_world_destroyDestroys itdetphys3d.h
detphys3d_world_engine_hashBox3D's own state hash (for checking)detphys3d.h
detphys3d_world_get_bodyReads one body's current statedetphys3d.h
detphys3d_world_get_descReads the settings it was created withdetphys3d.h
detphys3d_world_get_snapshot_statsSnapshot statusdetphys3d.h
detphys3d_world_get_statsBodies, awake count, contacts, hull count and moredetphys3d.h
detphys3d_world_hashState hash (FNV-1a 64 over tick, body count and each body's position 3, quaternion 4, velocity 3, angular velocity 3 raw bits)detphys3d.h
detphys3d_world_hull_countNumber of registered hullsdetphys3d.h
detphys3d_world_hull_infoHull information (vertex, face and triangle counts, radius, checksum)detphys3d.h
detphys3d_world_hull_readReads a hull's vertices [m] and triangle indices for drawingdetphys3d.h
detphys3d_world_read_bodiesReads all bodies into an array (fine to call every frame)detphys3d.h
detphys3d_world_read_transformsLight readback for drawing only (7 floats per body: position xyz [m], quaternion)detphys3d.h
detphys3d_world_remove_bodyRemoves a body (IDs are not reused)detphys3d.h
detphys3d_world_set_transformSets position and orientation directly (mm, integer quaternion)detphys3d.h
detphys3d_world_set_velocitySets velocity and angular velocity (mm/s, mrad/s)detphys3d.h
detphys3d_world_snapshot_restoreRestores a snapshot (the tick and body list too; registered hulls are kept; restoring a full one always starts a new shape version)detphys3d.h
detphys3d_world_snapshot_sizeMeasures the current snapshot size (default DETPHYS3D_SNAPSHOT_DEFAULT = FULL)detphys3d.h
detphys3d_world_snapshot_writeWrites a snapshot into a caller bufferdetphys3d.h
detphys3d_world_statsWorld statusdetphys3d.h
detphys3d_world_stepAdvances one tickdetphys3d.h
detphys3d_world_step_nAdvances count ticks (fewer calls when re-simulating after a rollback)detphys3d.h
detphys3d_world_tickCurrent tick numberdetphys3d.h
detphys3d_world_transfer_restoreRestores a transfer (written by another world or device; rebuilds the registry or hull table first if they differ)detphys3d.h
detphys3d_world_transfer_sizeMeasures the state to send to another peer (transfer)detphys3d.h
detphys3d_world_transfer_writeWrites a transfer (full image + shape registry contents + hull table)detphys3d.h
detphys_abi_versionThis header's version (DETPHYS_ABI_VERSION). Compare with >= at startupdetphys.h
detphys_bake_abi_versionVersion of this header (DETPHYS_BAKE_ABI_VERSION)detphys_bake.h
detphys_bake_alphaBake an alpha image (1 byte per pixel), an RGBA image (alpha is the 4th byte) or the bytes of a PNG file (rows top-down; up to 16384 x 16384 px). params may be NULL (the defaults). Always return a result (NULL only when memory runs out)detphys_bake.h
detphys_bake_dataThe .dnshape bytes (NULL when the bake failed). Valid until the result is destroyeddetphys_bake.h
detphys_bake_errorWhy the bake failed (English, one sentence; empty on success)detphys_bake.h
detphys_bake_get_statsNumbers about the bake (detphys_bake_stats)detphys_bake.h
detphys_bake_paramsUnits per m, pixels per m, alpha threshold, most vertices per piece (3–8), decomposition (DETPHYS_BAKE_STEINER = default, DETPHYS_BAKE_HM = Hertel-Mehlhorn), simplification tolerance (px), smallest bulge of a vertex (mm), smallest island (px), Steiner snap distance (mm)detphys_bake.h
detphys_bake_params_defaultDefault parameters (1000 units per m = mm, 128 px per m, alpha 128 or more is inside, 8 vertices per piece, Steiner, tolerance 1 px)detphys_bake.h
detphys_bake_png_alphaReads the alpha of a PNG without baking it (call with alpha = NULL to get the size first)detphys_bake.h
detphys_bake_read_outlineThe simplified outline, for previews (loops and vertices in vertex units)detphys_bake.h
detphys_bake_resultA finished bake (opaque)detphys_bake.h
detphys_bake_result_destroyFrees a resultdetphys_bake.h
detphys_bake_statsImage size, pieces and their vertices, outline loops and vertices, holes filled, specks dropped, vertices removed, Steiner points, bounds, the tolerance used and the largest distance from the traced outline (mm)detphys_bake.h
detphys_bake_statusDETPHYS_OK, DETPHYS_BAKE_ERR_IMAGE (−20, the image could not be read), DETPHYS_BAKE_ERR_SHAPE (−21, no shape could be made) or DETPHYS_ERR_ARGUMENT / DETPHYS_ERR_INTERNALdetphys_bake.h
detphys_body_abi_versionThis header's versiondetphys_body.h
detphys_body_descBody settings (type DETPHYS_BODY_STATIC / KINEMATIC / DYNAMIC, position, velocity, damping, flags [DETPHYS_BODY_FLAG_BULLET], tag, first shape)detphys_body.h
detphys_body_desc_defaultDefault body settings (dynamic body)detphys_body.h
detphys_body_viewRead-back state (ID, type, flags, tag, shape, integer pose x_mm/y_mm/angle_mrad, floats for drawing)detphys_body.h
detphys_build_infoOne line of build information (compiler, CPU, floating-point settings, SIMD), for comparison logsdetphys.h
detphys_debug_abi_versionThis header's versiondetphys_debug.h
detphys_debug_bodyOne body in a 2D recording (raw bits of x, y, cos, sin, vx, vy, w)detphys_debug.h
detphys_debug_body3dOne body in a 3D recording (raw bits of x, y, z, qx, qy, qz, qw, vx, vy, vz, wx, wy, wz; hull = hull index; 136 B). Version 3detphys_debug.h
detphys_debug_bundle_infoBundle headerdetphys_debug.h
detphys_debug_bundle_info_getReads a bundle (DNDB) header and the positions of its two recordingsdetphys_debug.h
detphys_debug_cause_nameCause name ("input", "physics", …)detphys_debug.h
detphys_debug_compareCompares two recordings (first diverging tick, body, field, ULPs, cause, spread)detphys_debug.h
detphys_debug_configRecording settings (dimensions 2 / 3; renamed from reserved in version 3)detphys_debug.h
detphys_debug_config_defaultDefault recording settings (600 ticks, 256 bodies, 32 input words, 16 state words, deep hash and types / shapes)detphys_debug.h
detphys_debug_diffOne differing field (body, field, values in A and B, ULPs)detphys_debug.h
detphys_debug_exportWrites a range of ticks as DNDR bytesdetphys_debug.h
detphys_debug_field_nameField name ("x", "vx", "qw", …)detphys_debug.h
detphys_debug_file_bodiesReads the bodies of a tick (2D recordings only; 3D recordings return DETPHYS_ERR_FORMAT)detphys_debug.h
detphys_debug_file_bodies3dReads the bodies of a tick of a 3D recording (2D recordings return DETPHYS_ERR_FORMAT). Version 3detphys_debug.h
detphys_debug_file_find_tickFinds the index of a tick numberdetphys_debug.h
detphys_debug_file_infoRecording header (format_version 1 = 2D, 2 = 3D; 3D recordings have DETPHYS_DEBUG_FILE_3D in flags)detphys_debug.h
detphys_debug_file_info_getReads a recording (DNDR) headerdetphys_debug.h
detphys_debug_file_tickReads the tick at an indexdetphys_debug.h
detphys_debug_recordRecords the world's current state (with inputs and state words)detphys_debug.h
detphys_debug_record3dRecords a 3D world's current state (into a recorder created with dimensions = 3; the recorded hash equals detphys3d_world_hash). Version 3detphys_debug.h
detphys_debug_recorder_clearDrops all recorded ticksdetphys_debug.h
detphys_debug_recorder_initUses a caller buffer as a recorderdetphys_debug.h
detphys_debug_recorder_sizeBuffer size needed for a recorderdetphys_debug.h
detphys_debug_recorder_statsRecorder statisticsdetphys_debug.h
detphys_debug_recorder_stats_getRecorder statisticsdetphys_debug.h
detphys_debug_reportComparison result (cause, first diverging tick, first tick per kind, counts)detphys_debug.h
detphys_debug_session_configSession debug settingsdetphys_debug.h
detphys_debug_session_config_defaultDefault session debug settings (off, 30-tick range, 4 reports, 10000 ms)detphys_debug.h
detphys_debug_session_reportOne desync report (status, range, bytes, report, first difference)detphys_debug.h
detphys_debug_session_statsSession debug countersdetphys_debug.h
detphys_debug_tickOne tick's header (hash, deep hash [Box3D's in 3D], body count, word counts)detphys_debug.h
detphys_debug_write_fileWrites bytes to a file (UTF-8 path)detphys_debug.h
detphys_eos_abi_versionVersion of this header (DETPHYS_EOS_ABI_VERSION)detphys_eos.h
detphys_eos_descDeveloper portal values (product ID, sandbox ID, deployment ID, client ID and client secret), product name and version, the name used to log in, cache folder, socket name, login timeout, log level, relay mode, flagsdetphys_eos.h
detphys_eos_desc_defaultDefault settingsdetphys_eos.h
detphys_eos_last_errorWhy the last detphys_eos_link_create failed ("" if it did not)detphys_eos.h
detphys_eos_link_createCreates an EOS transport (detphys_link). The first one initializes EOS and starts logging in with a device ID (the login continues inside detphys_link_poll, so you can call detphys_link_host / detphys_link_join without waiting). One at a time per processdetphys_eos.h
detphys_eos_sdk_versionVersion string of the loaded EOS SDK (to check where the SDK is and that it links)detphys_eos.h
detphys_eos_shutdownShuts EOS down. Call it once at the end of the process (if a transport still exists it does nothing and returns DETPHYS_LINK_E_STATE; afterwards no more EOS transports can be created in the same process)detphys_eos.h
detphys_kinematicA kinematic table (opaque)detphys_kinematic.h
detphys_kinematic_abi_versionThis header's versiondetphys_kinematic.h
detphys_kinematic_addCreates a kinematic body with a motion (with Box2D's angular speed limit lifted)detphys_kinematic.h
detphys_kinematic_bindGives an existing body a motiondetphys_kinematic.h
detphys_kinematic_checkWhether the world's values are bit-identical to the ones rebuilt from the functionsdetphys_kinematic.h
detphys_kinematic_clearRemoves all motions (the session calls this before begin)detphys_kinematic.h
detphys_kinematic_createCreates a kinematic table (one per world)detphys_kinematic.h
detphys_kinematic_descSplit settings (max_subticks 1–16, subtick_move_mm)detphys_kinematic.h
detphys_kinematic_desc_defaultDefault table settings (split up to 4 times, 20 mm)detphys_kinematic.h
detphys_kinematic_destroyDestroys itdetphys_kinematic.h
detphys_kinematic_get_statsSplit counts and other statisticsdetphys_kinematic.h
detphys_kinematic_poseA pose returned by a callback [µm, µrad]detphys_kinematic.h
detphys_kinematic_pose_atThe motion function's pose (also between ticks, for interpolated drawing)detphys_kinematic.h
detphys_kinematic_sessionSettings for passing a table to a session (flags NO_PRE_UPDATE / NO_SPLIT)detphys_kinematic.h
detphys_kinematic_session_defaultDefault settings for passing a table to a sessiondetphys_kinematic.h
detphys_kinematic_statsTable statisticsdetphys_kinematic.h
detphys_kinematic_stepAdvances one tick (instead of detphys_world_step; splits fast ticks, then updates)detphys_kinematic.h
detphys_kinematic_unbindRemoves a motiondetphys_kinematic.h
detphys_kinematic_updateSnaps to the current tick's pose and sets the velocity that reaches the next tickdetphys_kinematic.h
detphys_linkA link (opaque)detphys_link.h
detphys_link_abi_versionThe version of this header (DETPHYS_LINK_ABI_VERSION)detphys_link.h
detphys_link_closeLeaves the roomdetphys_link.h
detphys_link_createCreates a link from an implementation table (detphys_link_vtable), to plug in your own transportdetphys_link.h
detphys_link_create_hubCreates a link to the test lobbydetphys_link.h
detphys_link_create_loopbackA link wrapping one side of a loopbackdetphys_link.h
detphys_link_create_relayCreates a connection interface (detphys_link) through your own relay. Rooms work with detphys_link_host / detphys_link_joindetphys_relay.h
detphys_link_create_udpA link over UDP (detphys_udp.h). The role is chosen at creationdetphys_link.h
detphys_link_destroyDestroys it (leaves the room)detphys_link.h
detphys_link_errorText for the last failure (with NULL, why creating failed)detphys_link.h
detphys_link_get_infoState, role, path, reason, counters, room codedetphys_link.h
detphys_link_hostCreates a room (become the host). The room code is made, or yours is useddetphys_link.h
detphys_link_hubA test lobby (opaque)detphys_link.h
detphys_link_hub_createCreates / destroys a test lobbydetphys_link.h
detphys_link_hub_descTest lobby settings (time per operation, room limit, path to report, datagram limit, per-room transport)detphys_link.h
detphys_link_hub_desc_defaultDefault test lobby settingsdetphys_link.h
detphys_link_hub_pumpAdvances the test lobby's time by onedetphys_link.h
detphys_link_hub_room_countThe number of rooms nowdetphys_link.h
detphys_link_infoState, role, path, reason, round trip, datagram limit, largest datagram sent, counters, kind, room code, descriptions of the other side and yourselfdetphys_link.h
detphys_link_joinJoins a room with a room code (become the guest). Typos are returned before any trafficdetphys_link.h
detphys_link_pollCall every frame. Returns the current statedetphys_link.h
detphys_link_room_descRoom settings (members, bucket, room code, seed for making a code, timeout)detphys_link.h
detphys_link_room_desc_defaultDefault room settingsdetphys_link.h
detphys_link_state_nameASCII names of states and reasons (translation keys)detphys_link.h
detphys_link_transportGets the transport to pass to the session (the link counts what is sent and received)detphys_link.h
detphys_link_vtableAn implementation table (send, recv and get_info are required; poll, host, join, wait, error, close and destroy are optional)detphys_link.h
detphys_link_waitWaits until something can be received (headless tests)detphys_link.h
detphys_loopbackA loopback (opaque)detphys_turn.h
detphys_loopback_createCreates a loopback joining two peers in one processdetphys_turn.h
detphys_loopback_descDelay, loss and duplication rates, seeddetphys_turn.h
detphys_loopback_desc_defaultDefault loopback settings (no delay, no loss)detphys_turn.h
detphys_loopback_destroyDestroys itdetphys_turn.h
detphys_loopback_get_statsSent, dropped, duplicated, delivered countsdetphys_turn.h
detphys_loopback_pumpAdvances time by one (the unit of delay)detphys_turn.h
detphys_loopback_statsLoopback countersdetphys_turn.h
detphys_loopback_transportGets the transport of side 0 or 1detphys_turn.h
detphys_mesh_infoInformation about a registered shapedetphys_body.h
detphys_motion_descA motion (path DETPHYS_PATH_*, ease, position, spin, orbit, period, phase, points, callback)detphys_kinematic.h
detphys_motion_desc_defaultDefault motion (FIXED, SMOOTH)detphys_kinematic.h
detphys_motion_pointA POINTS point (position, angle, ticks to the next point)detphys_kinematic.h
detphys_relay_abi_versionVersion of this header (DETPHYS_RELAY_ABI_VERSION)detphys_relay.h
detphys_relay_descRelay host and port, local port, resend and PING intervals, timeout when nothing arrivesdetphys_relay.h
detphys_relay_desc_defaultDefault settings for connecting to the relaydetphys_relay.h
detphys_room_code_makeMakes a room code (six digits) from a seeddetphys_link.h
detphys_room_code_parseChecks typed text and normalizes it to six digits (skips full-width digits and separators; format error / check digit error)detphys_link.h
detphys_rt_abi_versionThis header's versiondetphys_rt.h
detphys_rt_advancePasses your input and advances one tick (rolling back and re-simulating if needed). Returns ADVANCED / STALLED / SYNC_WAIT / DELAY_WAITdetphys_rt.h
detphys_rt_auto_delayAutomatic input delay settingsdetphys_rt.h
detphys_rt_auto_delay_defaultDefault automatic input delay (off, 0–6, jitter × 1, raise after 500 ms, lower after 3000 ms)detphys_rt.h
detphys_rt_configSettings (session id, shapes, peer, world, input delay 0–30, prediction window 0–60, hash checks, snapshots, workers, network values)detphys_rt.h
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.h
detphys_rt_config_default3dFills session settings (snapshot FULL) and 3D world settings with defaults (either may be NULL)detphys_rt.h
detphys_rt_confirmedA confirmed tick recorddetphys_rt.h
detphys_rt_createCreates a session (creates the world, registers shapes, calls begin)detphys_rt.h
detphys_rt_create3dCreates a 3D session (NULL world settings = defaults). Then poll → advance → next_confirmed as in 2Ddetphys_rt.h
detphys_rt_create3d_kinematicSame as detphys_rt_create3d, also passing a 3D tabledetphys3d_kinematic.h
detphys_rt_create_kinematicSame, also passing a kinematic table (moving concave shapes)detphys_rt.h
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 failuredetphys_rt.h
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 failuredetphys_rt.h
detphys_rt_ctxValues passed to callbacks (world, params, state, tick, peer, re-simulating)detphys_rt.h
detphys_rt_ctx3dValues passed to callbacks (same layout as detphys_rt_ctx; only world is a detphys3d_world*)detphys_rt.h
detphys_rt_debug_bundlePacks a report and both recordings into a bundledetphys_rt.h
detphys_rt_debug_countNumber of reportsdetphys_rt.h
detphys_rt_debug_getReads a reportdetphys_rt.h
detphys_rt_debug_nudge_atTest only: shifts the state by 1 ULP after that tickdetphys_rt.h
detphys_rt_debug_statsRecording and exchange countersdetphys_rt.h
detphys_rt_destroyDestroys itdetphys_rt.h
detphys_rt_errorReason when in ERRORdetphys_rt.h
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)detphys_rt.h
detphys_rt_get_link_infoCurrent link and delay statusdetphys_rt.h
detphys_rt_get_resync_infoWhat was sent / received on resync and rejoin (counts, registry rebuilds, size, restore time). Works for 2D toodetphys_rt.h
detphys_rt_get_statsCounters for rollbacks, re-simulation, waits, hash checks, resyncs, bytes and timedetphys_rt.h
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 7detphys_rt.h
detphys_rt_kinematicThe kinematic table a session is moving (read only; NULL if none)detphys_rt.h
detphys_rt_kinematic3dThe 3D table a real-time session is moving (read only; NULL if none)detphys3d_kinematic.h
detphys_rt_link_infoLink and delay statusdetphys_rt.h
detphys_rt_next_confirmedTakes the oldest confirmed tick record (tick, hash), for replays and logsdetphys_rt.h
detphys_rt_next_input_tickThe tick the next advance's input goes todetphys_rt.h
detphys_rt_pollReads what arrived; sends acks and resync statedetphys_rt.h
detphys_rt_read_stateCurrent game state wordsdetphys_rt.h
detphys_rt_resync_infoResync status (dimensions 2 / 3, sent, received, registry_rebuilds, hull_replacements, last size, tick and time)detphys_rt.h
detphys_rt_ruleA rule (1–16 input words, 0–64 state words, params, begin, apply_inputs, after_tick, predict)detphys_rt.h
detphys_rt_rule3dA 3D rule (same layout as detphys_rt_rule; callbacks receive detphys_rt_ctx3d; 72 B)detphys_rt.h
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_rt.h
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_rt.h
detphys_rt_sessionA session (opaque)detphys_rt.h
detphys_rt_set_auto_delaySets automatic input delay (NULL = off)detphys_rt.h
detphys_rt_set_debugTurns the desync debugger on / offdetphys_rt.h
detphys_rt_set_link_idYour link iddetphys_rt.h
detphys_rt_statsSession countersdetphys_rt.h
detphys_rt_worldCurrent world (including predictions; read it for drawing)detphys_rt.h
detphys_rt_world3dThe current 3D world (includes prediction; read it for drawing). For 3D sessions detphys_rt_world returns NULLdetphys_rt.h
detphys_rule_ctxValues passed to callbacks (world, params, state, mover, turn, tick, settled)detphys_turn.h
detphys_rule_ctx3dValues passed to callbacks (same layout as detphys_rule_ctx; only world is a detphys3d_world*)detphys_turn.h
detphys_rule_push3d_auto_inputsThe samples' automatic inputs (ticks 0..ticks, 3 words per tick), for comparing with the reference hashesdetphys_rt.h
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_rt.h
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.h
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 sessiondetphys_rt.h
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)detphys_rt.h
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_rt.h
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.h
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 sessiondetphys_rt.h
detphys_rule_push_layoutThe body ID layout and the params size (88 or 120 bytes)detphys_rt.h
detphys_rule_stack_descDrop clearance, range, fall line, material, base boxes (1–16)detphys_turn.h
detphys_rule_stack_desc_defaultDefault stacking settings (base 7 m wide, 0.6 m high, top at y = 0; drop clearance 300 mm; x range ±5000 mm; fall line −1000 mm)detphys_turn.h
detphys_rule_stack_nextNext shape (mode SEED / INPUT, seed, draw UNIFORM / BAG, per_match, weights, preview 0–8)detphys_turn.h
detphys_rule_stack_next_defaultDefault next-shape settings (SEED, UNIFORM, a different sequence per match, equal weights, 2 shapes ahead)detphys_turn.h
detphys_rule_stack_next_shapeWith SEED, computes the shape of match m, turn t (no session needed)detphys_turn.h
detphys_shape_descOne shape (DETPHYS_SHAPE_MESH / BOX / CIRCLE, size, offset, material)detphys_body.h
detphys_shape_desc_defaultDefault shape settings (friction 600, density 1000, restitution 0, × 1000)detphys_body.h
detphys_snapshot_infoImage header (kind, size, body count, tick, base id)detphys.h
detphys_snapshot_read_infoReads a snapshot image header (no world needed)detphys.h
detphys_snapshot_statsSnapshot statistics (for tuning)detphys.h
detphys_tag_infoState of a peer whose config check does not match (136 B, the same as for rt; see the section below)detphys_turn.h
detphys_transportThe transport interface (send, recv and user). Implement this for Steam, EOS and so ondetphys_turn.h
detphys_turn_abi_versionThis header's versiondetphys_turn.h
detphys_turn_boxA static box [mm]detphys_turn.h
detphys_turn_checkpoint_statsGuest checkpoint statisticsdetphys_turn.h
detphys_turn_configSession settings (session id, shapes, peer, first mover, tick limit, world, network values)detphys_turn.h
detphys_turn_config_defaultDefault session settings (up to 900 ticks per turn, 5000 ms peer timeout, 20 ms minimum resend, 250 ms keepalive)detphys_turn.h
detphys_turn_create_ruleCreates a session with a ruledetphys_turn.h
detphys_turn_create_rule3dCreates a session from a 3D rule and 3D world settings (detphys3d_world_desc, NULL = defaults). The world is rebuilt for every matchdetphys_turn.h
detphys_turn_create_rule3d_kinematicSame as detphys_turn_create_rule3d, also passing a 3D table (emptied before begin_match of every match)detphys3d_kinematic.h
detphys_turn_create_rule_kinematicSame, also passing a kinematic table (moving concave shapes)detphys_turn.h
detphys_turn_create_stackCreates a session with that ruledetphys_turn.h
detphys_turn_create_stack_exCreates a stacking session (the easy way from C# and others)detphys_turn.h
detphys_turn_currentCurrent turn numberdetphys_turn.h
detphys_turn_current_moverCurrent moverdetphys_turn.h
detphys_turn_debug_bundlePacks a report and both recordings into a bundle (DNDB)detphys_turn.h
detphys_turn_debug_countNumber of reportsdetphys_turn.h
detphys_turn_debug_getReads a report (with the list of differences and the spread)detphys_turn.h
detphys_turn_debug_nudge_atTest only: shifts the state by 1 ULP at the start of that turndetphys_turn.h
detphys_turn_debug_statsRecording and exchange countersdetphys_turn.h
detphys_turn_descSettings, input, report and shape for the functions abovedetphys_turn.h
detphys_turn_desc_defaultCreate a session from stacking-only settings (uses the built-in stacking rule)detphys_turn.h
detphys_turn_destroyDestroys itdetphys_turn.h
detphys_turn_errorReason when in ERRORdetphys_turn.h
detphys_turn_get_checkpoint_statsCheckpoint counts, sizes and timesdetphys_turn.h
detphys_turn_get_link_statsRound trip, resends, bytes, …detphys_turn.h
detphys_turn_get_statusCurrent status (turn, match, mover, world replacement counter, time since the last packet, …)detphys_turn.h
detphys_turn_get_tag_infoReads what a peer with a mismatching config check sends (detphys_tag_info) / returns a part's name. Version 9. See the section belowdetphys_turn.h
detphys_turn_kinematic3dThe 3D table a turn-based session is moving (read only; NULL if none)detphys3d_kinematic.h
detphys_turn_link_statsNetwork statisticsdetphys_turn.h
detphys_turn_meshShape data (.dnshape bytes)detphys_turn.h
detphys_turn_next_reportTakes one turn's report (detphys_turn_report)detphys_turn.h
detphys_turn_next_resultTakes one finished turn's result (with inputs and state)detphys_turn.h
detphys_turn_pollReads what arrived, advances up to max_ticks, sends (resends by count; for in-process tests)detphys_turn.h
detphys_turn_poll_atSame, with the engine's monotonic clock [µs] (use this on real networks)detphys_turn.h
detphys_turn_read_stateReads the current match state wordsdetphys_turn.h
detphys_turn_resultOne turn's result (hashes, bytes, turn, mover, next mover, ticks, flags [DETPHYS_TURN_FLAG_*])detphys_turn.h
detphys_turn_ruleA rule (input and state word counts, params, begin_match, check_input, apply_input, after_tick, end_turn)detphys_turn.h
detphys_turn_rule3dA 3D rule (same layout as detphys_turn_rule; callbacks receive detphys_rule_ctx3d; 80 B)detphys_turn.h
detphys_turn_rule_stackWrites the stacking rule where the input picks the shape (3 input words)detphys_turn.h
detphys_turn_rule_stack_exWrites the stacking rule (with the next-shape settings)detphys_turn.h
detphys_turn_sessionA session (opaque)detphys_turn.h
detphys_turn_set_checkpoint_kindKind of the guest's per-turn checkpoint (FULL default / DYNAMIC / LEGACY)detphys_turn.h
detphys_turn_set_debugTurns the desync debugger on / off (detphys_debug_session_config)detphys_turn.h
detphys_turn_set_link_idYour link id (a different value after a restart)detphys_turn.h
detphys_turn_set_peer_timeoutPeer timeout (until PEER_LOST)detphys_turn.h
detphys_turn_set_timingMinimum resend time and keepalive intervaldetphys_turn.h
detphys_turn_stateCurrent state (DETPHYS_TURN_CONNECTING, WAIT_LOCAL_INPUT, WAIT_REMOTE_INPUT, SIMULATING, WAIT_HASH, WAIT_RESYNC, ERROR, DETPHYS_TURN_PEER_LOST)detphys_turn.h
detphys_turn_statusCurrent statusdetphys_turn.h
detphys_turn_submitSubmits a stacking input (shape, x, angle)detphys_turn.h
detphys_turn_submit_wordsSubmits the mover's input (int32 × input_words)detphys_turn.h
detphys_turn_worldCurrent world (read only)detphys_turn.h
detphys_turn_world3dThe current 3D world (read only). For 3D sessions detphys_turn_world returns NULLdetphys_turn.h
detphys_udpA socket (opaque)detphys_udp.h
detphys_udp_createCreates a socket (DETPHYS_UDP_LISTEN to listen / DETPHYS_UDP_CONNECT to connect; IPv4)detphys_udp.h
detphys_udp_descMode (LISTEN / CONNECT), address, port, buffer sizesdetphys_udp.h
detphys_udp_desc_defaultDefault settingsdetphys_udp.h
detphys_udp_destroyDestroys itdetphys_udp.h
detphys_udp_get_statsSent and received counts and so ondetphys_udp.h
detphys_udp_last_errorDescription of the last failuredetphys_udp.h
detphys_udp_peerCurrent peer address ("a.b.c.d:port")detphys_udp.h
detphys_udp_statsUDP countersdetphys_udp.h
detphys_udp_transportGets the transport to pass to a sessiondetphys_udp.h
detphys_udp_waitWaits until something can be received (for headless tests; engines poll every frame)detphys_udp.h
detphys_worldA world (opaque)detphys.h
detphys_world_add_bodyCreates a body. Returns its ID (creation-order serial number)detphys_body.h
detphys_world_add_meshCopies and registers a .dnshape. Returns its number (from 0)detphys_body.h
detphys_world_add_shapeAdds a shape to a bodydetphys_body.h
detphys_world_apply_forceApplies a force (mN, for the next tick only)detphys_body.h
detphys_world_apply_impulseApplies an impulse (mN·s, changes velocity at once)detphys_body.h
detphys_world_awake_countAwake dynamic bodies (0 = settled)detphys_body.h
detphys_world_body_countBodies created (including removed ones)detphys_body.h
detphys_world_body_shapesReads the shapes attached to a bodydetphys_body.h
detphys_world_createCreates a world (NULL = defaults). Same as detphys_world_create_ex(desc, NULL)detphys.h
detphys_world_create_exCreates a world with settings and worker settingsdetphys.h
detphys_world_descTick rate, substeps, gravity (mm/s²)detphys.h
detphys_world_desc_defaultDefault world settings (60 Hz, 4 substeps, gravity (0, −10000) mm/s²)detphys.h
detphys_world_destroyDestroys a worlddetphys.h
detphys_world_get_bodyReads one body's current statedetphys_body.h
detphys_world_get_optionsReads the worker settings used at creationdetphys.h
detphys_world_get_snapshot_statsBases held, shape version, write counts and so ondetphys.h
detphys_world_hashState hash (FNV-1a 64 over the tick, body count and raw bits of every body's position, rotation, velocity and angular velocity)detphys.h
detphys_world_mesh_countNumber of registered shapesdetphys_body.h
detphys_world_mesh_infoShape information (convex polygons, vertices, radius, checksum)detphys_body.h
detphys_world_mesh_readReads the convex polygons' vertices [m] for drawingdetphys_body.h
detphys_world_optionsWorker count (1–64), pool (DETPHYS_POOL_OWN / BOX2D / EXTERNAL), spin, base slots, engine job functionsdetphys.h
detphys_world_options_defaultDefault worker settings (1 worker, core pool, spin 4000, 4 bases)detphys.h
detphys_world_read_bodiesReads all bodies into an array (fine every frame; does not affect the simulation)detphys_body.h
detphys_world_remove_bodyRemoves a body (IDs are not compacted)detphys_body.h
detphys_world_set_transformSets position and angle directly (mm, mrad)detphys_body.h
detphys_world_set_velocitySets velocity (mm/s, mrad/s)detphys_body.h
detphys_world_snapshot_restoreRestores a snapshot (the tick and the body list come back too; restoring a full one always starts a new shape version, so the next dyn takes a new base)detphys.h
detphys_world_snapshot_sizeCounts the size of a snapshot of the current state (dyn / full)detphys.h
detphys_world_snapshot_writeWrites a snapshot into a caller buffer (takes a base here if a dyn has none)detphys.h
detphys_world_stepAdvances one tickdetphys.h
detphys_world_tickCurrent tick number (0 right after creation)detphys.h

Common conventions

  • Structs contain only fixed-width integers, floats and function pointers, with no implicit padding (C# StructLayout.Sequential reads them as is).
  • Structs with struct_size must have it set to sizeof. Fill settings with *_default before changing them.
  • Errors are return values (DETPHYS_OK = 0, negative = DETPHYS_ERR_*). Variable-size data (snapshots, recordings, bundles) is written into caller buffers; if a buffer is too small the call returns DETPHYS_ERR_CAPACITY with the needed size.
  • All values going in are integers (length mm, angle mrad, speed mm/s, force mN, impulse mN·s, materials × 1000; 3D orientations are integer quaternions).
Return valueMeaning
DETPHYS_OK (0)Success
DETPHYS_ERR_ARGUMENT (−1)NULL, out of range, wrong struct_size
DETPHYS_ERR_CAPACITY (−2)Caller buffer too small (*out_size holds the needed size)
DETPHYS_ERR_FORMAT (−3)Snapshot or recording has the wrong format or is broken (the world is unchanged)
DETPHYS_ERR_BASE (−4)The base of a dyn snapshot is missing (the world is unchanged)
DETPHYS_ERR_CORRUPT (−5)Restoring failed half way (destroy and recreate the world)
DETPHYS_ERR_INTERNAL (−6)Allocation or thread creation failed

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