22 const glm::vec3& bounds_min,
23 const glm::vec3& bounds_max,
25 : m_num_points(num_particles)
26 , m_bounds(bounds_min, bounds_max)
27 , m_init_mode(init_mode)
34 "Created ParticleNetwork with {} points, bounds [{:.2f}, {:.2f}, {:.2f}] to [{:.2f}, {:.2f}, {:.2f}]",
36 bounds_min.x, bounds_min.y, bounds_min.z,
37 bounds_max.x, bounds_max.y, bounds_max.z);
53 auto physics = std::make_unique<PhysicsOperator>();
62 "Initialized ParticleNetwork: {} points, operator={}",
69 const glm::vec3& bounds_min,
70 const glm::vec3& bounds_max,
74 m_bounds = { .
min = bounds_min, .max = bounds_max };
86 physics->initialize(vertices);
89 field->initialize(vertices);
92 auto physics = std::make_unique<PhysicsOperator>();
94 physics->initialize(vertices);
99 "Reset ParticleNetwork: {} points reinitialized",
m_num_points);
113 for (
unsigned int frame = 0; frame < num_samples; ++frame) {
119 for (
unsigned int frame = 0; frame < num_samples; ++frame) {
125 "ParticleNetwork processed {} frames with {} operator",
134 bool should_interact = topology_interacts(
topology);
135 physics->enable_spatial_interactions(should_interact);
146 return graphics_op->get_point_count();
159 return physics->get_particle_velocity(
index);
172 metadata[
"bounds_min"] = std::format(
"({:.2f}, {:.2f}, {:.2f})",
174 metadata[
"bounds_max"] = std::format(
"({:.2f}, {:.2f}, {:.2f})",
179 metadata[
"gravity"] = std::format(
"({:.2f}, {:.2f}, {:.2f})",
180 physics->get_gravity().x,
181 physics->get_gravity().y,
182 physics->get_gravity().z);
183 metadata[
"drag"] = std::to_string(physics->get_drag());
185 auto avg_vel = physics->query_state(
"avg_velocity");
187 metadata[
"avg_velocity"] = std::to_string(*avg_vel);
203 "Cannot set null operator");
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());
216 const char* new_name = op->get_type_name().data();
219 "Switching operator: '{}' → '{}'",
222 std::vector<PointVertex> vertices;
225 vertices = old_graphics->extract_vertices();
228 "Extracted {} vertices from old operator",
231 vertices = old_field->extract_point_vertices();
234 "Extracted {} vertices from old FieldOperator",
241 new_graphics->initialize(vertices);
248 "Initialized new graphics operator with {} points",
252 if (
auto* new_field =
dynamic_cast<FieldOperator*
>(op.get())) {
253 new_field->initialize(vertices);
256 "Initialized new FieldOperator with {} points",
263 bool should_interact = topology_interacts(
get_topology());
264 physics->enable_spatial_interactions(should_interact);
268 "Operator switched successfully to '{}'", new_name);
276 const std::string& param_name,
277 const std::shared_ptr<Node>& source,
296 double value = mapping.broadcast_source->get_last_output();
300 m_operator->apply_one_to_one(mapping.param_name, mapping.network_source);
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::unordered_map< std::string, std::string > metadata
std::vector< glm::vec3 > positions
PrimitiveTopology topology
Pure field-driven vertex manipulation via Tendency evaluation.
Operator that produces GPU-renderable geometry.
Domain-agnostic interpretive lens for network processing.
std::vector< ParameterMapping > m_parameter_mappings
virtual void unmap_parameter(const std::string ¶m_name)
Remove parameter mapping.
Topology get_topology() const
Get the current topology.
virtual void map_parameter(const std::string ¶m_name, const std::shared_ptr< Node > &source, MappingMode mode=MappingMode::BROADCAST)
Map external node output to network parameter.
virtual void set_topology(Topology topology)
Set the network's topology.
bool is_enabled() const
Check if network is enabled.
float get_timestep() const
Seconds one visual frame advances this network.
std::shared_ptr< OperatorChain > m_operator_chain
virtual std::unordered_map< std::string, std::string > get_metadata() const
Get network metadata for debugging/visualization.
void set_output_mode(OutputMode mode)
Set the network's output routing mode.
std::optional< double > get_node_output(size_t index) const override
Get output value for specific particle.
Kinesis::SpatialDistribution m_init_mode
Kinesis::Stochastic::Stochastic m_random_gen
void set_operator(std::unique_ptr< NetworkOperator > op)
Set active operator (runtime switching)
void process_batch(unsigned int num_samples) override
Process the network for the given number of samples.
void ensure_initialized()
void reinitialize(size_t num_particles, const glm::vec3 &bounds_min, const glm::vec3 &bounds_max, Kinesis::SpatialDistribution init_mode)
Reinitialize particle network with new parameters.
void unmap_parameter(const std::string ¶m_name) override
Remove parameter mapping.
Kinesis::SamplerBounds m_bounds
void set_topology(Topology topology) override
Set the network's topology.
std::vector< PointVertex > generate_initial_vertices()
void initialize() override
Called once before first process_batch()
static bool is_compatible(const NetworkOperator &op) noexcept
Whether an operator can serve as this network's primary.
PointVertex generate_single_vertex(Kinesis::SpatialDistribution mode, size_t index, size_t total)
void update_mapped_parameters()
Update mapped parameters before physics step.
void reset() override
Reset network to initial state.
std::unique_ptr< NetworkOperator > m_operator
void map_parameter(const std::string ¶m_name, const std::shared_ptr< Node > &source, MappingMode mode=MappingMode::BROADCAST) override
Map external node output to network parameter.
std::unordered_map< std::string, std::string > get_metadata() const override
Get network metadata for debugging/visualization.
ParticleNetwork(size_t num_particles, const glm::vec3 &bounds_min=glm::vec3(-10.0F), const glm::vec3 &bounds_max=glm::vec3(10.0F), Kinesis::SpatialDistribution init_mode=Kinesis::SpatialDistribution::RANDOM_VOLUME)
Create particle network with spatial bounds.
size_t get_node_count() const override
Get number of particles in network.
N-body physics simulation with point rendering.
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
PointVertex to_point_vertex(const Vertex &s, glm::vec2 size_range={ 8.0F, 12.0F }) noexcept
Project raw Vertex to PointVertex.
std::vector< PointVertex > to_point_vertices(std::span< const Vertex > vertices, glm::vec2 size_range)
Batch-project raw Vertex vector to PointVertex.
Vertex generate_sample_at(SpatialDistribution dist, size_t index, size_t total, const SamplerBounds &bounds, Stochastic::Stochastic &rng)
Generate a single sample at a specific index (for indexed/sequential modes).
std::vector< Vertex > generate_samples(SpatialDistribution dist, size_t count, const SamplerBounds &bounds, Stochastic::Stochastic &rng)
Generate a batch of spatially distributed samples.
SpatialDistribution
Spatial distribution mode for point cloud and particle generation.
Topology
Defines the structural relationships between nodes in the network.
@ GRID_2D
2D lattice with 4-connectivity
@ INDEPENDENT
No connections, nodes process independently.
@ GRID_3D
3D lattice with 6-connectivity
@ SPATIAL
Dynamic proximity-based (nodes within radius interact)
MappingMode
Defines how nodes map to external entities (e.g., audio channels, graphics objects)
@ ONE_TO_ONE
Node array/network → network nodes (must match count)
@ BROADCAST
One node → all network nodes.
@ GRAPHICS_BIND
State available for visualization (read-only)
Vertex type for point primitives (POINT_LIST topology)