public sealed class PhysicsWorldA simulated world: bodies, constraints, characters and the queries that ask about them.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is the whole engine-facing surface of Jolt. Nothing above it names a Jolt type, which is what makes the binding replaceable and what lets the API be shaped for Vixen's conventions — right-handed Y-up mathematics, handles rather than native objects, a fixed step it does not own.
It does not own the clock. Step takes a delta and does not accumulate, because the accumulator is Vixen.Engine.Frames.FixedStepAccumulator and there must be exactly one of it — a physics world that ran its own steps would drift from the simulation phase it is meant to be part of, and a replay would stop reproducing.
It is not thread-safe. Bodies are created, moved and queried from whichever thread drives the step, and Jolt's own parallelism lives inside Step. The one exception is the contact callbacks, which Jolt raises from its job threads; those are buffered under a lock and handed back on the calling thread once the step is over — see Contacts.
Fields and properties (16)
public int CharacterCountHow many character controllers this world has.
public ReadOnlySpan<ConstraintHandle> ConstraintHandlesEvery constraint in the world, in the order it was created.
public PhysicsShapes ShapesThe shapes bodies in this world may use.
public PhysicsLayers LayersThe layer table this world was built with.
public PhysicsWorldSettings SettingsHow the world was configured.
public Vector3 GravityGravity, in metres a second squared.
public int BodyCountHow many bodies exist, awake or asleep.
public int ActiveBodyCountHow many bodies are awake and being solved.
public int ConstraintCountHow many constraints exist.
public long StepCountHow many steps have been run.
public PhysicsStepResult LastStepResultWhat the last step ran into.
public bool IsDisposedWhether Dispose has been called.
public ReadOnlySpan<ContactEvent> ContactsEverything that touched, went on touching or stopped during the last step.
public ReadOnlySpan<TriggerEvent> TriggersEverything that entered or left a sensor during the last step.
public ReadOnlySpan<BodyHandle> ActivationsBodies that woke during the last step.
public ReadOnlySpan<BodyHandle> DeactivationsBodies that fell asleep during the last step.
Methods (54)
public BodyHandle CreateBody(in BodyDescription description)Creates a body and adds it to the simulation.
public void DestroyBody(BodyHandle handle)Removes a body from the simulation and frees it.
public bool IsAlive(BodyHandle handle)Whether a handle still names a body in this world.
public ulong UserDataOf(BodyHandle handle)Whatever was associated with a body when it was created.
public ShapeId ShapeOf(BodyHandle handle)The shape a body was created with.
public PhysicsLayer LayerOf(BodyHandle handle)Which layer a body is on.
public bool IsSensor(BodyHandle handle)Whether a body is a sensor.
public Vector3 GetPosition(BodyHandle handle)Where a body is.
public Quaternion GetRotation(BodyHandle handle)Which way a body faces.
public void GetTransform(BodyHandle handle, out Vector3 position, out Quaternion rotation)Where a body is and which way it faces, in one read.
public void SetTransform(BodyHandle handle, Vector3 position, Quaternion rotation, bool activate = true)Moves a body there at once, with no motion in between.
public void MoveKinematic(BodyHandle handle, Vector3 position, Quaternion rotation, float deltaTime)Drives a kinematic body towards a pose over one step, giving it the velocity to get there.
public Vector3 GetLinearVelocity(BodyHandle handle)A body's linear velocity, in metres a second.
public void SetLinearVelocity(BodyHandle handle, Vector3 velocity)Sets a body's linear velocity.
public Vector3 GetAngularVelocity(BodyHandle handle)A body's angular velocity, in radians a second about each axis.
public void SetAngularVelocity(BodyHandle handle, Vector3 velocity)Sets a body's angular velocity.
public void ApplyForce(BodyHandle handle, Vector3 force)Applies a force for the coming step, at the body's centre of mass.
public void ApplyForce(BodyHandle handle, Vector3 force, Vector3 point)Applies a force for the coming step, at a point in world space.
public void ApplyTorque(BodyHandle handle, Vector3 torque)Applies a torque for the coming step.
public void ApplyImpulse(BodyHandle handle, Vector3 impulse)Changes a body's momentum at once, at its centre of mass.
public void ApplyImpulse(BodyHandle handle, Vector3 impulse, Vector3 point)Changes a body's momentum at once, at a point in world space.
public void ApplyAngularImpulse(BodyHandle handle, Vector3 impulse)Changes a body's angular momentum at once.
public bool IsActive(BodyHandle handle)Whether a body is awake.
public void Activate(BodyHandle handle)Wakes a body.
public void Deactivate(BodyHandle handle)Puts a body to sleep.
public BodyMotion GetMotion(BodyHandle handle)How a body moves.
public void SetMotion(BodyHandle handle, BodyMotion motion, bool activate = true)Changes how a body moves.
public void SetMotionQuality(BodyHandle handle, BodyMotionQuality quality)Changes how carefully a body's motion is swept.
public void SetFriction(BodyHandle handle, float friction)Changes a body's friction.
public void SetRestitution(BodyHandle handle, float restitution)Changes a body's restitution.
public void SetGravityFactor(BodyHandle handle, float factor)Changes how much of the world's gravity acts on a body.
public void SetShape(BodyHandle handle, ShapeId shape, bool updateMass = true)Gives a body a different shape.
public BoundingBox GetBounds(BodyHandle handle)The axis-aligned bounds a body currently occupies.
public CharacterController CreateCharacter(CharacterControllerSettings settings)Creates a character controller in this world.
public ConstraintHandle CreateConstraint(in ConstraintDescription description)Creates a constraint between two bodies and adds it to the simulation.
public void DestroyConstraint(ConstraintHandle handle)Removes a constraint and frees it.
public bool IsAlive(ConstraintHandle handle)Whether a handle still names a constraint in this world.
public void SetConstraintEnabled(ConstraintHandle handle, bool enabled)Turns a constraint off without destroying it, or back on.
public ConstraintKind GetConstraintKind(ConstraintHandle handle)Which joint a constraint is.
public void GetConstraintAnchors(ConstraintHandle handle, out Vector3 first, out Vector3 second)Where a constraint's two anchors are now, in world space.
public Vector3 GetConstraintAxis(ConstraintHandle handle)The axis a constraint turns about or slides along, now, in world space.
public void GetConstraintBodies(ConstraintHandle handle, out BodyHandle first, out BodyHandle second)The two bodies a constraint holds.
public void SetConstraintMotor(ConstraintHandle handle, ConstraintMotor motor, float target)Changes a motorised constraint's target.
public PhysicsWorld(PhysicsWorldSettings? settings = null)Builds a world.
public PhysicsStepResult Step(float deltaTime)Advances the simulation by one step.
public void OptimizeBroadPhase()Rebuilds the broad phase from scratch, which is worth doing once after a level is loaded and never during play.
public void Dispose()public bool Raycast(Vector3 origin, Vector3 direction, float distance, out RayHit hit, QueryFilter filter = default(QueryFilter))Finds the first thing a ray hits.
public ReadOnlySpan<RayHit> RaycastAll(Vector3 origin, Vector3 direction, float distance, QueryFilter filter = default(QueryFilter))Finds everything a ray hits, nearest first.
public ReadOnlySpan<ShapeOverlap> Overlap(ShapeId shape, Vector3 position, Quaternion rotation = default(Quaternion), QueryFilter filter = default(QueryFilter))Finds everything a shape overlaps where it is put.
public ReadOnlySpan<ShapeOverlap> OverlapSphere(Vector3 centre, float radius, QueryFilter filter = default(QueryFilter))Finds everything a sphere overlaps.
public ReadOnlySpan<ShapeOverlap> OverlapBox(Vector3 centre, Vector3 halfExtents, Quaternion rotation = default(Quaternion), QueryFilter filter = default(QueryFilter))Finds everything a box overlaps.
public bool ShapeCast(ShapeId shape, Vector3 origin, Quaternion rotation, Vector3 motion, out ShapeCastHit hit, QueryFilter filter = default(QueryFilter))Sweeps a shape and reports where it first hits something.
public bool CheckPoint(Vector3 point, QueryFilter filter = default(QueryFilter))Whether a point is inside anything.
Used by (19)
- ArenaCameraOcclusionThirdPersonShooter
- WeaponFireThirdPersonShooter
- CharacterControllerVixen.Physics
- CharacterControllerTestsVixen.Physics.Tests
- HeightFieldShapeTestsVixen.Physics.Tests
- JoltMathTestsVixen.Physics.Tests
- LagCompensationTestsVixen.Net.Physics.Tests
- LagCompensatorVixen.Net.Physics
- PhysicsConstraintTestsVixen.Physics.Tests
- PhysicsDebugDrawVixen.Physics
- PhysicsDeterminismTestsVixen.Physics.Tests
- PhysicsLayerTestsVixen.Physics.Tests
- PhysicsOcclusionProviderVixen.Audio.Physics
- PhysicsOcclusionTestsVixen.Audio.Physics.Tests
- PhysicsQueryTestsVixen.Physics.Tests
- PhysicsSceneVixen.Physics
- PhysicsSceneTestsVixen.Physics.Tests
- PhysicsShapeTestsVixen.Physics.Tests
- PhysicsWorldTestsVixen.Physics.Tests