28#include <utility/graphic/renderable.hpp>
30#include <utility/engine.hpp>
32#include "guillaume/ecs/entity.hpp"
48 std::shared_ptr<utility::graphic::Renderable>
91 std::map<ecs::Entity::Identifier, RenderHandle>
112 for (
auto &[identifier, handle]: _handles) {
125 for (
auto it = _handles.begin(); it != _handles.end();) {
126 if (!it->second.used) {
127 engine.removeObject(it->second.renderable,
128 it->second.objectId);
129 it = _handles.erase(it);
148 auto it = _handles.find(identifier);
149 if (it == _handles.end()) {
168 _handles.insert_or_assign(identifier, std::move(handle));
177 return _handles.size();
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
void insert(const ecs::Entity::Identifier &identifier, RenderHandle handle)
Store the handle of an entity, replacing the one it had.
void markAllUnused(void)
Clear the used flag of every handle. Call it from the system's prepare(), before any entity is drawn.
void clear(void)
Forget every handle without calling utility::Engine::removeObject. Use it only when the engine object...
RenderHandleMap(void)=default
Create an empty map.
~RenderHandleMap(void)=default
Destroy the map without removing the engine objects it refers to.
void removeUnused(utility::Engine &engine)
Remove from the engine, then from the map, every handle whose used flag is still false....
RenderHandle * find(const ecs::Entity::Identifier &identifier)
Look up the handle of an entity.
std::size_t size(void) const
Count the entities that have an engine object in this map.
Rules. Every class here runs each frame on the entities that have the components it declares.
What a render system remembers about the engine object it created for one entity.
bool used
Whether the entity was drawn this frame.
std::shared_ptr< utility::graphic::Renderable > renderable
Renderable uploaded last for this object.
size_t objectId
Identifier given by the engine.