EntropyCanvas::TransformPropagationSystem
EntropyCanvas::TransformPropagationSystem
Section titled “EntropyCanvas::TransformPropagationSystem”System for propagating Transform changes through the entity hierarchy. More…
#include <TransformPropagationSystem.h>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| ~TransformPropagationSystem() =default | |
| void | registerObservers(flecs::world & world) Register Flecs observers for Transform changes and reparenting. |
| void | propagate(flecs::world & world) Propagate transforms down the entity hierarchy. |
| void | markDirtyRecursive(flecs::entity entity) Mark an entity and all its descendants as needing world matrix update. |
| TransformPropagationSystem() =default |
Detailed Description
Section titled “Detailed Description”class EntropyCanvas::TransformPropagationSystem;System for propagating Transform changes through the entity hierarchy.
When a Transform component is modified, the TransformPropagationSystem computes the world matrices for that entity and all its descendants. The world matrix is the final local-to-world transformation that accounts for the entire parent chain.
Usage:
- Call registerObservers() once during scene setup to hook Transform changes
- Call propagate() once per frame (or after batch changes) to update all world matrices
The system uses the worldDirty flag within Transform to track which entities need updates:
- OnSet(Transform) → marks entity and all descendants as worldDirty
- OnAdd(ChildOf) → marks entity and all descendants as worldDirty (reparent)
- propagate() → processes dirty entities in topological order (parents before children)
Implementation notes:
- Root entities (no parent with Transform) have world matrix = local matrix
- Child entities have world matrix = parentWorld * localTransform
- Dirty marking is recursive (all descendants are marked)
- Propagation uses topological traversal (BFS from roots)
- World matrices are stored within Transform::_cache (not a separate component)
Public Functions Documentation
Section titled “Public Functions Documentation”function ~TransformPropagationSystem
Section titled “function ~TransformPropagationSystem”~TransformPropagationSystem() =defaultfunction registerObservers
Section titled “function registerObservers”void registerObservers( flecs::world & world)Register Flecs observers for Transform changes and reparenting.
Parameters:
- world Flecs world to register observers in
Must be called once during scene setup.
function propagate
Section titled “function propagate”void propagate( flecs::world & world)Propagate transforms down the entity hierarchy.
Parameters:
- world Flecs world to process
Updates world matrices within Transform for all entities. Call once per frame or after batch changes.
function markDirtyRecursive
Section titled “function markDirtyRecursive”static void markDirtyRecursive( flecs::entity entity)Mark an entity and all its descendants as needing world matrix update.
Parameters:
- entity Entity to mark dirty
Called automatically by observers, but can be called manually if needed.
function TransformPropagationSystem
Section titled “function TransformPropagationSystem”TransformPropagationSystem() =defaultUpdated on 2026-01-26 at 17:14:35 -0500