23#include "guillaume/systems/scrim_render.hpp"
28#include "guillaume/mesh_renderable.hpp"
64 const float x0 = pose.getPosition().x;
65 const float y0 = pose.getPosition().y;
66 const float z = pose.getPosition().z;
72 const float halfWidth = bound.getWidth() / 2.0f;
73 const float halfHeight = bound.getHeight() / 2.0f;
75 const utility::graphic::PositionF center(x0 + halfWidth,
78 const std::vector<utility::math::Vector2F> localVertices {
79 { -halfWidth, -halfHeight },
80 { halfWidth, -halfHeight },
81 { halfWidth, halfHeight },
82 { -halfWidth, halfHeight },
86 localVertices, center, pose.getOrientation());
88 utility::graphic::Mesh mesh(std::vector<utility::graphic::VertexF> {},
89 std::vector<uint32_t> {});
91 for (
const auto &worldVertex: worldVertices) {
104 if (mesh.getVertices().empty()) {
108 auto renderable = std::make_shared<MeshRenderable>(
109 std::vector<utility::graphic::Mesh> { mesh },
"mesh_material");
112 if (handle ==
nullptr) {
114 RenderHandle { _engine.createObject(renderable), renderable,
117 if (!_engine.updateObject(renderable, handle->objectId)) {
118 handle->objectId = _engine.createObject(renderable);
120 handle->renderable = renderable;
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
SystemFiller(Phase phase)
ComponentType & getComponent(const ecs::Entity::Identifier &entityIdentifier)
Get a component of an entity from the bound registry, to read or modify it.
bool requireComponent(const ecs::Entity::Identifier &entityIdentifier)
Tell whether an entity has a component, and log a warning naming the entity and the component when it...
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 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.
ScrimRender(utility::Engine &engine)
Create the system in the Render phase.
void update(const ecs::Entity::Identifier &entityIdentifier) override
Rebuild the quad of one scrim and upload it, creating the engine object on the first frame.
void cleanup(void) override
Remove the scrims of the entities that were not drawn this frame. Called once per frame after the ent...
void prepare(void) override
Mark every scrim as not drawn yet. Called once per frame before the entities are visited.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Rules. Every class here runs each frame on the entities that have the components it declares.
Mesh builders shared by the shape render systems.
utility::graphic::VertexF createVertex(const utility::graphic::PositionF &position, const utility::graphic::Color32Bit &color)
Make a mesh vertex from a position and a color.
std::vector< utility::graphic::PositionF > transformToWorldVertices(const std::vector< utility::math::Vector2F > &localVertices, const utility::graphic::PositionF ¢er, const utility::graphic::OrientationF &orientation)
Move 2D points of a shape's plane into world space.
What a render system remembers about the engine object it created for one entity.