Skip to content

EntropyCanvas::TransformPropagationSystem

System for propagating Transform changes through the entity hierarchy. More…

#include <TransformPropagationSystem.h>

Name
~TransformPropagationSystem() =default
voidregisterObservers(flecs::world & world)
Register Flecs observers for Transform changes and reparenting.
voidpropagate(flecs::world & world)
Propagate transforms down the entity hierarchy.
voidmarkDirtyRecursive(flecs::entity entity)
Mark an entity and all its descendants as needing world matrix update.
TransformPropagationSystem() =default
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:

  1. Call registerObservers() once during scene setup to hook Transform changes
  2. 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)
~TransformPropagationSystem() =default
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.

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.

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.

TransformPropagationSystem() =default

Updated on 2026-01-26 at 17:14:35 -0500