|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
Object that reacts to nearby entities when committed. More...
#include <Sensor.hpp>
Collaboration diagram for MayaFlux::Nexus::Sensor:Public Types | |
| using | PerceptionFn = std::function< void(const PerceptionContext &)> |
Public Member Functions | |
| void | clear_position () |
| Clear the position, disabling spatial queries for this object. | |
| const PerceptionFn & | fn () const |
| The perception function itself. | |
| const std::string & | fn_name () const |
| Identifier assigned to the perception function, empty if anonymous. | |
| uint32_t | id () const |
| Return the stable object id assigned by Fabric. | |
| void | invoke (const PerceptionContext &ctx) const |
| Invoke the perception function with the supplied context. | |
| const std::optional< glm::vec3 > & | position () const |
| Return the current position, if set. | |
| float | query_radius () const |
| Return the query radius. | |
| Sensor (float query_radius, PerceptionFn fn) | |
| Construct with a query radius and a perception function. | |
| Sensor (float query_radius, std::string fn_name, PerceptionFn fn) | |
| Construct with a query radius and a named perception function. | |
| void | set_fn_name (std::string name) |
| Set or replace the perception function's identifier. | |
| void | set_position (const glm::vec3 &p) |
| Set the position, enabling spatial queries for this object. | |
| void | set_query_radius (float r) |
| Set the query radius. | |
Private Attributes | |
| PerceptionFn | m_fn |
| std::string | m_fn_name |
| uint32_t | m_id { 0 } |
| std::optional< glm::vec3 > | m_position |
| float | m_query_radius |
Friends | |
| class | Fabric |
Object that reacts to nearby entities when committed.
Constructed with only a perception function and a query radius. Position is optional: call set_position before registering with Fabric if spatial queries are required. A Sensor without a position receives an empty spatial_results span on each commit.
The id is assigned by Fabric::wire and is stable for the object's lifetime.
Definition at line 19 of file Sensor.hpp.