API
API
C
API reference (Physics events) — Alpha (1.14.2)

Defold Learn logo


Physics events

Native physics-world notifications delivered through the extension broadcast. Defold owns simulation, collision objects and transform synchronization.

Include: #include <dmsdk/physics/physics_event.h>
CONSTANTS
PHYSICS_EVENT_POST_STEP physics world step completed
STRUCTS
struct PhysicsEvent native physics world event

Structs

PhysicsEvent

TYPE

struct PhysicsEvent

Payload for PHYSICS_EVENT_POST_STEP with data_size equal to sizeof(PhysicsEvent). Interpret m_World using the physics backend configured for the project and build. Legacy Defold Box2D supplies a b2World pointer, Box2D 3 a pointer to a b2WorldId value, and Bullet a btDiscreteDynamicsWorld pointer. For Box2D 3, copy the b2WorldId value from the supplied pointer. Native headers and libraries must match the backend bundled with this SDK. The payload and native world access are borrowed only during the callback. Read native event buffers and perform queries using that backend's own API. Do not step or destroy the world, destroy Defold-managed bodies, replace reserved user data or callbacks, or invalidate event buffers for other listeners. Defer destructive changes through Defold's normal lifecycle operations. Delivery order between extensions is unspecified. This event cannot change contact response for the completed step; that requires the backend's own pre-solve mechanism.

MEMBERS

const void* m_World borrowed native world access for the configured physics backend
float m_Dt time-scaled world update interval in seconds; native simulated time can differ


Constants

PHYSICS_EVENT_POST_STEP

Event identifier for PhysicsEvent notifications after each Defold physics-world update. Delivery is synchronous on the engine thread after native stepping and game-object world-transform propagation, before the collection's queued message dispatch. Fixed updates publish once per completed world update; paused or skipped world updates do not publish. A backend can perform zero or multiple internal simulation substeps in one world update, as Bullet does with fixed substeps. These substeps do not publish separate events. m_Dt carries the supplied world update interval; the amount of native simulation time advanced can differ.