Constraints
Point Constraint
Keeps one material point on each body coincident while leaving all relative rotation free.
Point is the simplest ball-and-socket style connection. It uses one shared world-space anchor at creation, stores a local attachment for each body, and does not impose angular limits or a motor.
Syntax#
jolt_point(body_a, body_b, anchor_x, anchor_y, anchor_z, options=undefined)
jolt_point_world(body, anchor_x, anchor_y, anchor_z, options=undefined)Arguments and options#
| Name | Default | Description |
|---|---|---|
| body_a / body_b | required | Two different live managed bodies. |
| body | required | Single body used by the world variant. |
| anchor_x / anchor_y / anchor_z | required | Shared finite world-space attachment point. |
| collision | true | Body-to-body only: whether the pair may collide. |
| enabled | true | Initial solver state. |
Methods#
| Method | Result | Point behaviour |
|---|---|---|
| is_valid() | Boolean | Checks the managed wrapper and its native generational handle. |
| get_native_handle() | Real | Returns the opaque native handle, or 0 when invalid. |
| destroy() | Boolean | Idempotently releases only the constraint; connected bodies remain alive. |
| set_enabled(enabled) / get_enabled() | Boolean | Temporarily removes or restores solver participation without destroying the constraint. |
| set_collision_enabled(enabled) / get_collision_enabled() | Boolean | Controls collision for a body pair. World variants always report false. |
| get_impulse() | Real | Magnitude of the three-axis positional solver impulse from the latest update. |
Example: pendulum#
var support = jolt_box_create_static(0, 0, 6, 0.5, 0.5, 0.5);
var weight = jolt_box_create_dynamic(0, 0, 3, 0.8, 0.8, 0.8, { mass: 4 });
var joint = jolt_point(support, weight, 0, 0, 5.5, {
collision: false
});
weight.add_impulse(4, 0, 0);World variant#
var ball = jolt_sphere_create_dynamic(0, 0, 3, 0.5, { mass: 2 });
var pivot = jolt_point_world(ball, 0, 0, 4);Errors and lifecycle#
- Body-to-body creators require two different live managed JoltBody values in the same managed default world.
- At least one connected body must be movable; native Jolt rejects an unsupported static-static pair.
- Constructors return a managed JoltConstraint on success or undefined after a validation/native creation failure.
- Destroying either attached body automatically destroys and invalidates the constraint before releasing that body.
- Read jolt_get_error() after a failed creator or method when the values may be untrusted.
- The shared anchor must be finite.
- Point has no limits, spring or motor methods; calling a type-incompatible JoltConstraint method records an invalid-operation error.
- An off-centre anchor naturally lets constraint force generate torque on a body.
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_point | jolt_point(body_a, body_b, anchor_x, anchor_y, anchor_z, options = undefined) | Returns JoltConstraint/undefined, does not own bodies. Two distinct live same-world bodies; _world variant one Dynamic body and fixed world. Enabled defaults true; ordinary two-body collision defaults true unless specified otherwise below. Also check jolt_has_error after creation: some subsequent options can fail while returning the created constraint. Shared world XYZ anchor m, free rotation. |
| jolt_point_world | jolt_point_world(body, anchor_x, anchor_y, anchor_z, options = undefined) | Returns JoltConstraint/undefined, does not own bodies. Two distinct live same-world bodies; _world variant one Dynamic body and fixed world. Enabled defaults true; ordinary two-body collision defaults true unless specified otherwise below. Also check jolt_has_error after creation: some subsequent options can fail while returning the created constraint. Shared world XYZ anchor m, free rotation. |