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

◆ query_state()

std::optional< double > MayaFlux::Nodes::Network::PhysicsOperator::query_state ( std::string_view  query) const
overridevirtual

Query operator internal state.

Implements MayaFlux::Nodes::Network::NetworkOperator.

Definition at line 219 of file PhysicsOperator.cpp.

220{
221 if (query == "point_count") {
222 return static_cast<double>(get_point_count());
223 }
224 if (query == "collection_count") {
225 return static_cast<double>(m_collections.size());
226 }
227 if (query == "avg_velocity") {
228 glm::vec3 avg(0.0F);
229 size_t total_points = 0;
230
231 for (const auto& group : m_collections) {
232 for (const auto& state : group.physics_state) {
233 avg += state.velocity;
234 ++total_points;
235 }
236 }
237
238 if (total_points > 0) {
239 avg /= static_cast<float>(total_points);
240 }
241 return static_cast<double>(glm::length(avg));
242 }
243
244 return std::nullopt;
245}
size_t get_point_count() const override
Get source point count (before topology expansion)
std::vector< CollectionGroup > m_collections

References get_point_count(), and m_collections.

+ Here is the call graph for this function: