Is your feature request related to a problem? Please describe.
Currently, managing components for specific tasks (e.g., filtering all light sources for shadow map rendering or calling methods for game logic simulation) is inconvenient. There is no built-in, lightweight way to group components dynamically without hardcoding logic into systems or manually maintaining collections.
This leads to extra boilerplate code and reduces flexibility when trying to quickly organize scene objects by categories like "Enemy", "LightSource", etc.
Describe the solution you'd like
Introduce a flat tagging system for Component with automatic group management in Scene.
New Component methods:
addTag(const TString &tag) – adds a tag to the component and automatically adds the component to the corresponding group in the Scene.
removeTag(const TString &tag) – removes the tag and removes the component from the group.
New Scene methods for group management:
addToGroup(Object *object, const TString &group) / addToGroupByHash(Object *object, uint32_t hash)
removeFromGroup(Object *object, const TString &group) / removeFromGroupByHash(Object *object, uint32_t hash)
Object::ObjectList &getObjectsInGroup(const TString &group) / getObjectsInGroupByHash(uint32_t hash)
Under the hood:
- Groups are flat (no hierarchy).
- Groups are stored by hash (using
Mathf::hashString) for fast access.
- All group operations are thread-safe (mutex-protected).
Example usage:
component->addTag("Enemy");
// automatically added to Scene group "Enemy"
auto& enemies = scene.getObjectsInGroup("Enemy");
Describe alternatives you've considered
- Hierarchical tags – considered but rejected for now to keep the system simple.
- Calling methods from groups – not planned for now to avoid overcomplicating the initial implementation.
- Manual group management – currently what developers have to do (add/remove objects from custom lists), which is error-prone and requires extra code.
Additional context
This feature is designed to be simple, flexible, and not tied to specific systems. It allows quick filtering of objects by category without modifying existing system logic. Use cases include:
- Filtering all light sources for shadow map rendering.
- Iterating over all "Enemy" objects for game logic simulation.
- Any scenario where dynamic grouping of components is useful.
Internal implementation uses hashed strings for performance and mutexes for thread safety.
Is your feature request related to a problem? Please describe.
Currently, managing components for specific tasks (e.g., filtering all light sources for shadow map rendering or calling methods for game logic simulation) is inconvenient. There is no built-in, lightweight way to group components dynamically without hardcoding logic into systems or manually maintaining collections.
This leads to extra boilerplate code and reduces flexibility when trying to quickly organize scene objects by categories like "Enemy", "LightSource", etc.
Describe the solution you'd like
Introduce a flat tagging system for
Componentwith automatic group management inScene.New Component methods:
addTag(const TString &tag)– adds a tag to the component and automatically adds the component to the corresponding group in theScene.removeTag(const TString &tag)– removes the tag and removes the component from the group.New Scene methods for group management:
addToGroup(Object *object, const TString &group)/addToGroupByHash(Object *object, uint32_t hash)removeFromGroup(Object *object, const TString &group)/removeFromGroupByHash(Object *object, uint32_t hash)Object::ObjectList &getObjectsInGroup(const TString &group)/getObjectsInGroupByHash(uint32_t hash)Under the hood:
Mathf::hashString) for fast access.Example usage:
Describe alternatives you've considered
Additional context
This feature is designed to be simple, flexible, and not tied to specific systems. It allows quick filtering of objects by category without modifying existing system logic. Use cases include:
Internal implementation uses hashed strings for performance and mutexes for thread safety.