Skip to content

Decouple physics engine #2801

Open
Open
@LeXXik

Description

Currently, Ammo is deeply integrated into rigidbody and collision components, making it an integral part of the PC engine.
I would like to propose decoupling the physics engine into own backend provider.

backends/ammo

There would be no changes to the current components API. However, instead of processing the physics inside the component, a component would call appropriate method of the currently selected backend. For now, it would be Ammo.

For example, when a user does rigidbody.teleport(pos, rot), the component would call backend.teleport(pos, rot). Most of the general purpose physics engines do their simulations through iterating simulation steps, so their features are similar. PC component can abstract away the inner workings of the one or another backend. If some physics engine doesn't support a feature, it is easy for the backend to notify a user.

This makes it trivial to add support and switching to another physics engine:

backends/physx
backends/rapier
backends/...

It also makes it easier for the games to implement and add custom physics engine - it would be simply a matter of adding another backend. All backends could have the same API signature, which would make PC agnostic about which backend is currently handling the physics simulation.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions