MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GeometryLeafNode.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "VertexSpec.hpp"
5
7
8/**
9 * @class GeometryLeafNode
10 * @brief One independent, arbitrary-topology geometry item.
11 *
12 * Concrete GeometryWriterNode leaf holding a flat Vertex array, with no
13 * interpolation, connectivity, or simulation of its own: callers supply
14 * finished geometry (Kinesis generators, input, procedural code) and this
15 * just holds and uploads it. Topology comes from the inherited
16 * set_primitive_topology()/get_primitive_topology() (default POINT_LIST);
17 * the reported vertex layout tracks whichever topology is current, since
18 * Vertex/PointVertex/LineVertex/MeshVertex share one 68-byte offset table
19 * and differ only in the scalar field's name.
20 *
21 * Intended to be held in bulk by AssemblyOperator, alongside other
22 * GeometryWriterNode subclasses, with no shared layout or relation assumed
23 * between items.
24 */
25class MAYAFLUX_API GeometryLeafNode : public GeometryWriterNode {
26public:
27 explicit GeometryLeafNode(size_t initial_capacity = 64);
28 explicit GeometryLeafNode(std::vector<Vertex> vertices);
29 explicit GeometryLeafNode(std::vector<glm::vec3> positions);
30
31 /// @brief Replace geometry with plain positions (color/scalar/normal/uv default).
32 void set_positions(std::vector<glm::vec3> positions);
33
34 /// @brief Replace geometry with fully specified vertices.
35 void set_geometry(std::vector<Vertex> vertices);
36
37 void update_vertex(size_t index, const Vertex& vertex);
38
39 [[nodiscard]] const std::vector<Vertex>& get_geometry() const { return m_items; }
40
41 /**
42 * @brief Mutable access for in-place edits. Does not itself mark the
43 * node dirty -- call set_geometry() (even with the same vector)
44 * or update_vertex() afterward so compute_frame() re-uploads.
45 */
46
47 void clear_geometry();
48
49 [[nodiscard]] size_t size() const { return m_items.size(); }
50
51 /**
52 * @brief No-op unless a mutator has run since the last call, so
53 * AssemblyOperator::process() calling this on every item every
54 * frame stays cheap regardless of how many items exist.
55 */
56 void compute_frame() override;
57
58protected:
59 void handle_topology_change() override { m_geometry_dirty = true; }
60
61private:
62 std::vector<Vertex> m_items;
63 bool m_geometry_dirty { true };
64};
65
66} // namespace MayaFlux::Nodes::GpuSync
void set_geometry(std::vector< Vertex > vertices)
Replace geometry with fully specified vertices.
const std::vector< Vertex > & get_geometry() const
void handle_topology_change() override
Called after set_primitive_topology() stores a different value.
void update_vertex(size_t index, const Vertex &vertex)
void set_positions(std::vector< glm::vec3 > positions)
Replace geometry with plain positions (color/scalar/normal/uv default).
GeometryWriterNode(uint32_t initial_capacity=1024)
Constructor.
Kakshya::Vertex Vertex
Definition VertexSpec.hpp:7