|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
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< Agent > | get_agent (uint32_t id) const |
Get the Agent registered under id. | |
| std::shared_ptr< Emitter > | get_emitter (uint32_t id) const |
Get the Emitter registered under id. | |
| std::shared_ptr< Sensor > | get_sensor (uint32_t id) const |
Get the Sensor registered under id. | |
| std::vector< Kinesis::QueryResult > | k_nearest (const glm::vec3 ¢er, 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. | |
| Fabric & | operator= (const Fabric &)=delete |
| Fabric & | operator= (Fabric &&)=delete |
| void | remove (uint32_t id) |
| Remove a registered object by id, cancelling any associated tasks. | |
| std::shared_ptr< Emitter::InfluenceFn > | resolve_influence_fn (std::string_view name) const |
| Look up a registered influence function by name. | |
| std::shared_ptr< Sensor::PerceptionFn > | resolve_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 Wiring * | wiring_for (uint32_t id) const |
| Access the finalised wiring for an entity for introspection. | |
| std::vector< Kinesis::QueryResult > | within_radius (const glm::vec3 ¢er, 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 ®) const |
Private Attributes | |
| Vruta::EventManager & | m_event_manager |
| std::unique_ptr< Kinesis::SpatialIndex3D > | m_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, Registration > | m_registrations |
| Vruta::TaskScheduler & | m_scheduler |
Friends | |
| class | Wiring |
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.