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

◆ seed() [1/2]

void MayaFlux::Buffers::VolumeGridBuffer::seed ( const std::string &  name,
const Kinesis::SpatialField &  field 
)

Write initial values into a scalar field from a Kinesis field.

Parameters
nameField name. Must have stride sizeof(float).
fieldSampled at each cell centre in world space.

Definition at line 519 of file VolumeGridBuffer.cpp.

520{
521 const auto* decl = find_field(name, "seed");
522 if (!decl) {
523 return;
524 }
525
526 if (decl->stride_bytes != sizeof(float)) {
528 "VolumeGridBuffer::seed: field '{}' has stride {}, SpatialField requires {}",
529 name, decl->stride_bytes, sizeof(float));
530 return;
531 }
532
533 const glm::uvec3 res = m_lattice.resolution;
534 std::vector<float> values(m_lattice.cell_count());
535
536 size_t i = 0;
537 for (uint32_t z = 0; z < res.z; ++z) {
538 for (uint32_t y = 0; y < res.y; ++y) {
539 for (uint32_t x = 0; x < res.x; ++x) {
540 values[i++] = field(m_lattice.cell_center({ x, y, z }));
541 }
542 }
543 }
544
545 seed_raw(name, values.data(), values.size() * sizeof(float));
546}
#define MF_ERROR(comp, ctx,...)
std::vector< std::byte > values
Definition VDBWriter.cpp:26
std::string name
Definition VKDevice.cpp:123
const Field * find_field(const std::string &name, const char *context) const
Resolve a field by name.
void seed_raw(const std::string &name, const void *data, size_t size)
Write initial values into a field from raw host memory.
@ BufferManagement
Buffer Management (Buffers::BufferManager, creating buffers)
@ Buffers
Buffers, Managers, processors and processing chains.
size_t cell_count() const noexcept
Total cell count.
Definition Lattice.hpp:36
glm::uvec3 resolution
Cell count per axis. Zero on any axis is invalid.
Definition Lattice.hpp:26
glm::vec3 cell_center(const glm::uvec3 &c) const noexcept
World position of a cell's centre.
Definition Lattice.hpp:70

References MayaFlux::Journal::BufferManagement, MayaFlux::Journal::Buffers, MayaFlux::Kinesis::Lattice3D::cell_center(), MayaFlux::Kinesis::Lattice3D::cell_count(), find_field(), m_lattice, MF_ERROR, name, MayaFlux::Kinesis::Lattice3D::resolution, seed_raw(), and values.

+ Here is the call graph for this function: