MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nexus::Fabric Class Reference

Orchestrates spatial indexing and scheduling for Nexus objects. More...

#include <Fabric.hpp>

+ Collaboration diagram for MayaFlux::Nexus::Fabric:

Classes

struct  Registration
 

Public Types

enum class  Kind : uint8_t { Emitter , Sensor , Agent }
 

Public Member Functions

std::vector< uint32_t > all_ids () const
 List all registered entity ids in insertion order.
 
void commit ()
 Update all positions, publish the snapshot, fire all registered objects.
 
 Fabric (const Fabric &)=delete
 
 Fabric (Fabric &&)=delete
 
 Fabric (Vruta::TaskScheduler &scheduler, Vruta::EventManager &event_manager, float cell_size=1.0F)
 Construct with scheduler and event manager from the engine.
 
void fire (uint32_t id)
 Fire a single object against the current snapshot without republishing.
 
std::shared_ptr< Agentget_agent (uint32_t id) const
 Get the Agent registered under id.
 
std::shared_ptr< Emitterget_emitter (uint32_t id) const
 Get the Emitter registered under id.
 
std::shared_ptr< Sensorget_sensor (uint32_t id) const
 Get the Sensor registered under id.
 
std::vector< Kinesis::QueryResultk_nearest (const glm::vec3 &center, uint32_t k) const
 Find the k nearest objects to a point.
 
Kind kind (uint32_t id) const
 Return the kind of entity registered under id.
 
const std::string & name () const
 Assigned name, empty if the Fabric was constructed outside a Tapestry.
 
Fabricoperator= (const Fabric &)=delete
 
Fabricoperator= (Fabric &&)=delete
 
void remove (uint32_t id)
 Remove a registered object by id, cancelling any associated tasks.
 
std::shared_ptr< Emitter::InfluenceFnresolve_influence_fn (std::string_view name) const
 Look up a registered influence function by name.
 
std::shared_ptr< Sensor::PerceptionFnresolve_perception_fn (std::string_view name) const
 Look up a registered perception function by name.
 
void set_name (std::string name)
 Set or replace the Fabric's name.
 
Wiring wire (std::shared_ptr< Agent > agent)
 Begin wiring an Agent into the Fabric.
 
Wiring wire (std::shared_ptr< Emitter > emitter)
 Begin wiring an Emitter into the Fabric.
 
Wiring wire (std::shared_ptr< Sensor > sensor)
 Begin wiring a Sensor into the Fabric.
 
const Wiringwiring_for (uint32_t id) const
 Access the finalised wiring for an entity for introspection.
 
std::vector< Kinesis::QueryResultwithin_radius (const glm::vec3 &center, float radius) const
 Find all objects within a radius of a point.
 
 ~Fabric ()
 

Private Types

using Member = std::variant< std::shared_ptr< Emitter >, std::shared_ptr< Sensor >, std::shared_ptr< Agent > >
 

Private Member Functions

uint32_t assign_id (Member &m)
 
void fire (const Registration &reg) const
 

Private Attributes

Vruta::EventManagerm_event_manager
 
std::unique_ptr< Kinesis::SpatialIndex3Dm_index
 
std::unordered_map< std::string, std::shared_ptr< Emitter::InfluenceFn > > m_influence_fns
 
std::string m_name
 
uint32_t m_next_id { 1 }
 
std::unordered_map< std::string, std::shared_ptr< Sensor::PerceptionFn > > m_perception_fns
 
std::unordered_map< uint32_t, Registrationm_registrations
 
Vruta::TaskSchedulerm_scheduler
 

Friends

class Wiring
 

Detailed Description

Orchestrates spatial indexing and scheduling for Nexus objects.

Plain object, not a subsystem. Constructed with references to the engine's scheduler and event manager. Owns a Kinesis::SpatialIndex3D populated only for objects that have a position set.

Objects are registered via wire(), which returns a Wiring builder. The builder describes when and how the object's function is invoked. All coroutines and events are owned by the scheduler and event manager respectively. Fabric holds only the names needed to cancel them.

commit() updates all positions in the index, publishes the snapshot, and fires all registered objects. fire(id) fires a single object against the current snapshot without republishing.

Spatial queries read the last published snapshot and are safe from any thread.

Definition at line 37 of file Fabric.hpp.


The documentation for this class was generated from the following files: