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

Write counterpart to VertexAccess: splits interleaved vertex bytes into typed channels. More...

#include <VertexInsertion.hpp>

+ Collaboration diagram for MayaFlux::Kakshya::VertexInsertion:

Public Member Functions

void clear ()
 Empty the channel list and forget the last layout.
 
bool insert_interleaved (std::span< const uint8_t > vertex_bytes, const VertexLayout &layout)
 Replace the channel list with the attributes of interleaved vertices.
 
const VertexLayout & layout () const noexcept
 Layout of the last successful insertion, with vertex_count set to the decoded count.
 
uint32_t vertex_count () const noexcept
 Number of vertices decoded by the last successful insertion.
 
 VertexInsertion (std::vector< DataVariant > &channels)
 Construct with a mutable reference to the channel list.
 

Static Public Member Functions

static bool can_decode (const VertexLayout &layout) noexcept
 Whether a layout can be split into typed channels.
 

Private Attributes

std::vector< DataVariant > & m_channels
 
VertexLayout m_layout
 

Detailed Description

Write counterpart to VertexAccess: splits interleaved vertex bytes into typed channels.

Parallel to MeshInsertion and DataInsertion: holds a mutable reference to a channel list and populates it. Each VertexLayout attribute becomes one DataVariant, in layout order, holding the attribute for every vertex:

VERTEX_POSITIONS_3D, NORMALS_3D, TANGENTS_3D, COLORS_RGB -> vector<glm::vec3> TEXTURE_COORDS_2D -> vector<glm::vec2> VERTEX_COLORS_RGBA -> vector<glm::vec4> SCALAR_F32 -> vector<float>

For the canonical point, line and mesh layouts the channel order matches the slot order as_point_vertex_access() and its siblings consume, so a read channel list can be written back without reordering.

Nothing is written unless the layout and byte count are both valid.

Usage:

std::vector<DataVariant> channels;
if (ins.insert_interleaved(bytes, layout)) {
auto& positions = std::get<std::vector<glm::vec3>>(channels[0]);
}
std::vector< glm::vec3 > positions
uint32_t channels
const VertexLayout & layout() const noexcept
Layout of the last successful insertion, with vertex_count set to the decoded count.
Write counterpart to VertexAccess: splits interleaved vertex bytes into typed channels.

Definition at line 35 of file VertexInsertion.hpp.


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