MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ set_operator()

void MayaFlux::Nodes::Network::ParticleNetwork::set_operator ( std::unique_ptr< NetworkOperator op)

Set active operator (runtime switching)

Definition at line 182 of file ParticleNetwork.cpp.

183{
184 if (!op) {
186 "Cannot set null operator");
187 return;
188 }
189
190 const char* old_name = m_operator ? m_operator->get_type_name().data() : "none";
191 const char* new_name = op->get_type_name().data();
192
194 "Switching operator: '{}' → '{}'",
195 old_name, new_name);
196
197 std::vector<PointVertex> vertices;
198
199 if (auto* old_graphics = dynamic_cast<PhysicsOperator*>(m_operator.get())) {
200 vertices = old_graphics->extract_vertices();
201
203 "Extracted {} vertices from old operator",
204 vertices.size());
205 } else if (auto* old_field = dynamic_cast<FieldOperator*>(m_operator.get())) {
206 vertices = old_field->extract_point_vertices();
207
209 "Extracted {} vertices from old FieldOperator",
210 vertices.size());
211 } else if (!m_operator) {
212 vertices = generate_initial_vertices();
213 }
214
215 if (auto* new_graphics = dynamic_cast<PhysicsOperator*>(op.get())) {
216 new_graphics->initialize(vertices);
217
218 if (auto* physics = dynamic_cast<PhysicsOperator*>(op.get())) {
219 physics->set_bounds(m_bounds.min, m_bounds.max);
220 }
221
223 "Initialized new graphics operator with {} points",
224 vertices.size());
225 }
226
227 if (auto* new_field = dynamic_cast<FieldOperator*>(op.get())) {
228 new_field->initialize(vertices);
229
231 "Initialized new FieldOperator with {} points",
232 vertices.size());
233 }
234
235 m_operator = std::move(op);
236
237 if (auto* physics = dynamic_cast<PhysicsOperator*>(m_operator.get())) {
238 bool should_interact = (get_topology() == Topology::SPATIAL);
239 physics->enable_spatial_interactions(should_interact);
240 }
241
243 "Operator switched successfully to '{}'", new_name);
244}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
Topology get_topology() const
Get the current topology.
std::vector< PointVertex > generate_initial_vertices()
std::unique_ptr< NetworkOperator > m_operator
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
@ SPATIAL
Dynamic proximity-based (nodes within radius interact)

References generate_initial_vertices(), MayaFlux::Nodes::Network::NodeNetwork::get_topology(), m_bounds, m_operator, MayaFlux::Kinesis::SamplerBounds::max, MF_DEBUG, MF_ERROR, MF_INFO, MayaFlux::Kinesis::SamplerBounds::min, MayaFlux::Journal::NodeProcessing, MayaFlux::Journal::Nodes, and MayaFlux::Nodes::Network::SPATIAL.

+ Here is the call graph for this function: