From 1b8ff0752a7622534199e0d8e8c2801967eed4ba Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 13 Jan 2026 16:31:02 +0100 Subject: Reworking the packages sets --- lib/core/c++/particle/particle.hpp | 19 ++++++++++++++++ lib/core/tests/particles.cpp | 44 ++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/core/c++/particle/particle.hpp b/lib/core/c++/particle/particle.hpp index cea80f0..557707d 100644 --- a/lib/core/c++/particle/particle.hpp +++ b/lib/core/c++/particle/particle.hpp @@ -91,6 +91,25 @@ constexpr auto verlet_step_lambda = [](saw::data>& particle, pos = pos_new; }; +template +constexpr auto handle_collision = [](saw::data>& left, saw::data>& right){ + auto& rb_l = left.template get<"rigid_body">(); + auto& rb_r = right.template get<"rigid_body">(); + + auto& pos_l = rb_l.template get<"position">(); + auto& pos_old_l = rb_l.template get<"position_old">(); + auto vel_l = pos_l - pos_old_l; + auto& mass_l = left.template get<"mass">(); + + + /** + * E to 0 + */ + + + +}; + template constexpr auto broadphase_collision_distance = [](saw::data>& left, saw::data>& right) -> std::pair>>{ diff --git a/lib/core/tests/particles.cpp b/lib/core/tests/particles.cpp index 7c0c748..366c2a2 100644 --- a/lib/core/tests/particles.cpp +++ b/lib/core/tests/particles.cpp @@ -1,9 +1,7 @@ #include #include -//#include "../c++/particle/geometry/circle.hpp" #include "../c++/particle/particle.hpp" -#include namespace { namespace sch { @@ -143,15 +141,49 @@ SAW_TEST("Moving particles 2D"){ std::cout<<"Collided at: "<().template get<"position">().at({{0u}}).get(); - std::cout<<" "; - std::cout<().template get<"position">().at({{0u}}).get(); - std::cout<> 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.5); + + pos.at({{0u}}) = 5.0; + pos.at({{1u}}) = 0.0; + pos_old = pos; + acc.at({{0u}}) = -0.1; + } +} + /* SAW_TEST("Minor Test for mask"){ using namespace kel; -- cgit v1.2.3