MayaFlux 0.5.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 191 of file ParticleNetwork.cpp.

192{
193 if (!op) {
195 "Cannot set null operator");
196 return;
197 }
198
199 if (!is_compatible(*op)) {
201 "ParticleNetwork: unsupported operator type '{}' rejected as primary. "
202 "The primary must own PointVertex storage; a chain operator need not.",
203 op->get_type_name());
204 return;
205 }
206
207 const char* old_name = m_operator ? m_operator->get_type_name().data() : "none";
208 const char* new_name = op->get_type_name().data();
209
211 "Switching operator: '{}' → '{}'",
212 old_name, new_name);
213
214 std::vector<PointVertex> vertices;
215
216 if (auto* old_graphics = dynamic_cast<PhysicsOperator*>(m_operator.get())) {
217 vertices = old_graphics->extract_vertices();
218
220 "Extracted {} vertices from old operator",
221 vertices.size());
222 } else if (auto* old_field = dynamic_cast<FieldOperator*>(m_operator.get())) {
223 vertices = old_field->extract_point_vertices();
224
226 "Extracted {} vertices from old FieldOperator",
227 vertices.size());
228 } else if (!m_operator) {
229 vertices = generate_initial_vertices();
230 }
231
232 if (auto* new_graphics = dynamic_cast<PhysicsOperator*>(op.get())) {
233 new_graphics->initialize(vertices);
234
235 if (auto* physics = dynamic_cast<PhysicsOperator*>(op.get())) {
236 physics->set_bounds(m_bounds.min, m_bounds.max);
237 }
238
240 "Initialized new graphics operator with {} points",
241 vertices.size());
242 }
243
244 if (auto* new_field = dynamic_cast<FieldOperator*>(op.get())) {
245 new_field->initialize(vertices);
246
248 "Initialized new FieldOperator with {} points",
249 vertices.size());
250 }
251
252 m_operator = std::move(op);
253
254 if (auto* physics = dynamic_cast<PhysicsOperator*>(m_operator.get())) {
255 bool should_interact = (get_topology() == Topology::SPATIAL);
256 physics->enable_spatial_interactions(should_interact);
257 }
258
260 "Operator switched successfully to '{}'", new_name);
261}
#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.
@ SPATIAL
Dynamic proximity-based (nodes within radius interact)

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, MayaFlux::Journal::Nodes, and MayaFlux::Nodes::Network::SPATIAL.

+ Here is the call graph for this function: