PhysicsSystem
- Module
- Physics
- Header
#include "Physics/PhysicsSystem.h"- Namespace
Mowo
Public functions
| Returns | Name | Description |
|---|---|---|
void | Initialize | |
void | Shutdown | |
void | Update | |
PhysicsWorld& | GetPhysicsWorld | |
FPhysicsSnapshotRing& | GetSnapshotRing | The whole-world snapshots gameplay captures for rollback and resimulation. |
float | GetDiscardedSimulationTime | Simulation time the substep cap (p.MaxSubsteps) refused to run, and how many frames hit the cap. |
uint32_t | GetSubstepCapHits | |
float | GetFixedTimestep | |
void | SetFixedTimestep | |
uint32_t | GetAsyncStepsInFlight | p.AsyncTick: fixed steps this Update handed to a worker and has not yet joined. |
bool | IsAsyncStepInFlight | |
bool | IsDuringPhysicsOverlapEnabled | p.OverlapDuringPhysics (on by default): UE's StartPhysics / EndPhysics. |
bool | BeginFrameStep | |
void | EndFrameStep | |
MulticastDelegate<const FConstraintBreakInfo&>& | OnConstraintBroken | Raised the fixed step a ConstraintComponent crossed its break threshold, after the joint is gone and broken is set. |
void | ReleaseConstraint | |
void | SetSimulationFocus | Simulation LOD: dynamic bodies beyond the sleep radius around the focus are force-deactivated; they wake when the focus comes back within the (smaller) wake radius. |
void | ClearSimulationFocus | |
size_t | GetLodFrozenCount | Bodies currently frozen by the simulation LOD. |
uint32_t | GetLodBodiesExaminedLastUpdate | Bodies the last LOD pass looked at: the active ones, plus the frozen set on a frame the focus moved. |
void | ShiftOrigin | Origin rebasing: translate every Jolt body and character controller by -shift, velocities untouched. |
bool | StepCharacter | Advance ONE character controller by dt outside the fixed-step loop: integrates gravity into the component's linearVelocity, runs the Jolt ExtendedUpdate against the live collision world, and writes the result back to the component + transform. |
bool | SetCharacterPosition | Teleport a character controller (and its transform) — the rewind half of the prediction reconcile. |
const CharacterController* | GetCharacterController | The live controller behind an entity, nullptr when none — diagnostics and the self-tests (capsule shape state isn't mirrored on the component). |
FPhysicsBodyId | GetQueryBodyForEntity | The body a query originating ON this entity must exclude: its rigid body if it has one, otherwise its character controller's inner body. |
uint64_t | GetEntityForBody | Look up EntityID for a physics body (returns INVALID_ENTITY if not found) |
size_t | GetRegisteredBodyCount | Bodies this system has registered — RigidBody bodies, character inner bodies and implicit statics alike. |
bool | GetBodyInterpolation | |
float | GetInterpolationAlpha | |
MulticastDelegate<uint64_t, const CollisionInfo&>& | OnCollisionEnterEvents | The single-slot callbacks above belong to whichever system claimed them (the interactable system owns collision enter). |
void | SetOnCollisionEnter | |
void | SetOnCollisionStay | |
void | SetOnCollisionExit | |
void | SetOnTriggerEnter | |
void | SetOnTriggerStay | |
void | SetOnTriggerExit | |
FPhysicsBodyId | GetImplicitStaticBody | The static body this system created for a collider that carries no RigidBody, if any. |
size_t | GetImplicitStaticBodyCount | |
uint64_t | GetImplicitStaticPoseReadCount | How many times an implicit static's world pose has been re-derived from its transform since the system started. |
Function details
Initialize
void Initialize(World* world) overrideShutdown
void Shutdown() overrideUpdate
void Update(float deltaTime) overrideGetPhysicsWorld
PhysicsWorld& GetPhysicsWorld()GetSnapshotRing
FPhysicsSnapshotRing& GetSnapshotRing()The whole-world snapshots gameplay captures for rollback and resimulation. Empty and unsized until first asked for: its capacity comes from p.SnapshotFrames, and nothing is recorded unless something captures.
GetDiscardedSimulationTime
float GetDiscardedSimulationTime() constSimulation time the substep cap (p.MaxSubsteps) refused to run, and how many frames hit the cap. Both stay zero on a healthy frame budget.
GetSubstepCapHits
uint32_t GetSubstepCapHits() constGetFixedTimestep
float GetFixedTimestep() constSetFixedTimestep
void SetFixedTimestep(float timestep)GetAsyncStepsInFlight
uint32_t GetAsyncStepsInFlight() constp.AsyncTick: fixed steps this Update handed to a worker and has not yet joined. Non-zero between one Update's return and the next one's start; every PhysicsWorld entry point that reaches Jolt joins on its own.
IsAsyncStepInFlight
bool IsAsyncStepInFlight() constIsDuringPhysicsOverlapEnabled
static bool IsDuringPhysicsOverlapEnabled()p.OverlapDuringPhysics (on by default): UE's StartPhysics / EndPhysics. The scene kicks the frame's steps onto a worker after the PrePhysics tick group, ticks DuringPhysics while Jolt runs, then joins — instead of the step running inside Update with the game thread waiting. EndFrameStep runs Update's post-step half, so the Update that follows in the same frame does nothing. BeginFrameStep returns false (Update does it all) when the overlap is off or p.AsyncTick owns the step. The scene runs the world systems ordered ahead of this one (World::UpdateBefore) before the kick, so movement input still lands on this frame's step.
BeginFrameStep
bool BeginFrameStep(float deltaTime)EndFrameStep
void EndFrameStep()OnConstraintBroken
MulticastDelegate<const FConstraintBreakInfo&>& OnConstraintBroken()Raised the fixed step a ConstraintComponent crossed its break threshold, after the joint is gone and broken is set. The same payload rides the EventBus as ConstraintBrokenEvent for listeners that never see this system (audio, VFX, replication).
ReleaseConstraint
void ReleaseConstraint(ConstraintComponent& constraint, bool clearBroken)SetSimulationFocus
void SetSimulationFocus(const Vec3& position)Simulation LOD: dynamic bodies beyond the sleep radius around the focus are force-deactivated; they wake when the focus comes back within the (smaller) wake radius. No focus = no LOD. Radii override via p.LODSleepRadius / p.LODWakeRadius, kill switch via p.LOD.
ClearSimulationFocus
void ClearSimulationFocus()GetLodFrozenCount
size_t GetLodFrozenCount() constBodies currently frozen by the simulation LOD. Diagnostic (and the self-tests pin that destroyed entities don't linger here).
GetLodBodiesExaminedLastUpdate
uint32_t GetLodBodiesExaminedLastUpdate() constBodies the last LOD pass looked at: the active ones, plus the frozen set on a frame the focus moved. Diagnostic — a settled world reads zero.
ShiftOrigin
void ShiftOrigin(const Vec3& shift)Origin rebasing: translate every Jolt body and character controller by -shift, velocities untouched. Callers (Scene) shift the transform components; this keeps the physics mirror aligned.
StepCharacter
bool StepCharacter(uint64_t entityId, float dt)Advance ONE character controller by dt outside the fixed-step loop: integrates gravity into the component's linearVelocity, runs the Jolt ExtendedUpdate against the live collision world, and writes the result back to the component + transform. Game-thread only, never while Update is running — the client-prediction replay path steps a rewound character through the still-unacked inputs with this.
SetCharacterPosition
bool SetCharacterPosition(uint64_t entityId, const Vec3& position)Teleport a character controller (and its transform) — the rewind half of the prediction reconcile.
GetCharacterController
const CharacterController* GetCharacterController(uint64_t entityId) constThe live controller behind an entity, nullptr when none — diagnostics and the self-tests (capsule shape state isn't mirrored on the component).
GetQueryBodyForEntity
FPhysicsBodyId GetQueryBodyForEntity(uint64_t entityId) constThe body a query originating ON this entity must exclude: its rigid body if it has one, otherwise its character controller's inner body. Looking up RigidBodyComponent alone misses characters entirely, and a ray that starts inside a convex shape reports a hit at fraction 0 — which is how an AI standing in its own capsule goes blind, or a foot-IK probe lands on its own knee. Anything tracing from a pawn wants this, not the component.
GetEntityForBody
uint64_t GetEntityForBody(FPhysicsBodyId bodyID) constLook up EntityID for a physics body (returns INVALID_ENTITY if not found)
GetRegisteredBodyCount
size_t GetRegisteredBodyCount() constBodies this system has registered — RigidBody bodies, character inner bodies and implicit statics alike. Diagnostic, and the self-tests read it to pin that a torn-down entity leaves nothing behind.
GetBodyInterpolation
bool GetBodyInterpolation(uint64_t entityId, FBodyInterp& out) constGetInterpolationAlpha
float GetInterpolationAlpha() constOnCollisionEnterEvents
MulticastDelegate<uint64_t, const CollisionInfo&>& OnCollisionEnterEvents()The single-slot callbacks above belong to whichever system claimed them (the interactable system owns collision enter). Anything else that wants contact begins — an actor's OnHit event — subscribes here and is told about the same pairs, once per side, after the slot callback ran.
SetOnCollisionEnter
void SetOnCollisionEnter(CollisionCallback cb)SetOnCollisionStay
void SetOnCollisionStay(CollisionCallback cb)SetOnCollisionExit
void SetOnCollisionExit(CollisionCallback cb)SetOnTriggerEnter
void SetOnTriggerEnter(CollisionCallback cb)SetOnTriggerStay
void SetOnTriggerStay(CollisionCallback cb)SetOnTriggerExit
void SetOnTriggerExit(CollisionCallback cb)GetImplicitStaticBody
FPhysicsBodyId GetImplicitStaticBody(uint64_t entityId) constThe static body this system created for a collider that carries no RigidBody, if any. Diagnostics and the self-tests — nothing is stored on the component, because the body is derived state and must not survive a save/load round trip as authored data.
GetImplicitStaticBodyCount
size_t GetImplicitStaticBodyCount() constGetImplicitStaticPoseReadCount
uint64_t GetImplicitStaticPoseReadCount() constHow many times an implicit static's world pose has been re-derived from its transform since the system started. Diagnostic — a frame in which no prop's transform was rebuilt adds nothing.