From d5ca3c64eea9906be9205b0d650419d3ed18d7aa Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 12 Jan 2026 10:56:57 +0100 Subject: Particle test collision --- lib/core/tests/particles.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/core/tests/particles.cpp b/lib/core/tests/particles.cpp index 0806375..7c0c748 100644 --- a/lib/core/tests/particles.cpp +++ b/lib/core/tests/particles.cpp @@ -96,6 +96,62 @@ SAW_TEST("Collision Spheroid 2D"){ SAW_EXPECT(have_collided, "Particles should collide"); } +SAW_TEST("Moving particles 2D"){ + using namespace kel; + + saw::data> part_a; + { + auto& body = part_a.template get<"rigid_body">(); + auto& pos = body.template get<"position">(); + auto& pos_old = body.template get<"position_old">(); + auto& coll = part_a.template get<"collision">(); + auto& radius = coll.template get<"radius">(); + auto& acc = body.template get<"acceleration">(); + + radius.set(1.0); + + pos.at({{0u}}) = -5.0; + pos.at({{1u}}) = 0.2; + pos_old = pos; + acc.at({{0u}}) = 0.1; + + } + saw::data> part_b; + { + auto& body = part_b.template get<"rigid_body">(); + auto& pos = body.template get<"position">(); + auto& pos_old = body.template get<"position_old">(); + auto& coll = part_b.template get<"collision">(); + auto& radius = coll.template get<"radius">(); + auto& acc = body.template get<"acceleration">(); + + radius.set(1.0); + + pos.at({{0u}}) = 5.0; + pos.at({{1u}}) = 0.0; + pos_old = pos; + acc.at({{0u}}) = -0.1; + } + + bool has_collided = false; + for(uint64_t i = 0u; i < 32u; ++i){ + lbm::verlet_step_lambda(part_a,{0.5}); + lbm::verlet_step_lambda(part_b,{0.5}); + + has_collided = lbm::broadphase_collision_check(part_a,part_b); + if(has_collided){ + std::cout<<"Collided at: "<().template get<"position">().at({{0u}}).get(); + std::cout<<" "; + std::cout<().template get<"position">().at({{0u}}).get(); + std::cout<