MayaFlux 0.2.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 173 of file PhysicsOperator.cpp.

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