Skip to content

UMjPhysicsEngine

Core physics engine component that owns the MuJoCo simulation lifecycle.

Manages mjSpec compilation, mjModel/mjData ownership, the async physics loop, and callback registration for pre/post step hooks.

Attribute Value
Kind Class
UE Macro UCLASS
Inherits UActorComponent
Blueprint Spawnable ✅ Yes

Properties

Public Properties

Property Type Description
StepRequestEvent FEvent* Wakes the async physics worker when a step request lands in
FMujocoStepCallback using If bound, replaces mj_step (used by replay).
FMujocoPostStepCallback using Called after mj_step (or custom step); used for recording.
Options FMjOptionGenerated
SimSpeedPercent float 100 = realtime, 50 = half speed.
NumWorkerThreads int32 Worker threads for MuJoCo's per-step thread pool (mju_threadpool).
bIsPaused bool
bSaveDebugXml bool Saves compiled scene XML and MJB to Saved/URLab/ on each compile.
ControlSource EControlSource
m_ArticulationMap TMapAMjArticulation\*> O(1) articulation lookup. Key = actor name.
m_LastCompileError FString Error string from the most recent Compile(); empty on success.
ActiveAssetPaths TArray<FString> Absolute paths of every mesh / texture asset registered to the

StepRequestEvent

Wakes the async physics worker when a step request lands in

  • Type: FEvent*

FMujocoStepCallback

If bound, replaces mj_step (used by replay).

  • Type: using

FMujocoPostStepCallback

Called after mj_step (or custom step); used for recording.

  • Type: using

Options

  • Type: FMjOptionGenerated
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Options

SimSpeedPercent

100 = realtime, 50 = half speed.

  • Type: float
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Options

NumWorkerThreads

Worker threads for MuJoCo's per-step thread pool (mju_threadpool).

  • Type: int32
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Options

bIsPaused

  • Type: bool
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Status

bSaveDebugXml

Saves compiled scene XML and MJB to Saved/URLab/ on each compile.

  • Type: bool
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Debug

ControlSource

  • Type: EControlSource
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Runtime

m_ArticulationMap

O(1) articulation lookup. Key = actor name.

  • Type: TMapAMjArticulation\*>

m_LastCompileError

Error string from the most recent Compile(); empty on success.

  • Type: FString

ActiveAssetPaths

Absolute paths of every mesh / texture asset registered to the

  • Type: TArray

Private Properties

Property Type Description
RenderStateMutex FCriticalSection Guards RenderSnapshot. Inner to CallbackMutex on the producer
RenderSnapshot FMjRenderSnapshot Engine-owned snapshot buffer. Sized on model load.
CommandMutex FCriticalSection Independent of CallbackMutex / RenderStateMutex. Held only

RenderStateMutex

Guards RenderSnapshot. Inner to CallbackMutex on the producer

  • Type: FCriticalSection

RenderSnapshot

Engine-owned snapshot buffer. Sized on model load.

CommandMutex

Independent of CallbackMutex / RenderStateMutex. Held only

  • Type: FCriticalSection

Functions

Public Functions

General

Function Returns Description
ApplyThreadPool() void (Re)build or free MuJoCo's per-step worker thread pool on the live
MaxWorkerThreads() int32 Max useful worker threads = logical CPU cores (cross-platform).
RestoreSnapshot() void Restore is scheduled for the next physics step.
PushRenderState() void Copies the live mjData into the engine-owned render
WithRenderState() void Runs the visitor against the latest render snapshot
SubmitMocapPose() void World-frame mocap pose for a mocap body, in MuJoCo coordinates.
SubmitWrench() void Set xfrc_applied[body] = [tx, ty, tz, fx, fy, fz] (MuJoCo order).
SubmitClearForce() void Zero xfrc_applied for the body on the next drain.
ApplyWakeBody() void Wake the body and its kinematic tree synchronously. Takes
ApplySleepBody() void Put the body and its kinematic tree to sleep synchronously.
ApplyThreadPool

(Re)build or free MuJoCo's per-step worker thread pool on the live

  • Signature: ApplyThreadPool()
MaxWorkerThreads

Max useful worker threads = logical CPU cores (cross-platform).

  • Signature: MaxWorkerThreads()
  • Returns: int32
RestoreSnapshot

Restore is scheduled for the next physics step.

PushRenderState

Copies the live mjData into the engine-owned render

  • Signature: PushRenderState()
WithRenderState

Runs the visitor against the latest render snapshot

  • Signature: WithRenderState(TFunctionRef<void(const FMjRenderSnapshot&)
SubmitMocapPose

World-frame mocap pose for a mocap body, in MuJoCo coordinates.

  • Signature: SubmitMocapPose(int32 BodyId, const double Pos[3], const double Quat[4])
SubmitWrench

Set xfrc_applied[body] = [tx, ty, tz, fx, fy, fz] (MuJoCo order).

  • Signature: SubmitWrench(int32 BodyId, const double Xfrc[6])
SubmitClearForce

Zero xfrc_applied for the body on the next drain.

  • Signature: SubmitClearForce(int32 BodyId)
ApplyWakeBody

Wake the body and its kinematic tree synchronously. Takes

  • Signature: ApplyWakeBody(int32 BodyId)
ApplySleepBody

Put the body and its kinematic tree to sleep synchronously.

  • Signature: ApplySleepBody(int32 BodyId)

Private Functions

General

Function Returns Description
DrainCommands() void Drains PendingCommands into m_data. Must be called by the
DrainCommands

Drains PendingCommands into m_data. Must be called by the

  • Signature: DrainCommands()