Skip to content

EntropyCanvas::SceneService

SceneService manages scene graph operations via ISceneGraph interface. More…

#include <SceneService.h>

Inherits from EntropyEngine::Core::EntropyService, EntropyEngine::Core::EntropyObject

Name
~SceneService() override
flecs::world &world()
Get the Flecs world from the scene graph.
const flecs::world &world() const
virtual const char *version() const override
voidupdateCameraAspectRatio(float aspectRatio)
Update the active camera’s aspect ratio (call on window resize).
virtual voidunload() override
virtual EntropyEngine::Core::TypeSystem::TypeIDtypeId() const override
voidtick(float deltaTime)
Tick the scene - runs ECS systems and updates entities.
virtual voidstop() override
virtual voidstart() override
voidsetSchemaService(ComponentSchemaService * service)
Set the schema service for hash-based component lookup.
voidsetDataProvider(IDataProvider * provider)
Set the data provider for receiving scene data.
voidsetActiveCamera(flecs::entity camera)
Set the active camera.
ComponentSchemaService *schemaService() const
Get the schema service.
voidscheduleAsyncTick(EntropyEngine::Core::Concurrency::WorkContractGroup & group, float deltaTime)
Schedule tick as async work contract (fire-and-forget).
ISceneGraph *sceneGraph() const
Get the underlying ISceneGraph.
voidprepareForShutdown()
Prepare for shutdown - prevents new ticks from being scheduled.
SceneService &operator=(const SceneService & ) =delete
virtual const char *name() const override
uint64_tmakeLocalEntityId(uint32_t serverId, uint64_t serverEntityId)
Create a local entity ID from server ID and server entity ID.
virtual voidload() override
boolisValid(flecs::entity entity) const
Check if an entity is valid.
boolisTickInProgress() const
Check if a tick is currently in progress.
virtual const char *id() const override
glm::mat4getActiveCameraViewProjection() const
Get the view-projection matrix from the active camera.
glm::mat4getActiveCameraView() const
Get just the view matrix from the active camera.
glm::mat4getActiveCameraProjection() const
Get just the projection matrix from the active camera.
glm::vec3getActiveCameraPosition() const
Get the world position of the active camera.
std::optional< flecs::entity >getActiveCamera() const
Get the active camera entity.
template <typename Func >
void
forEachRenderable(Func && func)
Iterate all entities with Transform and MeshComponent.
template <typename Func >
void
forEachLight(Func && func)
Iterate all entities with Transform and Light.
template <typename Func >
void
forEachCamera(Func && func)
Iterate all entities with Transform and CameraComponent.
ExternalTransformRegistry &externalTransformRegistry()
Get the external transform registry for low-latency transform sources.
const ExternalTransformRegistry &externalTransformRegistry() const
size_tentityCount() const
Get entity count.
voiddestroyEntity(flecs::entity entity)
Destroy an entity.
IDataProvider *dataProvider() const
Get the current data provider.
flecs::entitycreateEntity(const char * name =nullptr)
Create a new entity with an optional name.
flecs::entitycreateEntity(const Transform & transform, const char * name =nullptr)
Create an entity with Transform component.
flecs::entitycreateCamera(const Transform & transform, const CameraComponent & camera, const char * name =nullptr)
Create a camera entity with Transform and CameraComponent.
SimulationCommandQueue &commandQueue()
Get the command queue for external systems to submit flecs mutations.
voidapplySnapshot(const SceneSnapshot & snapshot)
Apply a scene snapshot (full scene replacement).
voidapplyDelta(const PropertyDelta & delta)
Apply a property delta (single property change).
SceneService()
Construct with default SceneGraph (created on load).
SceneService(std::unique_ptr< ISceneGraph > sceneGraph)
Construct with injected ISceneGraph implementation.
SceneService(const SceneService & ) =delete

Public Functions inherited from EntropyEngine::Core::EntropyService

Name
~EntropyService() override =default
ServiceStatestate() const
virtual std::vector< TypeSystem::TypeID >dependsOnTypes() const
virtual std::vector< std::string >dependsOn() const
virtual const char *className() const override
Runtime class name for diagnostics and reflection.

Protected Functions inherited from EntropyEngine::Core::EntropyService

Name
voidsetState(ServiceState s)

Friends inherited from EntropyEngine::Core::EntropyService

Name
classEntropyServiceRegistry

Protected Classes inherited from EntropyEngine::Core::EntropyObject

Name
structHandleCore
Optional handle identity stamped by an owner/registry.

Public Functions inherited from EntropyEngine::Core::EntropyObject

Name
virtual~EntropyObject() =default
virtual const TypeSystem::TypeInfo *typeInfo() const
Optional richer type information; may be null.
booltryRetain() const
Attempts to retain only if the object is still alive.
virtual std::stringtoString() const
Human-readable short string (class@ptr by default).
voidretain() const
Increments the reference count.
voidrelease() const
Decrements the reference count and deletes when it reaches zero.
uint32_trefCount() const
Current reference count (approximate under contention).
boolhasHandle() const
template <class OwnerT >
OwnerT *
handleOwnerAs() const
Returns the stamped owner pointer cast to the requested type.
const void *handleOwner() const
uint32_thandleIndex() const
uint64_thandleId() const
uint32_thandleGeneration() const
WeakControlBlock *getWeakControlBlock() const
Lazily retrieves or creates the weak control block.
virtual std::stringdescription() const
Long-form description; defaults to toString().
virtual std::stringdebugString() const
Debug-oriented string including refcount and handle when present.
virtual const char *className() const
Runtime class name for diagnostics and reflection.
virtual uint64_tclassHash() const
Stable type hash for cross-language identification.
EntropyObject() =default
EntropyObject(EntropyObject && ) =delete
EntropyObject(const EntropyObject & ) =delete

Protected Functions inherited from EntropyEngine::Core::EntropyObject

Name
void_setHandleIdentity(void * owner, uint32_t index, uint32_t generation)
void_clearHandleIdentity()

Protected Attributes inherited from EntropyEngine::Core::EntropyObject

Name
std::atomic< WeakControlBlock * >_weakBlock
Lazily allocated control block for weak refs.
std::atomic< uint32_t >_refCount
Thread-safe retain/release counter.
struct EntropyEngine::Core::EntropyObject::HandleCore_handle

Friends inherited from EntropyEngine::Core::EntropyObject

Name
structHandleAccess
class EntropyCanvas::SceneService;

SceneService manages scene graph operations via ISceneGraph interface.

This service works with any ISceneGraph implementation:

  • SceneGraph: Base implementation for clients
  • PersistentSceneGraph: Server-side with USD persistence, DeltaTracker, etc.

Responsibilities:

  • Wraps ISceneGraph for service lifecycle management
  • Receives scene snapshots and deltas via IDataProvider
  • Provides entity creation/destruction API
  • Supports querying entities by component
  • Manages the active camera
~SceneService() override
inline flecs::world & world()

Get the Flecs world from the scene graph.

Use for advanced queries or direct Flecs API access.

inline const flecs::world & world() const
inline virtual const char * version() const override

Reimplements: EntropyEngine::Core::EntropyService::version

void updateCameraAspectRatio(
float aspectRatio
)

Update the active camera’s aspect ratio (call on window resize).

virtual void unload() override

Reimplements: EntropyEngine::Core::EntropyService::unload

inline virtual EntropyEngine::Core::TypeSystem::TypeID typeId() const override

Reimplements: EntropyEngine::Core::EntropyService::typeId

void tick(
float deltaTime
)

Tick the scene - runs ECS systems and updates entities.

Parameters:

  • deltaTime Time since last tick in seconds

Call once per frame from simulation thread/main loop.

virtual void stop() override

Reimplements: EntropyEngine::Core::EntropyService::stop

virtual void start() override

Reimplements: EntropyEngine::Core::EntropyService::start

void setSchemaService(
ComponentSchemaService * service
)

Set the schema service for hash-based component lookup.

void setDataProvider(
IDataProvider * provider
)

Set the data provider for receiving scene data.

This registers for delta callbacks automatically.

void setActiveCamera(
flecs::entity camera
)

Set the active camera.

inline ComponentSchemaService * schemaService() const

Get the schema service.

void scheduleAsyncTick(
EntropyEngine::Core::Concurrency::WorkContractGroup & group,
float deltaTime
)

Schedule tick as async work contract (fire-and-forget).

Parameters:

  • group WorkContractGroup to schedule on
  • deltaTime Time since last tick in seconds

If a tick is already in progress, this is a no-op.

inline ISceneGraph * sceneGraph() const

Get the underlying ISceneGraph.

Return: Pointer to ISceneGraph (nullptr if not loaded)

void prepareForShutdown()

Prepare for shutdown - prevents new ticks from being scheduled.

Call before waiting for in-flight tick to complete.

SceneService & operator=(
const SceneService &
) =delete
inline virtual const char * name() const override

Reimplements: EntropyEngine::Core::EntropyService::name

static uint64_t makeLocalEntityId(
uint32_t serverId,
uint64_t serverEntityId
)

Create a local entity ID from server ID and server entity ID.

This allows entities from multiple servers to coexist.

virtual void load() override

Reimplements: EntropyEngine::Core::EntropyService::load

bool isValid(
flecs::entity entity
) const

Check if an entity is valid.

bool isTickInProgress() const

Check if a tick is currently in progress.

Used to prevent overlapping ticks.

inline virtual const char * id() const override

Reimplements: EntropyEngine::Core::EntropyService::id

glm::mat4 getActiveCameraViewProjection() const

Get the view-projection matrix from the active camera.

Returns identity matrix if no active camera.

glm::mat4 getActiveCameraView() const

Get just the view matrix from the active camera.

glm::mat4 getActiveCameraProjection() const

Get just the projection matrix from the active camera.

glm::vec3 getActiveCameraPosition() const

Get the world position of the active camera.

std::optional< flecs::entity > getActiveCamera() const

Get the active camera entity.

template <typename Func >
inline void forEachRenderable(
Func && func
)

Iterate all entities with Transform and MeshComponent.

template <typename Func >
inline void forEachLight(
Func && func
)

Iterate all entities with Transform and Light.

template <typename Func >
inline void forEachCamera(
Func && func
)

Iterate all entities with Transform and CameraComponent.

inline ExternalTransformRegistry & externalTransformRegistry()

Get the external transform registry for low-latency transform sources.

inline const ExternalTransformRegistry & externalTransformRegistry() const
size_t entityCount() const

Get entity count.

void destroyEntity(
flecs::entity entity
)

Destroy an entity.

inline IDataProvider * dataProvider() const

Get the current data provider.

flecs::entity createEntity(
const char * name =nullptr
)

Create a new entity with an optional name.

flecs::entity createEntity(
const Transform & transform,
const char * name =nullptr
)

Create an entity with Transform component.

flecs::entity createCamera(
const Transform & transform,
const CameraComponent & camera,
const char * name =nullptr
)

Create a camera entity with Transform and CameraComponent.

inline SimulationCommandQueue & commandQueue()

Get the command queue for external systems to submit flecs mutations.

Thread-safe: can be called from any thread.

void applySnapshot(
const SceneSnapshot & snapshot
)

Apply a scene snapshot (full scene replacement).

void applyDelta(
const PropertyDelta & delta
)

Apply a property delta (single property change).

SceneService()

Construct with default SceneGraph (created on load).

explicit SceneService(
std::unique_ptr< ISceneGraph > sceneGraph
)

Construct with injected ISceneGraph implementation.

Parameters:

Takes ownership of the scene graph.

SceneService(
const SceneService &
) =delete

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