Contacts
Reads ENTER, STAY, and EXIT events produced by the physics simulation.
Native contact callbacks are copied into a bounded thread-safe queue. jolt_update() drains that queue into a world event list and into per-body lists for the most recently processed frame.
Event constants#
| Constant | Value | Meaning |
|---|---|---|
| JOLT_COLLISION_ENTER | 1 | A body/sub-shape pair started touching |
| JOLT_COLLISION_STAY | 2 | The pair persisted during a simulation step |
| JOLT_COLLISION_EXIT | 3 | The active pair stopped touching |
High-Level API#
var world_events = jolt_get_collisions();
var body_events = body.get_collisions();
var dropped = jolt_get_dropped_collision_count();World event fields#
| Field | Description |
|---|---|
| type | ENTER, STAY, or EXIT constant |
| body_a / body_b | Managed JoltBody values when still known |
| body_a_handle / body_b_handle | Raw generational handles |
| body_a_valid / body_b_valid | Whether the high-level body lookup succeeded |
| position | World-space midpoint of the first available manifold point pair |
| normal | World-space native manifold normal in body_a/body_b order |
| penetration_depth | Native manifold penetration; EXIT is forced to 0 |
| body_a_sensor / body_b_sensor | Separate sensor flags |
| user_data_a / user_data_b | Current GML user_data or undefined |
Per-body event fields#
| Field | Description |
|---|---|
| type | ENTER, STAY, or EXIT |
| body | The JoltBody whose list is being read |
| other_body | Other managed JoltBody, when valid |
| entity / other_entity | GML user_data values |
| other_handle / other_valid | Raw handle and lookup state |
| position / normal / penetration_depth | Contact geometry |
| sensor | True when either body is a sensor |
For body_b, the wrapper negates the native normal so each body's list has the opposite orientation. A world event retains the native body_a/body_b ordering.
Queue behaviour and limits#
- The native queue holds at most 4096 events.
- When full, the oldest event is removed and the dropped counter increases.
- The active-contact map is keyed by both BodyIDs and both SubShapeIDs, so compounds can produce distinct sub-shape pairs.
- EXIT reuses the last stored contact position and normal and sets penetration_depth to 0.
- Only the first available manifold point pair is exposed by the public event.
Typical loop#
var events = jolt_get_collisions();
for (var i = 0; i < array_length(events); ++i) {
var event = events[i];
switch (event.type) {
case JOLT_COLLISION_ENTER: break;
case JOLT_COLLISION_STAY: break;
case JOLT_COLLISION_EXIT: break;
}
}Low-Level / Advanced API#
jolt_world_collision_next(world)
jolt_world_collision_get_dropped_count(world)
jolt_world_collision_clear(world)collision_next() pops one copied event and returns undefined when empty. collision_clear() removes queued events and resets the dropped counter; the managed runtime normally drains automatically.
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| jolt_get_collisions | jolt_get_collisions() | Managed events from latest drain after jolt_update / dropped-event count. Read after update; not a query for all current overlaps. |
| jolt_get_dropped_collision_count | jolt_get_dropped_collision_count() | Managed events from latest drain after jolt_update / dropped-event count. Read after update; not a query for all current overlaps. |
| jolt_layer_set_collision | jolt_layer_set_collision(layer_a, layer_b, enabled) | Two live same-world layers + enabled → Boolean. Sets pair collision matrix, not a query mask. |
| JoltBody.get_collisions | JoltBody.get_collisions() | Managed event array from the latest jolt_update; not a persistent overlap list. |