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

◆ evaluate()

void MayaFlux::Nexus::Expanse::evaluate ( uint32_t  fabric_id,
std::span< const std::pair< uint32_t, glm::vec3 > >  snapshot 
)

Evaluate a spatial snapshot from one Fabric against this Expanse.

Runs the containment predicate against each position in snapshot, diffs the result against the previous occupant set for fabric_id, fires on_enter / on_exit for the difference, and updates the stored set. Each Fabric maintains independent occupant state.

Parameters
fabric_idStable id of the calling Fabric.
snapshotAll indexed positions from that Fabric's spatial index.

Definition at line 7 of file Expanse.cpp.

9{
10 auto& prev = m_occupants_by_fabric[fabric_id];
11
12 std::unordered_set<uint32_t> inside;
13 for (const auto& [eid, pos] : snapshot) {
14 if (m_contains && m_contains(pos))
15 inside.insert(eid);
16 }
17
18 if (m_on_enter) {
19 for (uint32_t eid : inside) {
20 if (!prev.contains(eid))
21 m_on_enter(eid);
22 }
23 }
24
25 if (m_on_exit) {
26 for (uint32_t eid : prev) {
27 if (!inside.contains(eid))
28 m_on_exit(eid);
29 }
30 }
31
32 if (inside.empty()) {
33 m_occupants_by_fabric.erase(fabric_id);
34 } else {
35 prev = std::move(inside);
36 }
37}
std::unordered_map< uint32_t, std::unordered_set< uint32_t > > m_occupants_by_fabric
Definition Expanse.hpp:155

References m_contains, m_occupants_by_fabric, m_on_enter, and m_on_exit.