MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kakshya::MeshInsertion Class Reference

Write counterpart to MeshAccess. More...

#include <MeshInsertion.hpp>

+ Collaboration diagram for MayaFlux::Kakshya::MeshInsertion:

Public Member Functions

std::optional< MeshAccessbuild () const
 Produce a MeshAccess over the current variant contents.
 
void clear ()
 Clear both variants and reset all internal state.
 
void insert_flat (std::span< const uint8_t > vertex_bytes, std::span< const uint32_t > index_data, const VertexLayout &layout)
 Insert a single flat mesh (no submesh tracking).
 
void insert_submesh (std::span< const uint8_t > vertex_bytes, std::span< const uint32_t > index_data, std::string_view name={}, std::string_view material_name={}, const VertexLayout &layout=VertexLayout::for_meshes(60))
 Append one submesh batch, accumulating into the shared buffers.
 
 MeshInsertion (DataVariant &vertex_variant, DataVariant &index_variant)
 Construct with mutable references to the two storage variants.
 

Private Member Functions

void ensure_index_storage ()
 
void ensure_vertex_storage ()
 
bool validate_layout (const VertexLayout &incoming) const
 

Private Attributes

uint32_t m_index_count = 0
 
DataVariantm_index_variant
 
VertexLayout m_layout
 
bool m_layout_set = false
 
std::optional< RegionGroupm_submeshes
 
uint32_t m_vertex_count = 0
 Running total across all submitted batches.
 
DataVariantm_vertex_variant
 

Detailed Description

Write counterpart to MeshAccess.

Parallel to EigenInsertion and DataInsertion: holds mutable references to two DataVariant targets and populates them with interleaved vertex bytes and flat uint32_t index data respectively. Callers supply typed spans; the class handles memcpy into the canonical storage and constructs the VertexLayout.

Submesh structure is recorded as a RegionGroup whose Regions map to the index sub-ranges of each submitted batch. Callers accumulate batches via insert_submesh() and then call build() to obtain a MeshAccess.

The vertex DataVariant always receives vector<uint8_t> (raw bytes). The index DataVariant always receives vector<uint32_t>. Neither variant is touched until insert_submesh() or insert_flat() is called.

Usage (single mesh, no submeshes):

DataVariant vbuf, ibuf;
MeshInsertion ins(vbuf, ibuf);
ins.insert_flat(
std::span<const uint8_t>{ raw_bytes, byte_count },
std::span<const uint32_t>{ indices, index_count },
auto access = ins.build();
Write counterpart to MeshAccess.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
Definition NDData.hpp:76
static VertexLayout for_meshes(uint32_t stride=60)
Factory: layout for MeshVertex (position, color, weight, uv, normal, tangent)

Usage (multi-submesh, e.g. from assimp):

DataVariant vbuf, ibuf;
MeshInsertion ins(vbuf, ibuf);
for (auto& sub : model.meshes) {
ins.insert_submesh(sub.vertex_bytes, sub.indices,
sub.name, sub.material_name);
}
auto access = ins.build();

Definition at line 48 of file MeshInsertion.hpp.


The documentation for this class was generated from the following files: