MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Agent.cpp
Go to the documentation of this file.
1#include "Agent.hpp"
2
4
6
7namespace MayaFlux::Nexus {
8
9void Agent::set_influence_target(std::shared_ptr<Buffers::RenderProcessor> proc)
10{
11 if (!proc) {
13 "Cannot set null influence target");
14 return;
15 }
16
17 if (m_influence_ubo) {
19 }
20
21 m_influence_ubo = std::make_shared<Buffers::VKBuffer>(
22 sizeof(InfluenceUBO),
25
26 proc->add_binding("u_influence",
27 Buffers::ShaderBinding { 1, 0, vk::DescriptorType::eUniformBuffer });
28
29 proc->bind_buffer("u_influence", m_influence_ubo);
30
31 m_influence_target = std::move(proc);
32}
33
35{
36 m_influence_target->unbind_buffer("u_influence");
37 m_influence_ubo.reset();
38 m_influence_target.reset();
39}
40
42{
43 if (!m_influence_ubo || !m_influence_ubo->get_mapped_ptr()) {
45 "Cannot upload influence UBO: no target or failed to map buffer");
46 return;
47 }
48
49 InfluenceUBO data {
50 .position = ctx.position,
51 .intensity = ctx.intensity,
52 .color = ctx.color.value_or(glm::vec3(1.0F)),
53 .radius = ctx.radius,
54 .size = ctx.size.value_or(1.0F),
55 };
56
57 std::memcpy(m_influence_ubo->get_mapped_ptr(), &data, sizeof(InfluenceUBO));
58}
59
60} // namespace MayaFlux::Nexus
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
@ UNIFORM
Uniform buffer (host-visible)
void upload_influence_ubo(const InfluenceContext &ctx) const
Definition Agent.cpp:41
void clear_influence_target()
Disconnect from the current influence target.
Definition Agent.cpp:34
std::shared_ptr< Buffers::RenderProcessor > m_influence_target
Definition Agent.hpp:297
void set_influence_target(std::shared_ptr< Buffers::RenderProcessor > proc)
Set the render processor to target for GPU-side influence delivery.
Definition Agent.cpp:9
std::shared_ptr< Buffers::VKBuffer > m_influence_ubo
Definition Agent.hpp:298
@ Init
Engine/subsystem initialization.
@ Runtime
General runtime operations (default fallback)
@ Nexus
Spatial indexing and scheduling for user-defined behaviour.
@ UNKNOWN
Unknown or undefined modality.
Describes how a VKBuffer binds to a shader descriptor.
glm::vec3 position
Position of the influence point in world space.
std::optional< glm::vec3 > color
Optional color hint for the influence, may be used for visualisation or shader effects.
std::optional< float > size
Optional size hint for the influence, may be used for visualisation or shader effects.
float intensity
Intensity of the influence, typically in the range [0, 1], but may exceed 1 for strong influences.
float radius
Radius of influence around the position, defining the area of effect for spatially-dependent influenc...
Data passed to an Emitter or Agent influence function on each commit.
GPU-side std140 layout matching InfluenceContext plain data fields.