struct
TRendererObjectECSUtility
template<typename IdFragment, typename DirtyTag, typename TransformDirtyTag, RendererId (RendererScene::*AllocateFn)(ecs::Registry &, ecs::Entity), void (RendererScene::*DeallocateFn)(ecs::Registry &, ecs::Entity), typename ...DataFragments>Provides generic ECS utility methods for renderer object types.
Handles the common pattern of creating data fragments, registering/unregistering with the renderer, managing dirty tags, and migrating fragments across scenes.
Fragment removal cleanup (ID deallocation, dirty tag removal) is handled automatically by OnWillRemove events subscribed in RendererScene. This template only needs to handle creation, registration, and migration.
Template parameters
IdFragment | The ID fragment type (e.g., ecs::LightId). |
|---|---|
DirtyTag | The full-dirty tag type (e.g., ecs::LightDirty). |
TransformDirtyTag | The transform-dirty tag type (e.g., ecs::LightTransformDirty). |
AllocateFn | Pointer-to-member for RendererScene::Allocate*Id. |
DeallocateFn | Pointer-to-member for RendererScene::Deallocate*Id. |
DataFragments | The ECS data fragment types managed by this renderer object. |
Public
Methods
staticCreateFragmentsIfMissing
Ensures all data fragments exist on the entity.
Returns true if any fragment was newly created.
staticRegisterWithRenderer
Allocates a renderer ID and marks the entity dirty.
This ensures a render proxy for the entity is created on the render thread, and the entity can be rendered. Use Mark*Dirty() methods when changing data fragment properties to ensure render proxy has up-to-date information.
staticUnregisterFromRenderer
Deallocates the renderer ID and removes dirty tags.
This deallocated the render proxy for the entity on the render thread, and the entity will no longer be rendered. Does not remove data fragments — the entity stays but is deactivated.
staticRemoveFragments
Removes all data fragments from the entity.
Cleanup (ID deallocation, dirty tag removal) is handled by the associated RendererScene when it is notified the fragment has been removed.
staticChangeScene
Handles fragment migration when the entity moves between scenes.
Migrates data fragments from old entity to new (removal from old triggers OnWillRemove → auto-cleanup on old scene). Optionally registers in new renderer scene if is true (e.g. can be false if entity exists, but is currently not active/disabled).
staticMarkDirty
Marks the entity as fully dirty, requiring a full sync to the render thread.
staticMarkTransformDirty
Marks only the transform as dirty.
No-op if the entity is already fully dirty.
staticMarkDirty
Adds the appropriate dirty tag based on the flag type.
Transform-only changes use TransformDirtyTag (unless already full-dirty). Everything else uses DirtyTag.