menu_bookDocumentation

SceneAnimationSystem: Threaded Animation, Bone Merge Order, Procedural Bones, and Ragdoll Physics Step

calendar_today May 4, 2026 schedule ~1 min read person patrickjr verified 50

SceneAnimationSystem: Threaded Animation Updates and Bone Merge Order

SceneAnimationSystem drives all SkinnedModelRenderer animation updates. It runs at Stage.UpdateBones (after OnUpdate, before OnPreRender).

Threading Model

Animation updates run in parallel using Parallel.ForEach with load-balanced partitioning:

  1. Root renderers (no skinned parent) are processed in parallel
  2. Each root renderer processes its SkinnedChildren recursively
  3. Bone merge roots (renderers with bone-merged children) merge descendants in parallel
  4. Transform changes are queued in a ConcurrentQueue<GameTransform> and applied on the main thread
  5. Animation events (OnFootstepEvent, OnSoundEvent, etc.) are dispatched on the main thread
The thread count is ProcessorCount - 1 (leaving one core for the main thread).

Update Order

CODE
Stage.UpdateBones:
  1. Parallel: AnimationUpdate() on all root SkinnedModelRenderers
     - Updates SceneModel transform
     - Runs animation graph / sequence
     - Updates bone GameObjects from bone positions
  2. Parallel: MergeDescendants() on bone merge roots
  3. Main thread: Apply queued transform changes
  4. Main thread: Dispatch animation events (footsteps, sounds, etc.)

Stage.FinishUpdate:
  - FinishUpdate() on all renderers (handles transform-dirty flag)

Stage.PhysicsStep:
  - Parallel: Physics.Step() on renderers with bone physics (ragdolls)

Procedural Bones

Bone GameObjects with GameObjectFlags.ProceduralBone are read FROM the GameObject transform INTO the animation system (not the other way around). This allows you to procedurally control bones:

CSHARP
// Mark a bone GameObject as procedural
boneGo.Flags |= GameObjectFlags.ProceduralBone;

// Now set its local transform to control the bone
boneGo.LocalTransform = myTransform;

Bone Physics (Ragdolls)

Renderers with BonePhysics (ragdolls) have their physics stepped at Stage.PhysicsStep, in parallel with the main physics step. This is separate from the regular animation update.

Was this helpful?