drainEvents method
What happened since the last drain, oldest first.
Implementation
@override
List<PhysicsEvent3D> drainEvents() {
if (_gone) return const [];
final out = <PhysicsEvent3D>[];
while (true) {
final n = jj_drain_events(handle, _events, _eventCapacity);
for (var i = 0; i < n; i++) {
final e = _events[i];
if (e.type < 1 || e.type > _eventTypes.length) continue;
out.add(
PhysicsEvent3D(
_eventTypes[e.type - 1],
e.bodyA,
e.bodyB,
point: Vector3(e.point[0], e.point[1], e.point[2]),
normal: Vector3(e.normal[0], e.normal[1], e.normal[2]),
depth: e.depth,
),
);
}
if (n < _eventCapacity) break;
if (_eventCapacity < 8192) {
_drop(_events);
_eventCapacity *= 2;
_events = _alloc<JJ_Event>(_eventCapacity);
}
}
return out;
}