EntropyCanvas::SceneGraph
EntropyCanvas::SceneGraph
Section titled “EntropyCanvas::SceneGraph”Basic scene graph implementation. More…
#include <SceneGraph.h>
Inherits from EntropyCanvas::ISceneGraph
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| ~SceneGraph() override | |
| virtual bool | tick(float deltaTime) override Tick the scene (process systems, observers, etc.). |
| virtual void | setTransform(flecs::entity entity, const Transform & transform) override Update Transform component (triggers observers). |
| virtual void | setParent(flecs::entity child, flecs::entity parent) override Set parent-child relationship. |
| void | registerComponentsWithCanToggle(flecs::world & world) Register all SDK components with CanToggle trait for a Flecs world. |
| virtual void | queryTransforms(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 bool | modifyTransform(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::entity | getParent(flecs::entity entity) const override Get parent entity. |
| virtual size_t | getEntityCount() const override Get total entity count. |
| virtual std::vector< flecs::entity > | getChildren(flecs::entity entity) const override Get all children of an entity. |
| virtual void | destroyEntity(flecs::entity entity) override Destroy an entity and all its children (cascade delete via ChildOf). |
| 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. |
| virtual void | clear() override Clear all entities (reset scene). |
| virtual void | addTransform(flecs::entity entity, const Transform & transform) override Add Transform component to an entity. |
| SceneGraph() | |
| SceneGraph(const SceneGraph & ) =delete | |
| SceneGraph(SceneGraph && ) =delete |
Protected Functions
Section titled “Protected Functions”| Name | |
|---|---|
| virtual void | onTransformChanged(flecs::entity entity, const Transform & transform) Called when a Transform is modified (for subclass hooks). |
| virtual void | onEntityDestroying(flecs::entity entity) Called when an entity is about to be destroyed (for subclass hooks). |
| virtual void | onEntityCreated(flecs::entity entity) Called when an entity is created (for subclass hooks). |
Protected Attributes
Section titled “Protected Attributes”| Name | |
|---|---|
| flecs::world | _world |
Additional inherited members
Section titled “Additional inherited members”Public Functions inherited from EntropyCanvas::ISceneGraph
| Name | |
|---|---|
| virtual | ~ISceneGraph() =default |
Detailed Description
Section titled “Detailed Description”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
Public Functions Documentation
Section titled “Public Functions Documentation”function ~SceneGraph
Section titled “function ~SceneGraph”~SceneGraph() overridefunction tick
Section titled “function tick”virtual bool tick( float deltaTime) overrideTick the scene (process systems, observers, etc.).
Parameters:
- deltaTime Time step in seconds
Return: True if world is still active
Reimplements: EntropyCanvas::ISceneGraph::tick
function setTransform
Section titled “function setTransform”virtual void setTransform( flecs::entity entity, const Transform & transform) overrideUpdate Transform component (triggers observers).
Parameters:
- entity Target entity
- transform New transform value
Reimplements: EntropyCanvas::ISceneGraph::setTransform
function setParent
Section titled “function setParent”virtual void setParent( flecs::entity child, flecs::entity parent) overrideSet parent-child relationship.
Parameters:
- child Child entity
- parent Parent entity (null to remove parent)
Reimplements: EntropyCanvas::ISceneGraph::setParent
function registerComponentsWithCanToggle
Section titled “function registerComponentsWithCanToggle”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.
function queryTransforms
Section titled “function queryTransforms”virtual void queryTransforms( std::function< void(flecs::entity, const Transform &)> callback) const overrideQuery all entities with Transform component.
Parameters:
- callback Function called for each entity
Reimplements: EntropyCanvas::ISceneGraph::queryTransforms
function operator=
Section titled “function operator=”SceneGraph & operator=( const SceneGraph &) =deletefunction operator=
Section titled “function operator=”SceneGraph & operator=( SceneGraph &&) =deletefunction modifyTransform
Section titled “function modifyTransform”virtual bool modifyTransform( flecs::entity entity, std::function< void(Transform &)> callback) overrideModify 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
function getWorld
Section titled “function getWorld”inline virtual flecs::world & getWorld() overrideGet the underlying Flecs world (for advanced use).
Return: Reference to Flecs world
Reimplements: EntropyCanvas::ISceneGraph::getWorld
function getWorld
Section titled “function getWorld”inline virtual const flecs::world & getWorld() const overrideReimplements: EntropyCanvas::ISceneGraph::getWorld
function getTransform
Section titled “function getTransform”virtual std::optional< Transform > getTransform( flecs::entity entity) const overrideGet Transform component from an entity.
Parameters:
- entity Target entity
Return: Optional transform value
Reimplements: EntropyCanvas::ISceneGraph::getTransform
function getParent
Section titled “function getParent”virtual flecs::entity getParent( flecs::entity entity) const overrideGet parent entity.
Parameters:
- entity Child entity
Return: Parent entity (null if no parent)
Reimplements: EntropyCanvas::ISceneGraph::getParent
function getEntityCount
Section titled “function getEntityCount”virtual size_t getEntityCount() const overrideGet total entity count.
Reimplements: EntropyCanvas::ISceneGraph::getEntityCount
function getChildren
Section titled “function getChildren”virtual std::vector< flecs::entity > getChildren( flecs::entity entity) const overrideGet all children of an entity.
Parameters:
- entity Parent entity
Return: Vector of child entities
Reimplements: EntropyCanvas::ISceneGraph::getChildren
function destroyEntity
Section titled “function destroyEntity”virtual void destroyEntity( flecs::entity entity) overrideDestroy an entity and all its children (cascade delete via ChildOf).
Parameters:
- entity Entity to destroy
Reimplements: EntropyCanvas::ISceneGraph::destroyEntity
function createEntity
Section titled “function createEntity”virtual flecs::entity createEntity( const char * name =nullptr, const Transform * transform =nullptr, flecs::entity parent =flecs::entity::null()) overrideCreate 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
function clear
Section titled “function clear”virtual void clear() overrideClear all entities (reset scene).
Reimplements: EntropyCanvas::ISceneGraph::clear
function addTransform
Section titled “function addTransform”virtual void addTransform( flecs::entity entity, const Transform & transform) overrideAdd Transform component to an entity.
Parameters:
- entity Target entity
- transform Initial transform value
Reimplements: EntropyCanvas::ISceneGraph::addTransform
function SceneGraph
Section titled “function SceneGraph”SceneGraph()function SceneGraph
Section titled “function SceneGraph”SceneGraph( const SceneGraph &) =deletefunction SceneGraph
Section titled “function SceneGraph”SceneGraph( SceneGraph &&) =deleteProtected Functions Documentation
Section titled “Protected Functions Documentation”function onTransformChanged
Section titled “function onTransformChanged”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
function onEntityDestroying
Section titled “function onEntityDestroying”virtual void onEntityDestroying( flecs::entity entity)Called when an entity is about to be destroyed (for subclass hooks).
Parameters:
- entity The entity being destroyed
function onEntityCreated
Section titled “function onEntityCreated”virtual void onEntityCreated( flecs::entity entity)Called when an entity is created (for subclass hooks).
Parameters:
- entity The created entity
Protected Attributes Documentation
Section titled “Protected Attributes Documentation”variable _world
Section titled “variable _world”flecs::world _world;Updated on 2026-01-26 at 17:14:35 -0500