MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_collection()

void MayaFlux::Nodes::Network::PhysicsOperator::add_collection ( const std::vector< PointVertex > &  vertices,
float  mass_multiplier = 1.0F 
)

Add a single physics collection.

Parameters
verticesPointVertex array with position, color, size
mass_multiplierMass multiplier for all particles in this collection

Definition at line 55 of file PhysicsOperator.cpp.

58{
59 if (vertices.empty()) {
61 "Cannot add collection with zero vertices");
62 return;
63 }
64
65 CollectionGroup group;
66 group.collection = std::make_shared<GpuSync::PointCollectionNode>();
67
68 group.physics_state.resize(vertices.size());
69
70 for (size_t i = 0; i < vertices.size(); ++i) {
71 group.physics_state[i] = PhysicsState {
72 .velocity = glm::vec3(0.0F),
73 .force = glm::vec3(0.0F),
74 .mass = mass_multiplier
75 };
76 }
77
78 group.collection->set_points(vertices);
79 group.collection->compute_frame();
80
81 uint32_t expected = 0;
82 while (!m_access_token.compare_exchange_weak(expected, 1,
83 std::memory_order_acquire, std::memory_order_relaxed)) {
84 if (m_shutdown.load(std::memory_order_relaxed))
85 return;
86 expected = 0;
87 }
88
89 m_collections.push_back(std::move(group));
90
91 m_access_token.store(0, std::memory_order_release);
92
94 "Added collection #{} with {} points (mass_mult={:.2f})",
95 m_collections.size(), vertices.size(), mass_multiplier);
96}
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::vector< CollectionGroup > m_collections
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.

References MayaFlux::Nodes::Network::PhysicsOperator::CollectionGroup::collection, m_access_token, m_collections, m_shutdown, MF_DEBUG, MF_WARN, MayaFlux::Journal::NodeProcessing, MayaFlux::Journal::Nodes, MayaFlux::Nodes::Network::PhysicsOperator::CollectionGroup::physics_state, and MayaFlux::Nodes::Network::PhysicsState::velocity.

Referenced by initialize(), and initialize_collections().

+ Here is the caller graph for this function: