|
MayaFlux 1.0.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_perception () |
| Remove the source set with set_perception(). | |
| 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. | |
| Sensor (float query_radius=1.0F) | |
| Construct with only a query radius, for a Sensor whose behaviour comes from a typed perception. | |
| void | set_fn_name (std::string name) |
| Set or replace the perception function's identifier. | |
| template<typename T > | |
| void | set_perception (typename Perception< T >::Source source, typename Perception< T >::Target target) |
| Set the one source of a perception of any type. | |
| 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 } |
| PerceptionFn | m_perception |
| std::optional< glm::vec3 > | m_position |
| float | m_query_radius |
Friends | |
| class | Fabric |
Object that reacts to nearby entities when committed.
Constructed with a query radius and, optionally, a perception function. 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.