PhysicsEngine

The entry point to the physics system; an engine represents the manager of all physics resources and structures. An engine is tied to a specific physics backend, and allows creating native objects to interface with the physics backend.

The units used throughout the engine are metric: meters, radians, seconds, kilograms.

Thread safety

Physics structures used by the engine are not thread-safe, so must be treated carefully when interacting with them from multiple threads. Typically, the user of e.g. a PhysicsSpace or RigidBody would wrap accesses to that object in a lock. To enforce this, you can specify a java.util.concurrent.locks.ReentrantLock on some structures. Before any read or write access, this lock will be checked to make sure the current thread holds an exclusive lock. If it does not, an exception will be thrown.

Types

Link copied to clipboard
interface Builder

Utility class for building a PhysicsEngine, allowing defining properties required for the engine.

Properties

Link copied to clipboard
abstract val name: String

A human-readable, branded name for the physics backend.

Link copied to clipboard
abstract val version: String

A human-readable version string for the physics backend. This is not required to follow any conventions like SemVer.

Functions

Link copied to clipboard
abstract fun createBody(type: RigidBodyType, position: DIso3): RigidBody.Own

Creates a RigidBody with default parameters, which is not attached to any PhysicsSpace.

Link copied to clipboard
abstract fun createCollider(shape: Shape, position: Collider.Start): Collider.Own

Creates a Collider with default parameters, which is not attached to any RigidBody or PhysicsSpace.

Link copied to clipboard
abstract fun createJoint(): Joint

Creates a Joint with default parameters, which is not attached to any RigidBody or PhysicsSpace.

Link copied to clipboard
abstract fun createShape(geom: Geometry): Shape

Creates a baked, physics-ready form of a Geometry, which starts with a reference count of 1. See RefCounted for information on using ref-counted objects.

Link copied to clipboard
abstract fun createSpace(settings: PhysicsSpace.Settings = PhysicsSpace.Settings()): PhysicsSpace

Creates an independent container for physics structures from the specified settings.

Link copied to clipboard
abstract fun destroy()
Link copied to clipboard
abstract fun stepSpaces(dt: Double, spaces: Collection<PhysicsSpace>)

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