23#include "guillaume/systems/line_render.hpp"
28#include "guillaume/mesh_renderable.hpp"
64 const auto &color = line.hasColor()
68 float centerY = bound.getHeight() / 2.0f;
70 centerY = line.getThickness() / 2.0f;
72 centerY = bound.getHeight() - line.getThickness() / 2.0f;
78 const utility::graphic::PositionF lift(
79 -pose.getOrientation().getForward() *
StrokeLift);
81 const utility::graphic::PositionF center(
82 pose.getPosition().x + bound.getWidth() / 2.0f + lift[0],
83 pose.getPosition().y - centerY + lift[1],
84 pose.getPosition().z + lift[2]);
86 utility::graphic::Mesh mesh(std::vector<utility::graphic::VertexF> {},
87 std::vector<uint32_t> {});
90 bound.getWidth() / 2.0f,
91 line.getThickness() / 2.0f, line.isDashed(),
92 line.getDashLength(), line.getGapLength(), color);
96 if (mesh.getVertices().empty()) {
100 auto renderable = std::make_shared<MeshRenderable>(
101 std::vector<utility::graphic::Mesh> { mesh },
"mesh_material");
104 if (handle ==
nullptr) {
106 RenderHandle { _engine.createObject(renderable), renderable,
109 if (!_engine.updateObject(renderable, handle->objectId)) {
110 handle->objectId = _engine.createObject(renderable);
112 handle->renderable = renderable;
@ Top
Inside the bound, against its top edge.
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...
LineRender(utility::Engine &engine)
Create the system in the Render phase.
static constexpr float StrokeLift
Distance a stroke placed on the top or bottom edge is moved towards the viewer, along the forward axi...
void prepare(void) override
Mark every engine object as not drawn yet. Called once per frame before the entities are visited.
void cleanup(void) override
Remove the engine objects of the entities that were not drawn this frame. Called once per frame after...
void update(const ecs::Entity::Identifier &entityIdentifier) override
Rebuild the mesh of one stroke and upload it, creating the engine object on the first frame.
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.
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.
void buildLineMesh(utility::graphic::Mesh &mesh, const utility::graphic::PositionF ¢er, const utility::graphic::OrientationF &orientation, float halfLength, float halfThickness, bool dashed, float dashLength, float gapLength, const utility::graphic::Color32Bit &color)
Build a straight stroke along X, solid or dashed.
What a render system remembers about the engine object it created for one entity.