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

◆ commit()

void MayaFlux::Nexus::Fabric::commit ( )

Update all positions, publish the snapshot, fire all registered objects.

For each object with a position, calls m_index->update() then m_index->publish(). Then fires each object's function with a context built from the new snapshot.

Definition at line 182 of file Fabric.cpp.

183{
184 for (auto& [id, reg] : m_registrations) {
185 std::visit([&](const auto& ptr) {
186 if (!ptr->m_position.has_value()) {
187 return;
188 }
189 if (reg.spatial_id.has_value()) {
190 m_index->update(*reg.spatial_id, *ptr->m_position);
191 } else {
192 reg.spatial_id = m_index->insert(*ptr->m_position);
193 }
194 },
195 reg.member);
196 }
197
198 m_index->publish();
199
200 if (!m_expanses.empty()) {
201 std::unordered_map<uint32_t, uint32_t> entity_of;
202 entity_of.reserve(m_registrations.size());
203 for (const auto& [id, reg] : m_registrations) {
204 if (reg.spatial_id.has_value()) {
205 entity_of.emplace(*reg.spatial_id, id);
206 }
207 }
208
209 auto snapshot = m_index->all();
210 for (auto& [spatial_id, position] : snapshot) {
211 if (const auto it = entity_of.find(spatial_id); it != entity_of.end()) {
212 spatial_id = it->second;
213 }
214 }
215
216 for (auto& [xid, expanse] : m_expanses)
217 expanse->evaluate(m_fabric_id, snapshot);
218 }
219
220 for (auto& [id, reg] : m_registrations) {
221 if (reg.commit_driven) {
222 fire(reg);
223 }
224 }
225}
std::optional< glm::vec3 > position
Definition Decoder.cpp:93
const uint8_t * ptr
std::unordered_map< uint32_t, std::shared_ptr< Expanse > > m_expanses
Definition Fabric.hpp:294
std::unique_ptr< Kinesis::SpatialIndex3D > m_index
Definition Fabric.hpp:292
void fire(uint32_t id)
Fire a single object against the current snapshot without republishing.
Definition Fabric.cpp:227
std::unordered_map< uint32_t, Registration > m_registrations
Definition Fabric.hpp:293

References fire(), m_expanses, m_fabric_id, m_index, m_registrations, position, and ptr.

+ Here is the call graph for this function: