diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-11-14 22:22:49 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-11-14 22:22:49 +0100 |
commit | b58765b671969aa810b9a345be55423523e893fb (patch) | |
tree | 9ed8d3be973a9530bd2c7a8d877a430c586a813c /src/crepe/system/CollisionSystem.h | |
parent | c9c132989053c5fcfb2b7e8d9f2c48a1896764f3 (diff) |
saved reference in storage struct to send to handeler
Diffstat (limited to 'src/crepe/system/CollisionSystem.h')
-rw-r--r-- | src/crepe/system/CollisionSystem.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/crepe/system/CollisionSystem.h b/src/crepe/system/CollisionSystem.h index a4c6ecb..4970579 100644 --- a/src/crepe/system/CollisionSystem.h +++ b/src/crepe/system/CollisionSystem.h @@ -1,26 +1,30 @@ #pragma once #include "Collider.h" +#include "api/Rigidbody.h" +#include "api/Transform.h" +#include "api/BoxCollider.h" +#include "api/CircleCollider.h" +#include <tuple> #include <vector> #include <variant> namespace crepe { -class Collider; -class BoxCollider; -class CircleCollider; -class Transform; -class Rigidbody; class CollisionSystem { +private: + using collider_stor = std::variant<BoxCollider, CircleCollider>; +private: + struct CollidedInfoStor { + std::tuple<collider_stor,Transform,Rigidbody> collider_info; +}; public: CollisionSystem(); void update(); private: - using collider_stor = std::variant<BoxCollider, CircleCollider>; -private: - void call_collision_handler(const Rigidbody& rigidbody1,const Rigidbody& rigidbody2); - std::vector<std::pair<collider_stor, collider_stor>> check_collisions(const std::vector<std::reference_wrapper<BoxCollider>>& boxcolliders, const std::vector<std::reference_wrapper<CircleCollider>>& circlecolliders); + void call_collision_handler(const CollidedInfoStor& data1,const CollidedInfoStor& data2); + std::vector<std::pair<CollidedInfoStor,CollidedInfoStor>> check_collisions(const std::vector<std::reference_wrapper<BoxCollider>>& boxcolliders, const std::vector<std::reference_wrapper<CircleCollider>>& circlecolliders); bool check_box_box_collision(const BoxCollider& box1, const BoxCollider& box2, const Transform& transform1, const Transform& transform2, const Rigidbody& rigidbody1, const Rigidbody& rigidbody2); bool check_box_circle_collision(const BoxCollider& box1, const CircleCollider& circle2, const Transform& transform1, const Transform& transform2, const Rigidbody& rigidbody1, const Rigidbody& rigidbody2); bool check_circle_circle_collision(const CircleCollider& circle1, const CircleCollider& circle2, const Transform& transform1, const Transform& transform2, const Rigidbody& rigidbody1, const Rigidbody& rigidbody2); |