MayaFlux 0.4.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)
22 : Agent(query_radius,
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
55
57{
59
60 for (const auto& proc : m_view_targets) {
61 if (proc) {
62 proc->set_view_transform(m_view);
63 }
64 }
65}
66
67} // namespace MayaFlux::Nexus
virtual void invoke_influence(const InfluenceContext &ctx) const
Invoke the influence function with the supplied context.
Definition Agent.hpp:277
virtual void invoke_perception(const PerceptionContext &ctx)
Invoke the perception function with the supplied context.
Definition Agent.hpp:266
std::function< void(const PerceptionContext &)> PerceptionFn
Definition Agent.hpp:31
void set_position(const glm::vec3 &p)
Set the position, enabling spatial indexing and queries for this object.
Definition Agent.hpp:95
std::function< void(const InfluenceContext &)> InfluenceFn
Definition Agent.hpp:30
Object that both perceives nearby entities and acts on MayaFlux objects.
Definition Agent.hpp:28
void invoke_influence(const InfluenceContext &ctx) const override
Influence: run the user influence callable, then push the current view to every view target.
Definition Locus.cpp:56
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:172
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:175
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:173
void advance_navigation(NavigationState &st)
Advance eye position by held movement flags against elapsed time.
ViewTransform compute_view_transform(NavigationState &st, float aspect)
Compute a ViewTransform from the current NavigationState.
ViewTransform build_view_transform(const NavigationState &st, float aspect)
Build a ViewTransform from the current NavigationState without mutating it.
Tuning parameters for a first-person fly-navigation controller.
Data passed to an Emitter or Agent influence function on each commit.
Data passed to a Sensor or Agent perception function on each commit.