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

◆ centroid() [4/7]

glm::vec3 MayaFlux::Kinesis::centroid ( std::span< const std::byte >  bytes,
size_t  stride,
size_t  offset = 0 
)
inlinenoexcept

Arithmetic centroid of the positions in interleaved vertex bytes.

Every Kakshya vertex record is 60 bytes with the position at offset 0, but any stride and offset work, so readback bytes, node vertex data and MeshData all go through here without a typed copy.

Parameters
bytesInterleaved records. A trailing partial record is ignored.
strideBytes per record.
offsetByte offset of the vec3 position within a record.
Returns
Mean position, or the zero vector when no whole record fits or stride is too small to hold a position.

Definition at line 174 of file Morphology.hpp.

178{
179 if (stride < offset + sizeof(glm::vec3))
180 return glm::vec3(0.0F);
181 const size_t count = bytes.size() / stride;
182 if (count == 0)
183 return glm::vec3(0.0F);
184 glm::vec3 acc(0.0F);
185 for (size_t i = 0; i < count; ++i)
186 acc += position_at(bytes, stride, offset, i).value_or(glm::vec3(0.0F));
187 return acc / static_cast<float>(count);
188}
uint64_t offset
Definition Composite.cpp:10
size_t count
std::optional< glm::vec3 > position_at(std::span< const std::byte > bytes, size_t stride, size_t offset, size_t index) noexcept
Position of one record in interleaved vertex bytes.

References count, offset, and position_at().

+ Here is the call graph for this function: