The Joly Physics Engine is a cross platform physics engine that powers the game Horizon Forbidden West. It is open source under the MIT license. The reasoning behind the creation of the Jolt Physics engine was as follows:
So why create yet another physics engine? First of all, this has been a personal learning project and secondly I wanted to address some issues that I had with existing physics engines:
- In games we usually need to do many more things than to simulate the physics world and we need to do this across multiple threads. We therefore place a lot of emphasis on concurrently accessing the physics simulation data outside of the main physics simulation update:
- Sections of the world can be loaded / unloaded in the background. A batch of physics bodies can be prepared on a background thread without locking or affecting the physics simulation and then inserted into the world all at once with a minimal impact on performance.
- Collision queries can run in parallel with other operations like insertion / removal of bodies. The query code is guaranteed to see a body in a consistent state, but when a body is changed during a collision query there is no guarantee if the change is visible to the query or not. If a thread modifies the position of a body and then does a collision query, it will immediately see the updated state (this is often a problem when working with a read version and a write version of the world).
- It is also possible to run collision queries in parallel to the main physics simulation by doing the broad phase query before the simulation step. This way, long running processes (like navigation mesh generation) can be spread out across multiple frames while still running the physics simulation every frame.
- One of the main sources of performance problems we found was waking up too many bodies while loading / unloading content. Therefore, bodies will not automatically wake up when created and neighboring bodies will not be woken up when bodies are removed. This can be triggered manually if desired.
- The simulation runs deterministically, so you could replicate a simulation to a remote client by merely replicating the inputs to the simulation. Read the Deterministic Simulation section to understand the limits of this.
- The simulation of this physics engine tries to simulate behavior of rigid bodies in the real world but makes approximations in the simulation so should mainly be used for games or VR simulations.
Jolt just released Jolt Physics 4.0, with the following features:
- Added support for soft bodies (feature still in development, see announcement).
- Support for limiting the degrees of freedom of a body to support 2D simulations (see announcement).
- Support for setting surface velocity of a body (see announcement).
- Added ability to update a height field after creation (see announcement).
- Support for non-power of 2 height fields.
- Expose a function to compare the JOLT_VERSION_ID with the version the library was compiled with to detect mismatches between library and client code.
- Added ability to specify extra ragdoll constraints that are not parent/child related.
- Ability to selectively save the state of a physics system to support replicating state over the network.
- Added constraint priority to control the order of evaluation of constraints (and thereby the most influential constraints).
- Sensors can now detect static objects.
- Ability to override mass and inertia of bodies from the ContactListener.
- Ability to specify stiffness/damping for springs instead of frequency/damping.
- Added option to disable the lean spring controller for motorcycles.
- Added vehicle callbacks at the beginning of the step listener and after wheel checks.
- Ability to override the position where the suspension and tire forces are applied.
- Support for building Jolt as a shared library on Windows.
- Optimized Indexify function from O(N^2) to O(N log(N)).
Key Links
Other physics engines mentioned in the video:
You can learn more about the Jolt physics system and see it in action in the video below.