MayaFlux 0.4.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 218 of file PhysicsOperator.cpp.

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