MayaFlux 0.2.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

 PhysicsOperator ()
 
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.
 
void add_collection (const std::vector< PointVertex > &vertices, float mass_multiplier=1.0F)
 Add a single physics collection.
 
void process (float dt) override
 Process for one batch cycle.
 
std::span< const uint8_t > get_vertex_data_for_collection (uint32_t idx) const override
 Get vertex data for specific collection (if multiple)
 
std::span< const uint8_t > get_vertex_data () const override
 Get vertex data for GPU upload.
 
Kakshya::VertexLayout get_vertex_layout () const override
 Get vertex layout describing vertex structure.
 
size_t get_vertex_count () const override
 Get number of vertices (may differ from point count for topology/path)
 
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.
 
std::vector< PointVertexextract_vertices () const
 Extract current vertex data as PointVertex array.
 
void set_parameter (std::string_view param, double value) override
 Set operator parameter.
 
std::optional< double > query_state (std::string_view query) const override
 Query operator internal state.
 
std::string_view get_type_name () const override
 Type name for introspection.
 
size_t get_point_count () const override
 Get source point count (before topology expansion)
 
void set_gravity (const glm::vec3 &gravity)
 Set the gravity vector.
 
void set_drag (float drag)
 Set the drag coefficient.
 
void set_interaction_radius (float radius)
 Set the interaction radius for physics calculations.
 
void set_spring_stiffness (float stiffness)
 Set the spring stiffness for interactions.
 
void set_bounds (const glm::vec3 &min, const glm::vec3 &max)
 Set the simulation bounds.
 
void set_point_size (float size)
 Set the rendered point size.
 
void set_bounds_mode (BoundsMode mode)
 Set the current bounds mode.
 
void enable_spatial_interactions (bool enable)
 Enable or disable spatial interactions between particles.
 
void set_repulsion_strength (float strength)
 Set the strength of repulsion between particles when spatial interactions are enabled.
 
void set_turbulence_strength (float strength)
 Set the strength of attraction towards the attraction point.
 
std::optional< double > get_particle_velocity (size_t global_index) const
 Get velocity magnitude for specific particle.
 
glm::vec3 get_gravity () const
 Get the current gravity vector.
 
float get_drag () const
 Get the current drag coefficient.
 
BoundsMode get_bounds_mode () const
 Get the current bounds mode.
 
bool spatial_interactions_enabled () const
 Check if spatial interactions between particles are enabled.
 
float get_repulsion_strength () const
 Get the current repulsion strength for spatial interactions.
 
void set_attraction_point (const glm::vec3 &point)
 
void clear_attraction_point ()
 
bool has_attraction_point () const
 
glm::vec3 get_attraction_point () const
 
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.
 
std::vector< CollectionGroup > & get_collections ()
 Direct access to collections for advanced per-particle control.
 
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.
 
const char * get_vertex_type_name () const override
 Get human-readable vertex type name (for validation/debugging)
 
- 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_forces ()
 
void apply_spatial_interactions ()
 
void apply_attraction_forces ()
 
void apply_turbulence ()
 
void integrate (float dt)
 
void handle_boundary_conditions ()
 
void sync_to_point_collection ()
 
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)
 

Static Private Member Functions

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

Private Attributes

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

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 52 of file PhysicsOperator.hpp.


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