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

◆ as_line_vertex_access()

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

Assemble line-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, thickness, uv, normal, tangent in canonical field order. Missing trailing channels are filled from config; slot 2 defaults to config.default_thickness. 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 133 of file VertexAccess.cpp.

136{
137 if (channels.empty()) {
138 MF_ERROR(Journal::Component::Kakshya, Journal::Context::Runtime,
139 "as_line_vertex_access: no channels supplied");
140 return std::nullopt;
141 }
142
143 if (channels.size() == 1) {
144 if (const auto* b = std::get_if<std::vector<uint8_t>>(&channels[0])) {
145 if (b->size() % 60 != 0) {
146 MF_ERROR(Journal::Component::Kakshya, Journal::Context::Runtime,
147 "as_line_vertex_access: uint8_t byte count {} not a multiple of 60",
148 b->size());
149 return std::nullopt;
150 }
151 const auto count = static_cast<uint32_t>(b->size() / 60);
152 auto layout = VertexLayout::for_lines();
153 layout.vertex_count = count;
154 return VertexAccess { .data_ptr = b->data(), .byte_count = b->size(), .layout = layout };
155 }
156 }
157
158 const size_t count = channel_view(channels[0]).count;
159 if (count == 0) {
160 MF_ERROR(Journal::Component::Kakshya, Journal::Context::Runtime,
161 "as_line_vertex_access: position channel (slot 0) is empty or unsupported");
162 return std::nullopt;
163 }
164
165 VertexAccess va;
166 va.conversion_buffer.resize(count * 60);
167 assemble_vertices(channels, count, config, config.default_thickness,
168 va.conversion_buffer.data());
169 va.data_ptr = va.conversion_buffer.data();
170 va.byte_count = va.conversion_buffer.size();
171 va.layout = VertexLayout::for_lines();
172 va.layout.vertex_count = static_cast<uint32_t>(count);
173 return va;
174}
#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_thickness, MayaFlux::Kakshya::VertexLayout::for_lines(), MayaFlux::Journal::Kakshya, MayaFlux::Kakshya::VertexAccess::layout, MF_ERROR, MayaFlux::Journal::Runtime, and MayaFlux::Kakshya::VertexLayout::vertex_count.

Referenced by MayaFlux::Buffers::DataWriteProcessor::upload_vertex().

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