MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ get_mesh_data()

std::optional< Kakshya::MeshData > MayaFlux::Nodes::GpuSync::MeshWriterNode::get_mesh_data ( ) const

The node's current geometry as MeshData, the inverse of set_mesh(const MeshData&).

Vertices and indices are copied as stored, in the node's own space with no transform applied. The canonical mesh layout is used.

Returns
The mesh, or nullopt when the node has no vertices or no indices.

Definition at line 39 of file MeshWriterNode.cpp.

40{
41 if (m_vertices.empty() || m_indices.empty()) {
42 return std::nullopt;
43 }
44
45 auto mesh_data = Kakshya::MeshData::empty();
46 Kakshya::MeshInsertion ins(mesh_data.vertex_variant, mesh_data.index_variant);
47 ins.insert_flat(
48 std::span<const uint8_t>(
49 reinterpret_cast<const uint8_t*>(m_vertices.data()),
50 m_vertices.size() * sizeof(MeshVertex)),
51 std::span<const uint32_t>(m_indices),
53
54 const auto access = ins.build();
55 if (!access) {
56 return std::nullopt;
57 }
58 mesh_data.layout = access->layout;
59
60 return mesh_data;
61}
Kakshya::MeshVertex MeshVertex
static MeshData empty()
Construct an empty MeshData with the canonical 60-byte mesh layout.
Definition MeshData.hpp:49
static VertexLayout for_meshes(uint32_t stride=60)
Factory: layout for MeshVertex (position, color, weight, uv, normal, tangent)

References MayaFlux::Kakshya::MeshInsertion::build(), MayaFlux::Kakshya::MeshData::empty(), MayaFlux::Kakshya::VertexLayout::for_meshes(), MayaFlux::Kakshya::MeshInsertion::insert_flat(), m_indices, and m_vertices.

+ Here is the call graph for this function: