MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Locus.cpp
Go to the documentation of this file.
1#include "Locus.hpp"
2
4
5namespace MayaFlux::Nexus {
6
8 float query_radius,
9 PerceptionFn perception,
10 InfluenceFn influence)
11 : Agent(query_radius, std::move(perception), std::move(influence))
12 , m_nav(Kinesis::make_navigation_state(config))
13{
16}
17
19 float query_radius,
20 std::string perception_fn_name, PerceptionFn perception,
21 std::string influence_fn_name, InfluenceFn influence)
23 std::move(perception_fn_name), std::move(perception),
24 std::move(influence_fn_name), std::move(influence))
25 , m_nav(Kinesis::make_navigation_state(config))
26{
29}
30
31void Locus::add_view_target(std::shared_ptr<Buffers::RenderProcessor> proc)
32{
33 if (!proc) {
34 return;
35 }
36 if (std::ranges::find(m_view_targets, proc) != m_view_targets.end()) {
37 return;
38 }
39 m_view_targets.push_back(std::move(proc));
40}
41
42void Locus::remove_view_target(const std::shared_ptr<Buffers::RenderProcessor>& proc)
43{
44 std::erase(m_view_targets, proc);
45}
46
48{
50
51 if (attached() && position()) {
52 m_nav.eye = *position();
53 }
54
59 glm::angleAxis(m_nav.yaw, glm::vec3(0.0F, 1.0F, 0.0F))
60 * glm::angleAxis(-m_nav.pitch, glm::vec3(1.0F, 0.0F, 0.0F)));
61}
62
64{
65 for (const auto& proc : m_view_targets) {
66 if (proc) {
67 proc->set_view_transform(m_view);
68 }
69 }
70
72}
73
74} // namespace MayaFlux::Nexus
float query_radius
Definition Decoder.cpp:96
const std::optional< glm::vec3 > & position() const
Return the current position, if set.
Definition Agent.hpp:108
void set_orientation(const glm::quat &q)
Set the orientation.
Definition Agent.hpp:122
virtual void invoke_influence(const InfluenceContext &ctx) const
Invoke the influence function with the supplied context.
Definition Agent.hpp:365
virtual void invoke_perception(const PerceptionContext &ctx)
Invoke the perception function with the supplied context.
Definition Agent.hpp:351
std::function< void(const PerceptionContext &)> PerceptionFn
Definition Agent.hpp:39
bool attached() const
True while a buffer is attached.
Definition Agent.hpp:216
void set_position(const glm::vec3 &p)
Set the position, enabling spatial indexing and queries for this object.
Definition Agent.hpp:114
std::function< void(const InfluenceContext &)> InfluenceFn
Definition Agent.hpp:38
Object that both perceives nearby entities and acts on MayaFlux objects.
Definition Agent.hpp:36
void invoke_influence(const InfluenceContext &ctx) const override
Influence: push the current view to every view target, then run the inherited influence path.
Definition Locus.cpp:63
void add_view_target(std::shared_ptr< Buffers::RenderProcessor > proc)
Add a render processor whose view transform this Locus drives.
Definition Locus.cpp:31
Kinesis::NavigationState m_nav
Definition Locus.hpp:173
Locus(const Kinesis::NavigationConfig &config, float query_radius, PerceptionFn perception, InfluenceFn influence)
Construct from a NavigationConfig with perception and influence functions.
Definition Locus.cpp:7
std::vector< std::shared_ptr< Buffers::RenderProcessor > > m_view_targets
Definition Locus.hpp:176
void invoke_perception(const PerceptionContext &ctx) override
Perceive: run the user perception callable, then integrate the view.
Definition Locus.cpp:47
void remove_view_target(const std::shared_ptr< Buffers::RenderProcessor > &proc)
Stop driving a render processor's view transform.
Definition Locus.cpp:42
Kinesis::ViewTransform m_view
Definition Locus.hpp:174
void advance_navigation(NavigationState &st)
Advance eye position by held movement flags against elapsed time.
ViewTransform build_view_transform(const NavigationState &st, float aspect)
Build a ViewTransform from the current NavigationState without mutating it.
ViewTransform compute_view_transform(NavigationState &st, float aspect)
Compute a ViewTransform from the current NavigationState.
Tuning parameters for a first-person fly-navigation controller.
float pitch
Radians, vertical rotation, clamped to [-89, +89] degrees.
float yaw
Radians, horizontal rotation.
Data passed to an Emitter or Agent influence function on each commit.
Definition Influence.hpp:17
Data passed to a Sensor or Agent perception function on each commit.