MayaFlux 1.0.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 199 of file ParticleNetwork.cpp.

200{
201 if (!op) {
203 "Cannot set null operator");
204 return;
205 }
206
207 if (!is_compatible(*op)) {
209 "ParticleNetwork: unsupported operator type '{}' rejected as primary. "
210 "The primary must own PointVertex storage; a chain operator need not.",
211 op->get_type_name());
212 return;
213 }
214
215 const char* old_name = m_operator ? m_operator->get_type_name().data() : "none";
216 const char* new_name = op->get_type_name().data();
217
219 "Switching operator: '{}' → '{}'",
220 old_name, new_name);
221
222 std::vector<PointVertex> vertices;
223
224 if (auto* old_graphics = dynamic_cast<PhysicsOperator*>(m_operator.get())) {
225 vertices = old_graphics->extract_vertices();
226
228 "Extracted {} vertices from old operator",
229 vertices.size());
230 } else if (auto* old_field = dynamic_cast<FieldOperator*>(m_operator.get())) {
231 vertices = old_field->extract_point_vertices();
232
234 "Extracted {} vertices from old FieldOperator",
235 vertices.size());
236 } else if (!m_operator) {
237 vertices = generate_initial_vertices();
238 }
239
240 if (auto* new_graphics = dynamic_cast<PhysicsOperator*>(op.get())) {
241 new_graphics->initialize(vertices);
242
243 if (auto* physics = dynamic_cast<PhysicsOperator*>(op.get())) {
244 physics->set_bounds(m_bounds.min, m_bounds.max);
245 }
246
248 "Initialized new graphics operator with {} points",
249 vertices.size());
250 }
251
252 if (auto* new_field = dynamic_cast<FieldOperator*>(op.get())) {
253 new_field->initialize(vertices);
254
256 "Initialized new FieldOperator with {} points",
257 vertices.size());
258 }
259
260 m_operator = std::move(op);
261
262 if (auto* physics = dynamic_cast<PhysicsOperator*>(m_operator.get())) {
263 bool should_interact = topology_interacts(get_topology());
264 physics->enable_spatial_interactions(should_interact);
265 }
266
268 "Operator switched successfully to '{}'", new_name);
269}
#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()
static bool is_compatible(const NetworkOperator &op) noexcept
Whether an operator can serve as this network's primary.
std::unique_ptr< NetworkOperator > m_operator
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.

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

+ Here is the call graph for this function: