MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nodes::Network::PhysicsOperator Class Reference

N-body physics simulation with point rendering. More...

#include <PhysicsOperator.hpp>

+ Inheritance diagram for MayaFlux::Nodes::Network::PhysicsOperator:
+ Collaboration diagram for MayaFlux::Nodes::Network::PhysicsOperator:

Classes

struct  CollectionGroup
 

Public Types

enum class  BoundsMode : uint8_t { NONE , BOUNCE , WRAP , CLAMP }
 How particles behave at spatial bounds. More...
 

Public Member Functions

void add_collection (const std::vector< PointVertex > &vertices, float mass_multiplier=1.0F)
 Add a single physics collection.
 
void add_force_field (Kinesis::VectorField field)
 Add an external force field evaluated per-particle per-frame.
 
void apply_global_impulse (const glm::vec3 &impulse)
 Apply impulse to all particles.
 
void apply_impulse (size_t index, const glm::vec3 &impulse)
 Apply impulse to specific particle.
 
void apply_one_to_one (std::string_view param, const std::shared_ptr< NodeNetwork > &source) override
 Apply ONE_TO_ONE parameter for physics-specific properties.
 
void clear_attraction_point ()
 
void clear_force_fields ()
 Remove all external force fields.
 
void enable_spatial_interactions (bool enable)
 Enable or disable spatial interactions between particles.
 
std::vector< PointVertexextract_vertices () const
 Extract current vertex data as PointVertex array.
 
size_t force_field_count () const
 Get number of active external force fields.
 
glm::vec3 get_attraction_point () const
 
BoundsMode get_bounds_mode () const
 Get the current bounds mode.
 
std::vector< CollectionGroup > & get_collections ()
 Direct access to collections for advanced per-particle control.
 
float get_drag () const
 Get the current drag coefficient.
 
glm::vec3 get_gravity () const
 Get the current gravity vector.
 
std::optional< double > get_particle_velocity (size_t global_index) const
 Get velocity magnitude for specific particle.
 
size_t get_point_count () const override
 Get source point count (before topology expansion)
 
float get_repulsion_strength () const
 Get the current repulsion strength for spatial interactions.
 
std::string_view get_type_name () const override
 Type name for introspection.
 
size_t get_vertex_count () const override
 Get number of vertices (may differ from point count for topology/path)
 
std::span< const uint8_t > get_vertex_data () const override
 Get vertex data for GPU upload.
 
std::span< const uint8_t > get_vertex_data_for_collection (uint32_t idx) const override
 Get vertex data for specific collection (if multiple)
 
Kakshya::VertexLayout get_vertex_layout () const override
 Get vertex layout describing vertex structure.
 
const char * get_vertex_type_name () const override
 Get human-readable vertex type name (for validation/debugging)
 
bool has_attraction_point () const
 
void initialize (const std::vector< PointVertex > &vertices)
 Initialize with a single physics collection.
 
void initialize_collections (const std::vector< std::vector< PointVertex > > &collections)
 Initialize multiple physics collections.
 
bool is_vertex_data_dirty () const override
 Check if geometry changed this frame.
 
void mark_vertex_data_clean () override
 Clear dirty flag after GPU upload.
 
 PhysicsOperator ()
 
void process (float dt) override
 Process for one batch cycle.
 
std::optional< double > query_state (std::string_view query) const override
 Query operator internal state.
 
void set_attraction_point (const glm::vec3 &point)
 
void set_attraction_strength (float strength)
 Set the strength of attraction towards the attraction point.
 
void set_bounds (const glm::vec3 &min, const glm::vec3 &max)
 Set the simulation bounds.
 
void set_bounds_mode (BoundsMode mode)
 Set the current bounds mode.
 
void set_drag (float drag)
 Set the drag coefficient.
 
void set_gravity (const glm::vec3 &gravity)
 Set the gravity vector.
 
void set_interaction_radius (float radius)
 Set the interaction radius for physics calculations.
 
void set_parameter (std::string_view param, double value) override
 Set operator parameter.
 
void set_point_size (float size)
 Set the rendered point size.
 
void set_repulsion_strength (float strength)
 Set the strength of repulsion between particles when spatial interactions are enabled.
 
void set_spring_stiffness (float stiffness)
 Set the spring stiffness for interactions.
 
void set_turbulence_strength (float strength)
 Set the strength of attraction towards the attraction point.
 
bool spatial_interactions_enabled () const
 Check if spatial interactions between particles are enabled.
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::NetworkOperator
virtual ~NetworkOperator ()=default
 

Protected Member Functions

void * get_data_at (size_t global_index) override
 Get mutable access to point at global index.
 

Private Member Functions

void apply_attraction_forces ()
 
void apply_forces ()
 
void apply_per_particle_force (std::string_view param, const std::shared_ptr< NodeNetwork > &source)
 
void apply_per_particle_mass (const std::shared_ptr< NodeNetwork > &source)
 
void apply_spatial_interactions ()
 
void apply_turbulence ()
 
void handle_boundary_conditions ()
 
void integrate (float dt)
 
void sync_to_point_collection ()
 

Static Private Member Functions

static std::optional< PhysicsParameterstring_to_parameter (std::string_view param)
 

Private Attributes

glm::vec3 m_attraction_point { 0.0F }
 
float m_attraction_strength { 1.0F }
 
Kinesis::SamplerBounds m_bounds { .min = glm::vec3 { -10.0F }, .max = glm::vec3 { 10.0F } }
 
BoundsMode m_bounds_mode { BoundsMode::BOUNCE }
 
std::vector< CollectionGroupm_collections
 
float m_drag { 0.01F }
 
std::vector< Kinesis::VectorFieldm_force_fields
 
glm::vec3 m_gravity { 0.0F, -9.81F, 0.0F }
 
bool m_has_attraction_point { false }
 
float m_interaction_radius { 1.0F }
 
float m_point_size { 5.0F }
 
Kinesis::Stochastic::Stochastic m_random_generator
 
float m_repulsion_strength { 0.5F }
 
bool m_spatial_interactions_enabled {}
 
float m_spring_stiffness { 0.5F }
 
float m_turbulence_strength { 0.0F }
 
std::vector< uint8_t > m_vertex_data_aggregate
 

Detailed Description

N-body physics simulation with point rendering.

Delegates rendering to PointCollectionNode. Physics state (velocity, force, mass) stored in parallel array. Each frame:

  1. Apply forces
  2. Integrate motion
  3. Update PointCollectionNode vertices
  4. PointCollectionNode handles GPU upload

Definition at line 53 of file PhysicsOperator.hpp.


The documentation for this class was generated from the following files: