MayaFlux 1.0.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 221 of file PhysicsOperator.cpp.

222{
223 if (query == "point_count") {
224 return static_cast<double>(get_point_count());
225 }
226 if (query == "collection_count") {
227 return static_cast<double>(m_collections.size());
228 }
229 if (query == "avg_velocity") {
230 glm::vec3 avg(0.0F);
231 size_t total_points = 0;
232
233 for (const auto& group : m_collections) {
234 for (const auto& state : group.physics_state) {
235 avg += state.velocity;
236 ++total_points;
237 }
238 }
239
240 if (total_points > 0) {
241 avg /= static_cast<float>(total_points);
242 }
243 return static_cast<double>(glm::length(avg));
244 }
245
246 return std::nullopt;
247}
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: