JoltWorld constructor
JoltWorld(
- PhysicsWorldSettings3D settings
Makes a world as settings say. Throws a StateError when Jolt
cannot (it was not initialised).
Implementation
JoltWorld(PhysicsWorldSettings3D settings)
: _gravity = Vector3.copy(settings.gravity) {
final s = _alloc<JJ_WorldSettings>();
s.ref
..gravity[0] = settings.gravity.x
..gravity[1] = settings.gravity.y
..gravity[2] = settings.gravity.z
..maxBodies = settings.maxBodies
..reportContactStay = settings.reportContactStay
..reportActivation = settings.reportActivation
// The less bouncy of the two bodies, as in the 2-D engines.
..restitutionCombine = JJ_COMBINE_MIN;
for (var i = 0; i < 16; i++) {
s.ref.collides[i] = settings.layerMasks[i];
}
handle = jj_world_create(s);
if (handle == 0) throw StateError('Jolt could not make a world.');
_worldFinalizer.attach(this, Pointer.fromAddress(handle), detach: this);
_tag = jj_world_handle_tag(handle);
_bodyInterface = JPH_PhysicsSystem_GetBodyInterface(jj_world_joltc(handle));
}