MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Emitter.cpp
Go to the documentation of this file.
1#include "Emitter.hpp"
2
4
7
8namespace MayaFlux::Nexus {
9
10void Emitter::set_influence_target(std::shared_ptr<Buffers::RenderProcessor> proc)
11{
12 if (!proc) {
14 "Cannot set null influence target");
15 return;
16 }
17
18 if (m_influence_ubo) {
20 }
21
22 m_influence_ubo = std::make_shared<Buffers::VKBuffer>(
23 sizeof(InfluenceUBO),
26
27 proc->add_binding("u_influence",
28 Buffers::ShaderBinding { 1, 0, vk::DescriptorType::eUniformBuffer });
29
30 proc->bind_buffer("u_influence", m_influence_ubo);
31
32 m_influence_target = std::move(proc);
33}
34
36{
37 m_influence_target->unbind_buffer("u_influence");
38 m_influence_ubo.reset();
39 m_influence_target.reset();
40}
41
43{
44 if (!m_influence_ubo || !m_influence_ubo->get_mapped_ptr()) {
46 "Cannot upload influence UBO: no target or failed to map buffer");
47 return;
48 }
49
50 InfluenceUBO data {
51 .position = ctx.position,
52 .intensity = ctx.intensity,
53 .color = ctx.color.value_or(glm::vec3(1.0F)),
54 .radius = ctx.radius,
55 .size = ctx.size.value_or(1.0F),
56 };
57
58 Buffers::upload_to_gpu(&data, sizeof(InfluenceUBO), m_influence_ubo, nullptr);
59}
60
61} // namespace MayaFlux::Nexus
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
@ UNIFORM
Uniform buffer (host-visible)
std::shared_ptr< Buffers::VKBuffer > m_influence_ubo
Definition Emitter.hpp:249
std::shared_ptr< Buffers::RenderProcessor > m_influence_target
Definition Emitter.hpp:248
void set_influence_target(std::shared_ptr< Buffers::RenderProcessor > proc)
Set the render processor to target for GPU-side influence delivery.
Definition Emitter.cpp:10
void upload_influence_ubo(const InfluenceContext &ctx) const
Definition Emitter.cpp:42
void clear_influence_target()
Disconnect from the current influence target.
Definition Emitter.cpp:35
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging)
Upload raw data to GPU buffer (auto-detects host-visible vs device-local)
@ 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.