41 : m_query_radius(query_radius)
42 , m_perception_fn(
std::move(perception))
43 , m_influence_fn(
std::move(influence))
57 std::string influence_fn_name,
InfluenceFn influence)
58 : m_query_radius(query_radius)
59 , m_perception_fn_name(
std::move(perception_fn_name))
60 , m_perception_fn(
std::move(perception))
61 , m_influence_fn_name(
std::move(influence_fn_name))
62 , m_influence_fn(
std::move(influence))
89 [[nodiscard]]
const std::optional<glm::vec3>&
position()
const {
return m_position; }
116 [[nodiscard]] uint32_t
id()
const {
return m_id; }
131 std::string fn_name =
"")
133 add_audio_sink(m_audio_sinks, mgr, channel, std::move(fn), std::move(fn_name));
139 Nexus::remove_audio_sink(m_audio_sinks, mgr, channel);
152 add_render_sink(m_render_sinks, mgr, config, std::move(fn), std::move(fn_name), m_position);
155 [[nodiscard]]
const std::vector<AudioSink>&
audio_sinks()
const {
return m_audio_sinks; }
156 [[nodiscard]]
const std::vector<RenderSink>&
render_sinks()
const {
return m_render_sinks; }
160 const std::shared_ptr<Core::Window>& window)
const
162 auto it = std::ranges::find_if(m_render_sinks,
164 return it != m_render_sinks.end() ? it->renderer :
nullptr;
185 void set_vertices(
const void* data,
size_t byte_count);
191 template <
typename T>
194 static_assert(
sizeof(T) == 60,
"set_vertices: T must be a 60-byte vertex type");
195 set_vertices(vertices.data(), vertices.size_bytes());
202 [[nodiscard]]
float intensity()
const {
return m_intensity; }
208 [[nodiscard]]
float radius()
const {
return m_radius; }
217 [[nodiscard]]
const std::optional<glm::vec3>&
color()
const {
return m_color; }
226 [[nodiscard]]
const std::optional<float>&
size()
const {
return m_size; }
237 void add_influence_target(std::shared_ptr<Buffers::RenderProcessor> proc);
246 void remove_influence_target(
const std::shared_ptr<Buffers::RenderProcessor>& proc);
251 void clear_influence_targets();
256 [[nodiscard]]
const std::vector<std::shared_ptr<Buffers::RenderProcessor>>&
259 return m_influence_targets;
268 if (m_perception_fn) {
269 m_perception_fn(ctx);
279 if (m_influence_fn) {
285 upload_influence_ubo(ctx);
292 float m_intensity { 1.0F };
293 float m_radius { 1.0F };
Token-based multimodal buffer management system for unified data stream processing.
void set_color(const glm::vec3 &c)
Set the color, a general-purpose parameter for influence functions.
float radius() const
Get the current radius.
void set_influence_fn_name(std::string name)
Set or replace the influence function's identifier.
const std::optional< glm::vec3 > & position() const
Return the current position, if set.
Agent(float query_radius, PerceptionFn perception, InfluenceFn influence)
Construct with query radius, perception function, and influence function.
void set_intensity(float i)
Set the intensity, a general-purpose parameter for influence functions.
const std::optional< glm::vec3 > & color() const
Get the current color, if set.
InfluenceFn m_influence_fn
virtual void invoke_influence(const InfluenceContext &ctx) const
Invoke the influence function with the supplied context.
PerceptionFn m_perception_fn
void remove_audio_sink(Buffers::BufferManager &mgr, uint32_t channel)
Unregister the audio sink on channel.
void set_size(float s)
Set the size, a general-purpose parameter for influence functions.
std::vector< std::shared_ptr< Buffers::RenderProcessor > > m_influence_targets
virtual void invoke_perception(const PerceptionContext &ctx)
Invoke the perception function with the supplied context.
uint32_t id() const
Return the stable object id assigned by Fabric.
const std::vector< AudioSink > & audio_sinks() const
std::vector< AudioSink > m_audio_sinks
void clear_position()
Clear the position, removing this object from spatial operations.
void render(Buffers::BufferManager &mgr, const Portal::Graphics::RenderConfig &config)
Register a render output targeting window.
std::optional< float > m_size
std::optional< glm::vec3 > m_position
const std::vector< std::shared_ptr< Buffers::RenderProcessor > > & influence_targets() const
All render processors currently receiving influence data.
const InfluenceFn & influence_fn() const
The influence function itself.
std::function< void(const PerceptionContext &)> PerceptionFn
float intensity() const
Get the current intensity.
void sink_audio(Buffers::BufferManager &mgr, uint32_t channel)
Register an audio output on channel.
const std::string & influence_fn_name() const
Identifier assigned to the influence function, empty if anonymous.
const std::optional< float > & size() const
Get the current size, if set.
void clear_size()
Clear the size, resetting it to an unset state.
void set_audio_data(std::span< const double > samples)
Push samples to all registered audio sinks.
std::optional< glm::vec3 > m_color
void render(Buffers::BufferManager &mgr, const Portal::Graphics::RenderConfig &config, std::string fn_name, RenderFn fn)
Register a render output targeting window with a producer function.
void clear_color()
Clear the color, resetting it to an unset state.
std::shared_ptr< Buffers::RenderProcessor > get_render_processor(const std::shared_ptr< Core::Window > &window) const
void set_query_radius(float r)
Set the query radius.
std::string m_perception_fn_name
void set_radius(float r)
Set the radius, a general-purpose parameter for influence functions.
void set_perception_fn_name(std::string name)
Set or replace the perception function's identifier.
void remove_render(Buffers::BufferManager &mgr, const std::shared_ptr< Core::Window > &window)
Unregister the render sink targeting window.
const std::string & perception_fn_name() const
Identifier assigned to the perception function, empty if anonymous.
Agent(float query_radius, std::string perception_fn_name, PerceptionFn perception, std::string influence_fn_name, InfluenceFn influence)
Construct with named perception and influence functions.
std::string m_influence_fn_name
const PerceptionFn & perception_fn() const
The perception function itself.
std::vector< RenderSink > m_render_sinks
float query_radius() const
Return the query radius.
void set_vertices(std::span< const T > vertices)
Set typed vertex data to all registered render sinks.
void set_position(const glm::vec3 &p)
Set the position, enabling spatial indexing and queries for this object.
std::function< void(const InfluenceContext &)> InfluenceFn
void sink_audio(Buffers::BufferManager &mgr, uint32_t channel, std::function< Kakshya::DataVariant(const InfluenceContext &)> fn, std::string fn_name="")
Register an audio output on channel with a producer function.
std::shared_ptr< Buffers::VKBuffer > m_influence_ubo
const std::vector< RenderSink > & render_sinks() const
Object that both perceives nearby entities and acts on MayaFlux objects.
Orchestrates spatial indexing and scheduling for Nexus objects.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
std::function< void(const InfluenceContext &)> RenderFn
void remove_render_sink(std::vector< RenderSink > &sinks, Buffers::BufferManager &mgr, const std::shared_ptr< Core::Window > &window)
Unregister and destroy the render sink targeting window.
void dispatch_render_sinks(std::vector< RenderSink > &sinks, const InfluenceContext &ctx)
For each sink that has a producer fn, call it and push the result.
void push_audio_data(std::vector< AudioSink > &sinks, std::span< const double > samples)
Push samples to every audio sink in sinks.
void dispatch_audio_sinks(std::vector< AudioSink > &sinks, const InfluenceContext &ctx)
For each sink that has a producer fn, call it and push the result.
void add_audio_sink(std::vector< AudioSink > &sinks, Buffers::BufferManager &mgr, uint32_t channel, std::function< Kakshya::DataVariant(const InfluenceContext &)> fn, std::string fn_name)
Create and register an audio sink on channel.
void add_render_sink(std::vector< RenderSink > &sinks, Buffers::BufferManager &mgr, const Portal::Graphics::RenderConfig &config, RenderFn fn, std::string fn_name, const std::optional< glm::vec3 > &initial_position)
Create and register a render sink targeting window.
Data passed to an Emitter or Agent influence function on each commit.
Data passed to a Sensor or Agent perception function on each commit.
std::shared_ptr< Core::Window > window
Holds the plumbing for one graphics output registered from a Nexus object.
Unified rendering configuration for graphics buffers.