Shape Resources
Resource Lifetime
The wrapper, cache and bodies hold separate native references. Destroying a JoltShape releases its wrapper reference; cached entries and already-created bodies can retain geometry. Clearing the cache therefore does not guarantee that all geometry memory is freed immediately.
| API | Contract |
|---|---|
| shape.is_valid() | Checks the live resource; false after destruction or world teardown. |
| shape.get_native_handle() | Opaque handle, or zero if invalid. Do not treat it as a pointer. |
| shape.destroy() | Idempotent release; the wrapper cannot be reused for new bodies or queries afterwards. |
// If retained across events:
if (!is_undefined(shape)) {
shape.destroy();
shape = undefined;
}
// Central controller Cleanup event:
jolt_stop();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 |
|---|---|---|
| JoltShape._create | JoltShape._create(motion, x, y, z, options) | Creates a new JoltBody/undefined, XYZ defaults 0, standard Body options. Mesh/Heightfield/Plane Static only; resource remains reusable. _create is an implementation delegate with explicit motion; applications should use create_* variants. |
| JoltShape.destroy | JoltShape.destroy() | Native validation returns Boolean, handle or0. Destroy idempotent Boolean releases resource handle; existing bodies/compounds retain native references and remain live. |
| JoltShape.get_native_handle | JoltShape.get_native_handle() | Native validation returns Boolean, handle or0. Destroy idempotent Boolean releases resource handle; existing bodies/compounds retain native references and remain live. |
| JoltShape.is_valid | JoltShape.is_valid() | Native validation returns Boolean, handle or0. Destroy idempotent Boolean releases resource handle; existing bodies/compounds retain native references and remain live. |