483{
486 auto& points1 = group1.collection->get_points();
487
488 for (size_t i = 0; i < points1.size(); ++i) {
489 const auto& pos_i = points1[i].position;
490 auto& state_i = group1.physics_state[i];
491
494 auto& points2 = group2.collection->get_points();
495
496 size_t start_j = (g1 == g2) ? i + 1 : 0;
497
498 for (size_t j = start_j; j < points2.size(); ++j) {
499 const auto& pos_j = points2[j].position;
500 auto& state_j = group2.physics_state[j];
501
502 glm::vec3 delta = pos_j - pos_i;
503 float distance = glm::length(delta);
504
505 if (distance < m_interaction_radius && distance > 0.001F) {
506 glm::vec3 direction = delta /
distance;
507
509
510 float repulsion_force = 0.0F;
513 }
514
515 glm::vec3 force = direction * (spring_force - repulsion_force);
516
517 state_i.force += force;
518 state_j.force -= force;
519 }
520 }
521 }
522 }
523 }
524}
std::vector< CollectionGroup > m_collections
float m_repulsion_strength
float m_interaction_radius
SpatialField distance(const glm::vec3 &anchor, float radius, DistanceMetric metric=DistanceMetric::EUCLIDEAN)
Normalized distance from an anchor point using the specified metric.