MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MeshWriterNode.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "VertexSpec.hpp"
5
7
8/**
9 * @class MeshWriterNode
10 * @brief Indexed triangle mesh for static or infrequently-updated geometry.
11 *
12 * Holds CPU-side MeshVertex and uint32_t index arrays.
13 * Topology is always TRIANGLE_LIST. Index buffer is uploaded via
14 * GeometryWriterNode::set_indices() on compute_frame().
15 *
16 * For GPU-deformed mesh data, populate m_vertices externally via
17 * set_mesh() and let compute_frame() handle the upload on the next cycle.
18 */
19class MAYAFLUX_API MeshWriterNode : public GeometryWriterNode {
20public:
21 explicit MeshWriterNode(size_t initial_vertex_capacity = 1024);
22
23 /**
24 * @brief Replace all vertex and index data atomically.
25 * @param vertices Mesh vertices
26 * @param indices Triangle indices (must be a multiple of 3)
27 */
28 void set_mesh(
29 std::span<const MeshVertex> vertices,
30 std::span<const uint32_t> indices);
31
32 /**
33 * @brief Replace vertex array only; index array is unchanged.
34 * @param vertices New vertex data
35 */
36 void set_mesh_vertices(std::span<const MeshVertex> vertices);
37
38 /**
39 * @brief Replace index array only; vertex array is unchanged.
40 * @param indices New index data (must be a multiple of 3)
41 */
42 void set_mesh_indices(std::span<const uint32_t> indices);
43
44 [[nodiscard]] const std::vector<MeshVertex>& get_mesh_vertices() const { return m_vertices; }
45 [[nodiscard]] const std::vector<uint32_t>& get_mesh_indices() const { return m_indices; }
46 [[nodiscard]] size_t get_mesh_vertex_count() const { return m_vertices.size(); }
47 [[nodiscard]] size_t get_mesh_face_count() const { return m_indices.size() / 3; }
48
49 void clear_mesh();
50
51 [[nodiscard]] Portal::Graphics::PrimitiveTopology get_primitive_topology() const override;
52
53 void compute_frame() override;
54
55private:
56 std::vector<MeshVertex> m_vertices;
57 std::vector<uint32_t> m_indices;
58};
59
60} // namespace MayaFlux::Nodes::GpuSync
Base class for nodes that generate 3D geometry data.
const std::vector< uint32_t > & get_mesh_indices() const
const std::vector< MeshVertex > & get_mesh_vertices() const
Indexed triangle mesh for static or infrequently-updated geometry.
PrimitiveTopology
Vertex assembly primitive topology.