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

◆ as_point_vertex_access()

MAYAFLUX_API std::optional< VertexAccess > MayaFlux::Kakshya::as_point_vertex_access ( std::span< const DataVariant channels,
const VertexAccessConfig config = {} 
)

Assemble point-vertex-compatible bytes from one or more data channels.

channels[0] must supply position data (vec3 or uint8_t interleaved). channels[1..5] optionally supply color, scalar, uv, normal, tangent in canonical field order. Missing trailing channels are filled from config. A single uint8_t channel of N*60 bytes is passed through zero-copy.

Parameters
channelsSource channels in canonical field order.
configDefault attribute values for absent channels.
Returns
Populated VertexAccess, or std::nullopt on empty or incompatible input.

Definition at line 89 of file VertexAccess.cpp.

92{
93 if (channels.empty()) {
94 MF_ERROR(Journal::Component::Kakshya, Journal::Context::Runtime,
95 "as_point_vertex_access: no channels supplied");
96 return std::nullopt;
97 }
98
99 // Zero-copy path: single uint8_t channel of N*60 bytes is already interleaved.
100 if (channels.size() == 1) {
101 if (const auto* b = std::get_if<std::vector<uint8_t>>(&channels[0])) {
102 if (b->size() % 60 != 0) {
103 MF_ERROR(Journal::Component::Kakshya, Journal::Context::Runtime,
104 "as_point_vertex_access: uint8_t byte count {} not a multiple of 60",
105 b->size());
106 return std::nullopt;
107 }
108 const auto count = static_cast<uint32_t>(b->size() / 60);
109 auto layout = VertexLayout::for_points();
110 layout.vertex_count = count;
111 return VertexAccess { .data_ptr = b->data(), .byte_count = b->size(), .layout = layout };
112 }
113 }
114
115 const size_t count = channel_view(channels[0]).count;
116 if (count == 0) {
117 MF_ERROR(Journal::Component::Kakshya, Journal::Context::Runtime,
118 "as_point_vertex_access: position channel (slot 0) is empty or unsupported");
119 return std::nullopt;
120 }
121
122 VertexAccess va;
123 va.conversion_buffer.resize(count * 60);
124 assemble_vertices(channels, count, config, config.default_size,
125 va.conversion_buffer.data());
126 va.data_ptr = va.conversion_buffer.data();
127 va.byte_count = va.conversion_buffer.size();
128 va.layout = VertexLayout::for_points();
129 va.layout.vertex_count = static_cast<uint32_t>(count);
130 return va;
131}
#define MF_ERROR(comp, ctx,...)
size_t b
size_t count

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

Referenced by as_vertex_access(), and MayaFlux::Buffers::DataWriteProcessor::upload_vertex().

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