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

◆ find_word_offset()

std::optional< uint32_t > MayaFlux::Kakshya::VertexLayout::find_word_offset ( DataModality  modality) const
inline

Word offset of the attribute matching the given modality, if any.

Parameters
modalityAttribute kind to search for, e.g. DataModality::VERTEX_POSITIONS_3D or VERTEX_COLORS_RGB.
Returns
Byte offset divided by 4, or nullopt when no attribute of that modality is present or its offset is not word-aligned.

The alignment check exists for GPU code addressing this record as a flat float/uint array rather than through a struct: GpuFieldOperator and the particle spatial hash both index by word, not byte.

Definition at line 70 of file VertexLayout.hpp.

71 {
72 for (const auto& attr : attributes) {
73 if (attr.component_modality == modality) {
74 if (attr.offset_in_vertex % 4 != 0) {
75 return std::nullopt;
76 }
77 return attr.offset_in_vertex / 4;
78 }
79 }
80 return std::nullopt;
81 }
std::vector< VertexAttributeLayout > attributes
All attributes that make up one vertex Ordered by shader location (0, 1, 2, ...)

References attributes.