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

◆ as_mesh_vertex_access()

MAYAFLUX_API std::optional< VertexAccess > MayaFlux::Kakshya::as_mesh_vertex_access ( const DataVariant variant,
const VertexAccessConfig config = {} 
)

Convert DataVariant to mesh-vertex-compatible bytes.

Output layout matches VertexLayout::for_meshes(): stride 60, position (vec3, offset 0), color (vec3, offset 12), weight (float, offset 24), uv (vec2, offset 28), normal (vec3, offset 36), tangent (vec3, offset 48). Compatible with mesh.vert.spv without any user-defined shaders.

Parameters
variantSource data.
configDefault attribute values (color, weight, uv).
Returns
Populated VertexAccess, or std::nullopt on incompatible type.

Definition at line 347 of file VertexAccess.cpp.

350{
351 auto positions = extract_positions(variant);
352 if (positions.empty()) {
353 MF_ERROR(Journal::Component::Kakshya, Journal::Context::Runtime,
354 "as_mesh_vertex_access: unsupported or empty variant");
355 return std::nullopt;
356 }
357
358 const auto count = static_cast<uint32_t>(positions.size());
359 VertexAccess va;
360 va.conversion_buffer.resize((size_t)count * 60);
361 write_mesh_vertices(positions, config, va.conversion_buffer.data());
362 va.data_ptr = va.conversion_buffer.data();
363 va.byte_count = va.conversion_buffer.size();
364 va.layout = VertexLayout::for_meshes();
365 va.layout.vertex_count = count;
366 return va;
367}
#define MF_ERROR(comp, ctx,...)
Eigen::Index count

References MayaFlux::Kakshya::VertexAccess::byte_count, MayaFlux::Kakshya::VertexAccess::conversion_buffer, count, MayaFlux::Kakshya::VertexAccess::data_ptr, MayaFlux::Kakshya::VertexLayout::for_meshes(), MayaFlux::Journal::Kakshya, MayaFlux::Kakshya::VertexAccess::layout, MF_ERROR, MayaFlux::Journal::Runtime, and MayaFlux::Kakshya::VertexLayout::vertex_count.

Referenced by MayaFlux::Buffers::GeometryWriteProcessor::processing_function().

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