menu_bookDocumentation
SceneAnimationSystem: Threaded Animation, Bone Merge Order, Procedural Bones, and Ragdoll Physics Step
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:
- Root renderers (no skinned parent) are processed in parallel
- Each root renderer processes its SkinnedChildren recursively
- Bone merge roots (renderers with bone-merged children) merge descendants in parallel
- Transform changes are queued in a ConcurrentQueue<GameTransform> and applied on the main thread
- Animation events (OnFootstepEvent, OnSoundEvent, etc.) are dispatched on 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?