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 175 of file PhysicsOperator.cpp.

176{
177 if (query == "point_count") {
178 return static_cast<double>(get_point_count());
179 }
180 if (query == "collection_count") {
181 return static_cast<double>(m_collections.size());
182 }
183 if (query == "avg_velocity") {
184 glm::vec3 avg(0.0F);
185 size_t total_points = 0;
186
187 for (const auto& group : m_collections) {
188 for (const auto& state : group.physics_state) {
189 avg += state.velocity;
190 ++total_points;
191 }
192 }
193
194 if (total_points > 0) {
195 avg /= static_cast<float>(total_points);
196 }
197 return static_cast<double>(glm::length(avg));
198 }
199
200 return std::nullopt;
201}
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: