stepSpaces

abstract fun stepSpaces(dt: Double, spaces: Collection<PhysicsSpace>)

Simulates an update for a collection of spaces in parallel, with the given time step.

Due to the implementation of physics spaces, a space can only be stepped a whole interval at once - you cannot start a step, then wait for it to finish later (this would allow starting multiple steps for different spaces at once, then waiting for all of them at the same time). However, through a specialized native function, we can achieve the same effect if we provide all the spaces that we want to step upfront.

Stages

The update step of a physics engine is typically split into:

  • Broad-phase - collision pairs are generated between all Colliders, using a bounding volume hierarchy to accelerate these queries. These pairs are coarse, and do not guarantee that two bodies did actually collide.

  • Narrow-phase - all collision pairs previously generated are checked to see if they actually collided, and if so, compute the contacts and forces necessary in order to resolve them.

Parameters

dt

The time step to simulate, in seconds.

spaces

The spaces to step.