12std::shared_ptr<FieldOperator>
19 auto op = std::make_shared<FieldOperator>(FieldMode::ABSOLUTE);
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));
62 op = std::make_shared<FieldOperator>(FieldMode::ABSOLUTE);
63 op->bind(target, std::move(field));
75 op = std::make_shared<FieldOperator>(FieldMode::ABSOLUTE);
76 op->bind(target, std::move(field));
88 op = std::make_shared<FieldOperator>(FieldMode::ABSOLUTE);
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];
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));
188 const auto&
current = slot.
node->get_mesh_vertices();
192 const auto held =
field_op->get_vertex_data();
194 if (held.size() != bytes || std::memcmp(held.data(),
current.data(), bytes) != 0) {
197 "MeshFieldOperator: initialised slot {} from its node ({} vertices)",
205 slot.
node->set_mesh_vertices(
field_op->extract_mesh_vertices());
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::shared_ptr< Nodes::Network::GpuFieldOperator > field_op
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 the given targets 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
FieldTarget
What a Tendency drives when applied to a vertex record.
FieldMode
How a field result combines with the value already present.
Kinesis::FieldTarget FieldTarget
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