12std::shared_ptr<FieldOperator>
22 op->initialize(slot.
node->get_mesh_vertices());
24 "MeshFieldOperator: initialised FieldOperator for slot {} ({} vertices)",
25 slot_index, slot.
node->get_mesh_vertex_count());
28 "MeshFieldOperator: slot {} has no node at bind time -- "
29 "FieldOperator initialised with empty vertex data",
46 "MeshFieldOperator::bind called before set_slots() -- "
47 "FieldOperator will be initialised lazily on first process()");
51 if (slot_index >=
m_slots->size()) {
53 "MeshFieldOperator::bind: slot_index {} out of range ({})",
58 op->bind(target, std::move(field));
63 op->bind(target, std::move(field));
70 if (
m_slots && slot_index < m_slots->size()) {
76 op->bind(target, std::move(field));
83 if (
m_slots && slot_index < m_slots->size()) {
89 op->bind(target, std::move(field));
97 it->second->unbind(target);
114 it->second->set_mode(mode);
130 for (
const auto& slot : *
m_slots) {
132 slot.node ? slot.node->get_mesh_vertex_count() : 0);
144 constexpr size_t floats_per_vertex =
sizeof(
MeshVertex) /
sizeof(
float);
147 for (
size_t i = 0; i <
m_slots->size(); ++i) {
152 const size_t float_count = vc * floats_per_vertex;
154 if (offset + float_count > primary.size())
157 auto& slot = (*m_slots)[i];
159 offset += float_count;
163 std::vector<MeshVertex> verts(vc);
164 std::memcpy(verts.data(), primary.data() + offset,
165 float_count *
sizeof(
float));
166 slot.node->set_mesh_vertices(std::move(verts));
168 offset += float_count;
185 auto& field_op = it->second;
187 if (field_op->get_vertex_count() == 0 && slot.
node
188 && slot.
node->get_mesh_vertex_count() > 0) {
189 field_op->initialize(slot.
node->get_mesh_vertices());
191 "MeshFieldOperator: lazy-initialised slot {} ({} vertices)",
192 slot.
index, slot.
node->get_mesh_vertex_count());
195 field_op->process(dt);
197 if (field_op->is_vertex_data_dirty() && slot.
node) {
198 slot.
node->set_mesh_vertices(field_op->extract_mesh_vertices());
199 field_op->mark_vertex_data_clean();
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
const Yantra::GpuChannelResult & gpu_result
Reference to the full dispatch result. Valid during callback only.
Context delivered to on_complete callbacks when a dispatch completes.
std::unordered_map< uint32_t, std::shared_ptr< FieldOperator > > m_field_ops
std::shared_ptr< Yantra::ShaderExecutionContext<> > m_executor
void bind(uint32_t slot_index, FieldTarget target, Kinesis::VectorField field)
Bind a VectorField to a slot.
void set_mode(uint32_t slot_index, FieldMode mode)
Set the field application mode for a slot's FieldOperator.
std::shared_ptr< FieldOperator > get_or_create(MeshSlot &slot, uint32_t slot_index)
Return an existing FieldOperator for the slot, or create and initialise one from the slot's current v...
void unbind_slot(uint32_t slot_index)
Remove the entire FieldOperator for a slot.
std::vector< size_t > m_gpu_slot_vertex_counts
Vertex count per slot index, snapshotted at set_gpu_executor() time.
void unbind(uint32_t slot_index, FieldTarget target)
Remove all fields bound to a target on a specific slot.
std::shared_ptr< Nodes::GpuSync::GpuComputeNode > m_compute_node
void process(float dt) override
Process for one batch cycle.
void process_slot(MeshSlot &slot, float dt) override
Run the slot's FieldOperator (if bound) and write results back to slot.node via set_mesh_vertices().
void unbind_all()
Remove all per-slot FieldOperators.
void set_gpu_executor(std::shared_ptr< Yantra::ShaderExecutionContext<> > executor, bool continuous=true)
Attach a GPU executor and switch to async dispatch mode.
void process(float dt) override
Iterate slots in topological order and call process_slot() on each.
std::vector< MeshSlot > * m_slots
Concrete GpuExecutionContext for a single fixed shader with fixed bindings.
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
Tendency< glm::vec3, glm::vec2 > UVField
FieldMode
How fields are applied each frame.
FieldTarget
Vertex attribute targets for Tendency field evaluation.
Kakshya::MeshVertex MeshVertex
Typed, composable, stateless callable from domain D to range R.
std::shared_ptr< GpuSync::MeshWriterNode > node
Geometry node for this slot.
uint32_t index
Position of this slot in MeshNetwork::m_slots. Stable after insertion.
Named, independently transformable mesh unit within a MeshNetwork.
std::vector< float > primary