MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
CompositeGeometryProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
5
7class GeometryWriterNode;
8}
9
10namespace MayaFlux::Buffers {
11
12/**
13 * @class CompositeGeometryProcessor
14 * @brief Aggregates multiple geometry nodes with independent topologies
15 *
16 * Similar to GeometryBindingsProcessor but aggregates all nodes into
17 * a single vertex buffer while tracking per-collection offsets and topologies.
18 *
19 * Each collection can have different primitive topology (LINE_LIST, LINE_STRIP,
20 * POINT_LIST, etc.) and will be rendered with separate RenderProcessors.
21 *
22 * Architecture:
23 * - Upload phase: Aggregate all vertices into single buffer (this processor)
24 * - Render phase: Multiple RenderProcessors, one per topology
25 *
26 * Usage:
27 * auto processor = std::make_shared<CompositeGeometryProcessor>();
28 * processor->add_geometry("path", path_node, PrimitiveTopology::LINE_STRIP);
29 * processor->add_geometry("normals", normals_node, PrimitiveTopology::LINE_LIST);
30 *
31 * buffer->set_default_processor(processor);
32 *
33 * auto collection = processor->get_collection("path");
34 * render->set_vertex_range(collection.vertex_offset, collection.vertex_count);
35 */
36class MAYAFLUX_API CompositeGeometryProcessor : public VKBufferProcessor {
37public:
39 std::string name;
40 std::shared_ptr<Nodes::GpuSync::GeometryWriterNode> node;
42
43 uint32_t vertex_offset;
44 uint32_t vertex_count;
45
46 std::optional<Kakshya::VertexLayout> vertex_layout;
47 };
48
50
51 /**
52 * @brief Add a geometry collection
53 * @param name Unique identifier for this collection
54 * @param node GeometryWriterNode to aggregate
55 * @param topology Primitive topology for rendering this collection
56 */
57 void add_geometry(
58 const std::string& name,
59 const std::shared_ptr<Nodes::GpuSync::GeometryWriterNode>& node,
61
62 /**
63 * @brief Remove a geometry collection
64 */
65 void remove_geometry(const std::string& name);
66
67 /**
68 * @brief Get collection metadata
69 * @return Optional collection if exists
70 */
71 [[nodiscard]] std::optional<GeometryCollection> get_collection(const std::string& name) const;
72
73 /**
74 * @brief Get all collections (for RenderProcessor creation)
75 */
76 [[nodiscard]] const std::vector<GeometryCollection>& get_collections() const { return m_collections; }
77
78 /**
79 * @brief Get collection count
80 */
81 [[nodiscard]] size_t get_collection_count() const { return m_collections.size(); }
82
83 /**
84 * @brief BufferProcessor interface - aggregates all geometry
85 */
86 void processing_function(const std::shared_ptr<Buffer>& buffer) override;
87
88private:
89 std::vector<GeometryCollection> m_collections;
90 std::vector<uint8_t> m_staging_aggregate;
91};
92
93} // namespace MayaFlux::Buffers
size_t get_collection_count() const
Get collection count.
const std::vector< GeometryCollection > & get_collections() const
Get all collections (for RenderProcessor creation)
Aggregates multiple geometry nodes with independent topologies.
PrimitiveTopology
Vertex assembly primitive topology.