421{
424 auto& points1 = group1.collection->get_points();
425
426 for (size_t i = 0; i < points1.size(); ++i) {
427 const auto& pos_i = points1[i].position;
428 auto& state_i = group1.physics_state[i];
429
432 auto& points2 = group2.collection->get_points();
433
434 size_t start_j = (g1 == g2) ? i + 1 : 0;
435
436 for (size_t j = start_j; j < points2.size(); ++j) {
437 const auto& pos_j = points2[j].position;
438 auto& state_j = group2.physics_state[j];
439
440 glm::vec3 delta = pos_j - pos_i;
441 float distance = glm::length(delta);
442
443 if (distance < m_interaction_radius && distance > 0.001F) {
444 glm::vec3 direction = delta / distance;
445
447
448 float repulsion_force = 0.0F;
451 }
452
453 glm::vec3 force = direction * (spring_force - repulsion_force);
454
455 state_i.force += force;
456 state_j.force -= force;
457 }
458 }
459 }
460 }
461 }
462}
std::vector< CollectionGroup > m_collections
float m_repulsion_strength
float m_interaction_radius