PhysicsSimulation class abstract

The backend driver contract, a physics engine addressed by integer handles, decoupled from any scene graph through PoseTargets.

Engine layers (flutter_scene's component layer, headless servers) own the mapping from handles to their objects. Backends implement stepping, queries, and events; unsupported capabilities throw UnsupportedError and are advertised through the supports* getters where callers need to branch.

Constructors

PhysicsSimulation()

Properties

backendName String
Identifier of the concrete backend, suitable for logging (for example "rapier3d").
no setter
collisions Stream<SimCollisionEvent>
Collision lifecycle events, keyed by collider handle.
no setter
fixedTimestep double
Length of one physics step, in seconds.
getter/setter pair
gravity ↔ Vector3
World-space acceleration applied to every dynamic body each step.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
maxSubsteps int
Maximum number of fixed steps consumed per frame by the driver.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportsCharacters bool
no setter
supportsJoints bool
no setter

Methods

applyAngularImpulse(int bodyHandle, Vector3 impulse) → void
applyForce(int bodyHandle, Vector3 force, {Vector3? atWorldPoint}) → void
applyImpulse(int bodyHandle, Vector3 impulse, {Vector3? atWorldPoint}) → void
applyTorque(int bodyHandle, Vector3 torque) → void
createAnchorBody() int
Creates an invisible fixed body for anchoring world-space joints.
createBody({required PoseTarget target, required BodyType type, double? additionalMass}) int
Creates a body at target's current pose and returns its handle. Dynamic bodies write their simulated pose back to target during interpolatePoses.
createColliders(int bodyHandle, Shape shape, {PhysicsMaterial material = PhysicsMaterial.defaultMaterial, bool isTrigger = false, Matrix4? localPose, int collisionLayer = 0xFFFFFFFF, int collisionMask = 0xFFFFFFFF}) List<int>
Creates collision geometry on bodyHandle and returns one handle per created collider (compound shapes may decompose; how is backend private). Empty means the shape is unsupported by this backend.
createJoint(JointDesc desc) int
destroyAnchorBody(int bodyHandle) → void
destroyBody(int bodyHandle) → void
destroyCollider(int colliderHandle) → void
destroyJoint(int jointHandle) → void
dispose() → void
Releases every body, collider, and joint. Called by owners when the simulation is discarded.
interpolatePoses(double alpha) → void
Writes interpolated dynamic-body poses to their PoseTargets. alpha is the accumulator fraction in [0, 1], 0 the previous step, 1 the current step.
isBodySleeping(int bodyHandle) bool
moveCharacter(int colliderHandle, {required Vector3 position, required Vector3 desiredTranslation, double? deltaSeconds, Vector3? up, double offset = 0.01, bool slide = true, double maxSlopeClimbAngle = 0.7853981633974483, double minSlopeSlideAngle = 0.7853981633974483, double? snapToGround = 0.1, bool autostep = false, double autostepMaxHeight = 0.3, double autostepMinWidth = 0.1, bool autostepIncludeDynamicBodies = true, double characterMass = 0.0}) CharacterMovement
Kinematic character move-and-slide against colliderHandle's surroundings. See the flutter_scene character controller for the parameter semantics.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overlapBox(Vector3 center, Vector3 halfExtents, Quaternion rotation, {int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) List<SimOverlapHit>
overlapSphere(Vector3 center, double radius, {int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) List<SimOverlapHit>
raycast(Ray ray, {double maxDistance = double.infinity, int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) → SimRaycastHit?
raycastAll(Ray ray, {double maxDistance = double.infinity, int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) List<SimRaycastHit>
readBodyAngularVelocity(int bodyHandle) → Vector3
readBodyLinearVelocity(int bodyHandle) → Vector3
readBodyPose(int bodyHandle) → (Vector3, Quaternion)
setBodyAdditionalMass(int bodyHandle, double mass) → void
setBodyAngularDamping(int bodyHandle, double damping) → void
setBodyAngularVelocity(int bodyHandle, Vector3 velocity) → void
setBodyAxisLocks(int bodyHandle, Vector3 linear, Vector3 angular) → void
Per-axis motion factors in [0, 1], 1 free, 0 locked.
setBodyCcdEnabled(int bodyHandle, bool enabled) → void
setBodyGravityScale(int bodyHandle, double scale) → void
setBodyKind(int bodyHandle, BodyType type) → void
setBodyKinematicTargetPose(int bodyHandle, Vector3 translation, Quaternion rotation) → void
Pushes the pose a kinematic body should reach by the next step.
setBodyLinearDamping(int bodyHandle, double damping) → void
setBodyLinearVelocity(int bodyHandle, Vector3 velocity) → void
setColliderFilter(int colliderHandle, int layer, int mask) → void
setColliderMaterial(int colliderHandle, PhysicsMaterial material) → void
shapeCast(Shape shape, Matrix4 from, Vector3 direction, double distance, {int layerMask = 0xFFFFFFFF, bool includeFixed = true, bool includeKinematic = true, bool includeDynamic = true, bool includeTriggers = false}) → SimShapeCastHit?
sleepBody(int bodyHandle) → void
step(double fixedDt) → void
Advances the simulation by exactly fixedDt seconds.
toString() String
A string representation of this object.
inherited
updateJoint(int jointHandle, JointDesc desc) → void
Reconfigures a joint in place. Backends without native updates may destroy and recreate internally; the handle stays valid.
wakeBody(int bodyHandle) → void

Operators

operator ==(Object other) bool
The equality operator.
inherited