13 : m_vertex_variant(vertex_variant)
14 , m_index_variant(index_variant)
40 "MeshInsertion: submesh stride {} does not match established stride {}; "
47 "MeshInsertion: submesh attribute count {} does not match established count {}; "
60 std::span<const uint8_t> vertex_bytes,
61 std::span<const uint32_t> index_data,
66 "MeshInsertion::insert_flat: layout stride_bytes is zero");
71 "MeshInsertion::insert_flat: vertex_bytes {} not a multiple of stride {}",
75 if (index_data.size() % 3 != 0) {
77 "MeshInsertion::insert_flat: index count {} is not a multiple of 3",
82 m_vertex_variant = std::vector<uint8_t>(vertex_bytes.begin(), vertex_bytes.end());
83 m_index_variant = std::vector<uint32_t>(index_data.begin(), index_data.end());
93 "MeshInsertion::insert_flat: {} vertices, {} indices ({} faces)",
102 std::span<const uint8_t> vertex_bytes,
103 std::span<const uint32_t> index_data,
104 std::string_view name,
105 std::string_view material_name,
110 "MeshInsertion::insert_submesh: layout stride_bytes is zero");
115 "MeshInsertion::insert_submesh: vertex_bytes {} not a multiple of stride {}",
119 if (index_data.size() % 3 != 0) {
121 "MeshInsertion::insert_submesh: index count {} is not a multiple of 3",
139 const auto submesh_vcount =
static_cast<uint32_t
>(vertex_bytes.size() / layout.
stride_bytes);
142 vbuf.insert(vbuf.end(), vertex_bytes.begin(), vertex_bytes.end());
144 ibuf.reserve(ibuf.size() + index_data.size());
145 for (
const uint32_t idx : index_data) {
151 sub.
index_count =
static_cast<uint32_t
>(index_data.size());
153 sub.
name = std::string(name);
166 "MeshInsertion::insert_submesh: '{}' +{} vertices, +{} indices, "
167 "running totals: {} vertices / {} indices",
168 name.empty() ?
"<unnamed>" : name,
169 submesh_vcount, index_data.size(),
196 "MeshInsertion::build: no data inserted");
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::optional< RegionGroup > m_submeshes
void ensure_vertex_storage()
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.
DataVariant & m_vertex_variant
MeshInsertion(DataVariant &vertex_variant, DataVariant &index_variant)
Construct with mutable references to the two storage variants.
std::optional< MeshAccess > build() const
Produce a MeshAccess over the current variant contents.
uint32_t m_vertex_count
Running total across all submitted batches.
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).
bool validate_layout(const VertexLayout &incoming) const
void ensure_index_storage()
DataVariant & m_index_variant
void clear()
Clear both variants and reset all internal state.
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::optional< MeshAccess > as_mesh_access(const DataVariant &vertex_variant, const DataVariant &index_variant, const VertexLayout &layout, std::optional< RegionGroup > submeshes)
Construct a MeshAccess from two DataVariant instances.
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.
Region to_region() const
Convert this subrange to a Region for use in RegionGroup.
uint32_t vertex_offset
Base vertex added to each index (large-mesh batching)
std::string material_name
Byte-range descriptor for one submesh within the shared index buffer.
Organizes related signal regions into a categorized collection.
uint32_t stride_bytes
Total bytes per vertex (stride in Vulkan terms) e.g., 3 floats (position) + 3 floats (normal) = 24 by...
uint32_t vertex_count
Total number of vertices in this buffer.
std::vector< VertexAttributeLayout > attributes
All attributes that make up one vertex Ordered by shader location (0, 1, 2, ...)
Complete description of vertex data layout in a buffer.