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

◆ triangle_soup_mesh()

MAYAFLUX_API std::optional< Kakshya::MeshData > MayaFlux::Buffers::triangle_soup_mesh ( std::span< const uint8_t >  vertex_bytes)

Wrap non-indexed triangle vertices as MeshData.

Parameters
vertex_bytesInterleaved Kakshya::MeshVertex records; the vertex count must be a nonzero multiple of 3.
Returns
MeshData with a sequential index array (0..N-1) and the canonical mesh layout; nullopt, with an error logged, if MeshInsertion rejects it.

Definition at line 438 of file StagingUtils.cpp.

439{
440 std::vector<uint32_t> indices(vertex_bytes.size() / sizeof(Kakshya::MeshVertex));
441 std::ranges::iota(indices, 0U);
442
443 auto mesh_data = Kakshya::MeshData::empty();
444 Kakshya::MeshInsertion ins(mesh_data.vertex_variant, mesh_data.index_variant);
445 ins.insert_flat(
446 vertex_bytes,
447 std::span<const uint32_t>(indices),
448 Kakshya::VertexLayout::for_meshes(sizeof(Kakshya::MeshVertex)));
449 auto access = ins.build();
450 if (!access) {
451 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
452 "triangle_soup_mesh: MeshInsertion::build() failed");
453 return std::nullopt;
454 }
455 mesh_data.layout = access->layout;
456
457 return mesh_data;
458}
#define MF_ERROR(comp, ctx,...)
std::vector< uint32_t > indices
Write counterpart to MeshAccess.
Vertex type for indexed triangle mesh primitives (TRIANGLE_LIST topology)

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Kakshya::MeshInsertion::build(), MayaFlux::Kakshya::MeshData::empty(), MayaFlux::Kakshya::VertexLayout::for_meshes(), indices, MayaFlux::Kakshya::MeshInsertion::insert_flat(), and MF_ERROR.

Referenced by download_compute_mesh(), and MayaFlux::Buffers::DataReadProcessor::resolve_mesh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: