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

◆ declare_fields()

void MayaFlux::Buffers::SpatialHashConfig::declare_fields ( const std::shared_ptr< NetworkGeometryBuffer > &  buffer) const

Declare the four state fields the hash build stages read and write, sized from this config.

Parameters
bufferBuffer to declare on. Fields already present under these names are left untouched (NetworkGeometryBuffer::declare_state rejects the duplicate and logs, matching its own documented behaviour).

Declares hash_cell_count/hash_cell_start/hash_cell_cursor at cell_count() elements each, and hash_particle_index at particle_count elements. Call once before attaching HashClearProcessor/ HashCountProcessor/HashScanProcessor/HashScatterProcessor to the buffer's chain. All four fields are single-slot: every stage fully overwrites the ones it owns each cycle rather than reading a previous cycle's value, so none of them need a second ping-pong slot.

Also declares hash_cluster_id, one uint32 per particle, at particle_count elements. Unlike the four fields above it is written by no dispatch at all: NetworkGeometryBuffer uploads it once, at wiring time, from PhysicsOperator::get_collections(), since cluster membership is fixed the moment a collection is added and never changes cycle to cycle. Declared here rather than by MutationConfig because it is consumed by any hash-based neighbour query, not only the claim protocol: HashDensityColorProcessor reads it too, and a caller can enable density colouring with no absorb_radius at all, in which case MutationConfig::declare_fields never runs. Every entry is 0 when the operator carries at most one collection, so every cluster-aware guard built on this field is a no-op for the ordinary single-population case.

Definition at line 84 of file SpatialHashProcessor.cpp.

85{
86 const uint32_t cells = cell_count();
87 buffer->declare_state("hash_cell_count", cells, sizeof(uint32_t), false);
88 buffer->declare_state("hash_cell_start", cells, sizeof(uint32_t), false);
89 buffer->declare_state("hash_cell_cursor", cells, sizeof(uint32_t), false);
90 buffer->declare_state("hash_particle_index", particle_count, sizeof(uint32_t), false);
91
92 if (!buffer->has_state("hash_cluster_id")) {
93 buffer->declare_state("hash_cluster_id", particle_count, sizeof(uint32_t), false);
94 }
95}
uint32_t cell_count() const
Total cell count, grid_dims.x * grid_dims.y * grid_dims.z.

References cell_count(), and particle_count.

Referenced by MayaFlux::Buffers::NetworkGeometryBuffer::wire_field_operators().

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