Skip to content

EntropyCanvas::SceneGraph

Basic scene graph implementation. More…

#include <SceneGraph.h>

Inherits from EntropyCanvas::ISceneGraph

Name
~SceneGraph() override
virtual booltick(float deltaTime) override
Tick the scene (process systems, observers, etc.).
virtual voidsetTransform(flecs::entity entity, const Transform & transform) override
Update Transform component (triggers observers).
virtual voidsetParent(flecs::entity child, flecs::entity parent) override
Set parent-child relationship.
voidregisterComponentsWithCanToggle(flecs::world & world)
Register all SDK components with CanToggle trait for a Flecs world.
virtual voidqueryTransforms(std::function< void(flecs::entity, const Transform &)> callback) const override
Query all entities with Transform component.
SceneGraph &operator=(const SceneGraph & ) =delete
SceneGraph &operator=(SceneGraph && ) =delete
virtual boolmodifyTransform(flecs::entity entity, std::function< void(Transform &)> callback) override
Modify Transform component with a callback.
virtual flecs::world &getWorld() override
Get the underlying Flecs world (for advanced use).
virtual const flecs::world &getWorld() const override
virtual std::optional< Transform >getTransform(flecs::entity entity) const override
Get Transform component from an entity.
virtual flecs::entitygetParent(flecs::entity entity) const override
Get parent entity.
virtual size_tgetEntityCount() const override
Get total entity count.
virtual std::vector< flecs::entity >getChildren(flecs::entity entity) const override
Get all children of an entity.
virtual voiddestroyEntity(flecs::entity entity) override
Destroy an entity and all its children (cascade delete via ChildOf).
virtual flecs::entitycreateEntity(const char * name =nullptr, const Transform * transform =nullptr, flecs::entity parent =flecs::entity::null()) override
Create a new entity with optional Transform component.
virtual voidclear() override
Clear all entities (reset scene).
virtual voidaddTransform(flecs::entity entity, const Transform & transform) override
Add Transform component to an entity.
SceneGraph()
SceneGraph(const SceneGraph & ) =delete
SceneGraph(SceneGraph && ) =delete
Name
virtual voidonTransformChanged(flecs::entity entity, const Transform & transform)
Called when a Transform is modified (for subclass hooks).
virtual voidonEntityDestroying(flecs::entity entity)
Called when an entity is about to be destroyed (for subclass hooks).
virtual voidonEntityCreated(flecs::entity entity)
Called when an entity is created (for subclass hooks).
Name
flecs::world_world

Public Functions inherited from EntropyCanvas::ISceneGraph

Name
virtual~ISceneGraph() =default
class EntropyCanvas::SceneGraph;

Basic scene graph implementation.

Provides entity management, hierarchy, and component operations using Flecs ECS. This is the base implementation suitable for clients and simple use cases.

For server-side persistence (USD, DeltaTracker, etc.), see PersistentSceneGraph in CanvasEngine.

Thread Safety:

  • All mutation operations must be called from the creating thread
  • Read operations (getTransform, getChildren, etc.) are safe from any thread
~SceneGraph() override
virtual bool tick(
float deltaTime
) override

Tick the scene (process systems, observers, etc.).

Parameters:

  • deltaTime Time step in seconds

Return: True if world is still active

Reimplements: EntropyCanvas::ISceneGraph::tick

virtual void setTransform(
flecs::entity entity,
const Transform & transform
) override

Update Transform component (triggers observers).

Parameters:

  • entity Target entity
  • transform New transform value

Reimplements: EntropyCanvas::ISceneGraph::setTransform

virtual void setParent(
flecs::entity child,
flecs::entity parent
) override

Set parent-child relationship.

Parameters:

  • child Child entity
  • parent Parent entity (null to remove parent)

Reimplements: EntropyCanvas::ISceneGraph::setParent

static void registerComponentsWithCanToggle(
flecs::world & world
)

Register all SDK components with CanToggle trait for a Flecs world.

Parameters:

  • world The Flecs world to register components in

This is the SINGLE place for CanToggle registration. Call this from any code that creates a Flecs world and needs to enable/disable entities.

virtual void queryTransforms(
std::function< void(flecs::entity, const Transform &)> callback
) const override

Query all entities with Transform component.

Parameters:

  • callback Function called for each entity

Reimplements: EntropyCanvas::ISceneGraph::queryTransforms

SceneGraph & operator=(
const SceneGraph &
) =delete
SceneGraph & operator=(
SceneGraph &&
) =delete
virtual bool modifyTransform(
flecs::entity entity,
std::function< void(Transform &)> callback
) override

Modify Transform component with a callback.

Parameters:

  • entity Target entity
  • callback Function to modify the transform

Return: True if entity has Transform and callback was executed

Reimplements: EntropyCanvas::ISceneGraph::modifyTransform

inline virtual flecs::world & getWorld() override

Get the underlying Flecs world (for advanced use).

Return: Reference to Flecs world

Reimplements: EntropyCanvas::ISceneGraph::getWorld

inline virtual const flecs::world & getWorld() const override

Reimplements: EntropyCanvas::ISceneGraph::getWorld

virtual std::optional< Transform > getTransform(
flecs::entity entity
) const override

Get Transform component from an entity.

Parameters:

  • entity Target entity

Return: Optional transform value

Reimplements: EntropyCanvas::ISceneGraph::getTransform

virtual flecs::entity getParent(
flecs::entity entity
) const override

Get parent entity.

Parameters:

  • entity Child entity

Return: Parent entity (null if no parent)

Reimplements: EntropyCanvas::ISceneGraph::getParent

virtual size_t getEntityCount() const override

Get total entity count.

Reimplements: EntropyCanvas::ISceneGraph::getEntityCount

virtual std::vector< flecs::entity > getChildren(
flecs::entity entity
) const override

Get all children of an entity.

Parameters:

  • entity Parent entity

Return: Vector of child entities

Reimplements: EntropyCanvas::ISceneGraph::getChildren

virtual void destroyEntity(
flecs::entity entity
) override

Destroy an entity and all its children (cascade delete via ChildOf).

Parameters:

  • entity Entity to destroy

Reimplements: EntropyCanvas::ISceneGraph::destroyEntity

virtual flecs::entity createEntity(
const char * name =nullptr,
const Transform * transform =nullptr,
flecs::entity parent =flecs::entity::null()
) override

Create a new entity with optional Transform component.

Parameters:

  • name Optional entity name (for debugging)
  • transform Optional initial transform
  • parent Optional parent entity (creates ChildOf relationship)

Return: Flecs entity handle

Reimplements: EntropyCanvas::ISceneGraph::createEntity

virtual void clear() override

Clear all entities (reset scene).

Reimplements: EntropyCanvas::ISceneGraph::clear

virtual void addTransform(
flecs::entity entity,
const Transform & transform
) override

Add Transform component to an entity.

Parameters:

  • entity Target entity
  • transform Initial transform value

Reimplements: EntropyCanvas::ISceneGraph::addTransform

SceneGraph()
SceneGraph(
const SceneGraph &
) =delete
SceneGraph(
SceneGraph &&
) =delete
virtual void onTransformChanged(
flecs::entity entity,
const Transform & transform
)

Called when a Transform is modified (for subclass hooks).

Parameters:

  • entity The entity whose transform changed
  • transform The new transform value
virtual void onEntityDestroying(
flecs::entity entity
)

Called when an entity is about to be destroyed (for subclass hooks).

Parameters:

  • entity The entity being destroyed
virtual void onEntityCreated(
flecs::entity entity
)

Called when an entity is created (for subclass hooks).

Parameters:

  • entity The created entity
flecs::world _world;

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