MayaFlux 0.5.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
 
struct  GroupIndex
 A global particle index resolved to its owning collection. More...
 

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.
 
size_t bond_count () const
 Number of particles currently bonded to a root other than themselves.
 
bool bonds_enabled () const
 
std::vector< uint32_t > build_cluster_ids () const override
 Per-particle collection index, global index order.
 
void clear_attraction_point ()
 
void clear_bonds ()
 Drop every adopted bond.
 
void clear_force_fields ()
 Remove all external force fields.
 
void enable_bonds (bool enable)
 Enable or disable adopting bonds from sync_bonds_from_claims.
 
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.
 
float get_accreted_mass (size_t global_index) const
 This particle's currently accreted mass.
 
std::span< const float > get_accreted_mass_span ()
 Every particle's currently accreted mass, in global index order.
 
glm::vec3 get_attraction_point () const
 
float get_bond_rest_length () const
 
float get_bond_stiffness () 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.
 
float get_interaction_radius () const
 Get the interaction radius for physics calculations.
 
float get_internal_dt () const
 
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.
 
float get_total_mass () const
 Sum of every particle's accreted mass.
 
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 seed_from_upstream (const GraphicsOperator *upstream) override
 Seed physics state from upstream operator's vertex data.
 
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_bond_rest_length (float rest_length)
 Distance a bond settles at.
 
void set_bond_stiffness (float stiffness)
 Spring constant pulling a bonded particle toward its root.
 
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_internal_dt (float dt)
 Fixed dt substituted when set_force_internal_dt(true).
 
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.
 
void sync_bonds_from_claims (std::span< const uint32_t > claimed_by)
 Adopt this cycle's GPU claim/absorption clustering as bonds.
 
 ~PhysicsOperator () override
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::GraphicsOperator
bool consumes_upstream () const
 Whether this operator requests upstream vertex state before process().
 
virtual std::vector< DirtyVertexRangedirty_vertex_ranges () const
 Vertex sub-ranges that changed since the last mark_vertex_data_clean().
 
bool participates_in_rendering () const
 Whether this operator contributes a vertex slice to rendering.
 
void set_consumes_upstream (bool value)
 
void set_force_internal_dt (bool value)
 Override the dt passed by the caller with a fixed internal value.
 
void set_participates_in_rendering (bool value)
 
virtual bool supports_incremental_upload () const
 Whether every vertex mutation on this operator sets a group's dirty flag, so dirty_vertex_ranges() is the complete record of what changed since the last mark_vertex_data_clean().
 
bool uses_force_internal_dt () const
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::NetworkOperator
virtual bool demands_full_vertex_restore () const
 Whether a downstream compute pass writes the network's vertex buffer in place each cycle, so the geometry producer must keep restoring the CPU-authoritative vertex data every frame.
 
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_bond_forces ()
 Pull each bonded particle toward its root with a spring.
 
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)
 
std::optional< GroupIndexresolve_global_index (size_t global_index) const
 Resolve a global index the same way apply_impulse/get_data_at do.
 
void sync_to_point_collection ()
 

Static Private Member Functions

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

Private Attributes

std::atomic< uint32_t > m_access_token { 0 }
 
std::vector< float > m_accreted_mass
 Lazily seeded to 1.0 per particle; see sync_bonds_from_claims.
 
glm::vec3 m_attraction_point { 0.0F }
 
float m_attraction_strength { 1.0F }
 
float m_bond_rest_length { 0.0F }
 
std::vector< uint32_t > m_bond_root
 Empty when no bonds are adopted; see sync_bonds_from_claims.
 
float m_bond_stiffness { 2.0F }
 
bool m_bonds_enabled { true }
 
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_internal_dt { 0.016F }
 
float m_point_size { 5.0F }
 
Kinesis::Stochastic::Stochastic m_random_generator
 
float m_repulsion_strength { 0.5F }
 
std::atomic< bool > m_shutdown { false }
 
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
 

Additional Inherited Members

- Protected Attributes inherited from MayaFlux::Nodes::Network::GraphicsOperator
bool m_consumes_upstream {}
 
bool m_force_internal_dt {}
 
bool m_participates_in_rendering { true }
 

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: