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
5
8
9namespace MayaFlux::Nexus {
10
11void Emitter::set_vertices(const void* data, size_t byte_count)
12{
13 for (auto& s : m_render_sinks)
14 s.writer->set_vertices(data, byte_count);
15}
16
17void Emitter::set_influence_target(std::shared_ptr<Buffers::RenderProcessor> proc)
18{
19 if (!proc) {
21 "Cannot set null influence target");
22 return;
23 }
24
25 if (m_influence_ubo) {
27 }
28
29 m_influence_ubo = std::make_shared<Buffers::VKBuffer>(
30 sizeof(InfluenceUBO),
33
34 proc->add_binding("u_influence",
35 Buffers::ShaderBinding { 1, 0, vk::DescriptorType::eUniformBuffer });
36
37 proc->bind_buffer("u_influence", m_influence_ubo);
38
39 m_influence_target = std::move(proc);
40}
41
43{
44 m_influence_target->unbind_buffer("u_influence");
45 m_influence_ubo.reset();
46 m_influence_target.reset();
47}
48
50{
51 if (!m_influence_ubo || !m_influence_ubo->get_mapped_ptr()) {
53 "Cannot upload influence UBO: no target or failed to map buffer");
54 return;
55 }
56
57 InfluenceUBO data {
58 .position = ctx.position,
59 .intensity = ctx.intensity,
60 .color = ctx.color.value_or(glm::vec3(1.0F)),
61 .radius = ctx.radius,
62 .size = ctx.size.value_or(1.0F),
63 };
64
65 Buffers::upload_to_gpu(&data, sizeof(InfluenceUBO), m_influence_ubo, nullptr);
66}
67
68} // namespace MayaFlux::Nexus
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
@ UNIFORM
Uniform buffer (host-visible)
void set_vertices(const void *data, size_t byte_count)
Set pre-packed interleaved vertex bytes to all registered render sinks.
Definition Emitter.cpp:11
std::shared_ptr< Buffers::VKBuffer > m_influence_ubo
Definition Emitter.hpp:240
std::shared_ptr< Buffers::RenderProcessor > m_influence_target
Definition Emitter.hpp:239
void set_influence_target(std::shared_ptr< Buffers::RenderProcessor > proc)
Set the render processor to target for GPU-side influence delivery.
Definition Emitter.cpp:17
void upload_influence_ubo(const InfluenceContext &ctx) const
Definition Emitter.cpp:49
std::vector< RenderSink > m_render_sinks
Definition Emitter.hpp:247
void clear_influence_target()
Disconnect from the current influence target.
Definition Emitter.cpp:42
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.