MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
NetworkGeometryProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
4
6class NodeNetwork;
7class ParticleNetwork;
8} // namespace MayaFlux::Nodes
9
10namespace MayaFlux::Buffers {
11
12/**
13 * @class NetworkGeometryProcessor
14 * @brief BufferProcessor that aggregates geometry from NodeNetwork nodes
15 *
16 * Extracts geometry from all nodes within a network and uploads to GPU as
17 * a single vertex buffer. Handles network-specific patterns like ParticleNetwork
18 * and PointCloudNetwork.
19 *
20 * Key Differences from GeometryBindingsProcessor:
21 * - Operates on NodeNetwork (not single GeometryWriterNode)
22 * - Aggregates vertices from ALL internal nodes
23 * - Type-aware: special handling for ParticleNetwork, PointCloudNetwork, etc.
24 *
25 * Behavior:
26 * - Extracts ALL node geometry from bound networks
27 * - Aggregates into single vertex buffer
28 * - Uses staging buffer for device-local targets
29 * - Supports multiple network bindings (different networks → different buffers)
30 *
31 * Usage:
32 * ```cpp
33 * auto particles = std::make_shared<ParticleNetwork>(1000);
34 * auto vertex_buffer = std::make_shared<VKBuffer>(...);
35 *
36 * auto processor = std::make_shared<NetworkGeometryProcessor>();
37 * processor->bind_network("particles", particles, vertex_buffer);
38 *
39 * vertex_buffer->set_default_processor(processor);
40 * vertex_buffer->process_default(); // Aggregates all 1000 Poiints -> GPU
41 * ```
42 */
43class MAYAFLUX_API NetworkGeometryProcessor : public VKBufferProcessor {
44public:
46
47 /**
48 * @brief Structure representing a network geometry binding
49 */
51 std::shared_ptr<Nodes::Network::NodeNetwork> network;
52 std::shared_ptr<VKBuffer> gpu_vertex_buffer;
53 std::shared_ptr<VKBuffer> staging_buffer;
54 };
55
56 /**
57 * @brief Bind a network to a GPU vertex buffer
58 * @param name Logical name for this binding
59 * @param network NodeNetwork to aggregate geometry from
60 * @param vertex_buffer GPU vertex buffer to upload to
61 *
62 * If vertex_buffer is device-local, a staging buffer is automatically created.
63 */
64 void bind_network(
65 const std::string& name,
66 const std::shared_ptr<Nodes::Network::NodeNetwork>& network,
67 const std::shared_ptr<VKBuffer>& vertex_buffer);
68
69 /**
70 * @brief Remove a network binding
71 * @param name Name of binding to remove
72 */
73 void unbind_network(const std::string& name);
74
75 /**
76 * @brief Check if a binding exists
77 * @param name Binding name
78 * @return True if binding exists
79 */
80 [[nodiscard]] bool has_binding(const std::string& name) const;
81
82 /**
83 * @brief Get all binding names
84 * @return Vector of binding names
85 */
86 [[nodiscard]] std::vector<std::string> get_binding_names() const;
87
88 /**
89 * @brief Get number of active bindings
90 * @return Binding count
91 */
92 [[nodiscard]] size_t get_binding_count() const;
93
94 /**
95 * @brief Get a specific binding
96 * @param name Binding name
97 * @return Optional containing binding if exists
98 */
99 [[nodiscard]] std::optional<NetworkBinding> get_binding(const std::string& name) const;
100
101 /**
102 * @brief BufferProcessor interface - aggregates and uploads network geometry
103 * @param buffer The buffer this processor is attached to
104 *
105 * For each bound network:
106 * 1. Extract vertices from all internal nodes
107 * 2. Aggregate into single vertex array
108 * 3. Upload to GPU vertex buffer
109 */
110 void processing_function(const std::shared_ptr<Buffer>& buffer) override;
111
112private:
113 std::unordered_map<std::string, NetworkBinding> m_bindings;
114 std::vector<uint8_t> m_staging_aggregate;
115};
116
117} // namespace MayaFlux::Buffers
Core::GlobalNetworkConfig network
Definition Config.cpp:37
std::unordered_map< std::string, NetworkBinding > m_bindings
BufferProcessor that aggregates geometry from NodeNetwork nodes.
Structure representing a network geometry binding.