From 2c2855b77a8a1a6e21a26fea5c5735dfbbc6066d Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Fri, 22 Nov 2024 15:14:29 +0100 Subject: fixed merge master --- src/crepe/Collider.h | 8 -------- src/crepe/system/CollisionSystem.cpp | 34 +++++++++++++++++----------------- src/crepe/system/CollisionSystem.h | 3 ++- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/crepe/Collider.h b/src/crepe/Collider.h index 78e48cf..0157324 100644 --- a/src/crepe/Collider.h +++ b/src/crepe/Collider.h @@ -10,14 +10,6 @@ class Collider : public Component { public: Collider(game_object_id_t id, Vector2 offset); -protected: - // Friend class allowing access to copy constructor - friend class CollisionSystem; - - // Copy Constructor (Restricted to CollisionSystem) - Collider(const Collider &other) - : Component(other.game_object_id), offset(other.offset) {} - public: //! Offset of the collider relative to rigidbody position Vector2 offset; diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index b23e779..9ca8b3a 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -42,12 +42,12 @@ void CollisionSystem::collision_handler(CollidedInfoStor& data1,CollidedInfoStor Vector2 move_back; // Check collision type and get values for handler - if (std::holds_alternative(data1.collider)) { - if (std::holds_alternative(data2.collider)) { + if (std::holds_alternative>(data1.collider)) { + if (std::holds_alternative>(data2.collider)) { // Get colliders from variant to be used to determine collision handler info - const BoxCollider& box_collider1 = std::get(data1.collider); - const BoxCollider& box_collider2 = std::get(data2.collider); + const BoxCollider& box_collider1 = std::get>(data1.collider).get(); + const BoxCollider& box_collider2 = std::get>(data2.collider).get(); collider1 = &box_collider1; collider2 = &box_collider2; @@ -62,24 +62,24 @@ void CollisionSystem::collision_handler(CollidedInfoStor& data1,CollidedInfoStor } else { // TODO: calcualte Box - Circle collision info - const BoxCollider& box_collider = std::get(data1.collider); - const CircleCollider& circle_collider = std::get(data2.collider); + const BoxCollider& box_collider = std::get>(data1.collider).get(); + const CircleCollider& circle_collider = std::get>(data2.collider).get(); collider1 = &box_collider; collider2 = &circle_collider; } } else { - if (std::holds_alternative(data2.collider)) { + if (std::holds_alternative>(data2.collider)) { // TODO: calcualte Circle - Circle collision info - const CircleCollider& circle_collider1 = std::get(data1.collider); - const CircleCollider& circle_collider2 = std::get(data2.collider); + const CircleCollider& circle_collider1 = std::get>(data1.collider).get(); + const CircleCollider& circle_collider2 = std::get>(data2.collider).get(); collider1 = &circle_collider1; collider2 = &circle_collider2; } else { // TODO: calcualte Circle - Box collision info - const CircleCollider& circle_collider = std::get(data1.collider); - const BoxCollider& box_collider = std::get(data2.collider); + const CircleCollider& circle_collider = std::get>(data1.collider); + const BoxCollider& box_collider = std::get>(data2.collider); collider1 = &circle_collider; collider2 = &box_collider; } @@ -222,8 +222,8 @@ std::vector; + // using collider_stor = std::variant; + using collider_stor = std::variant, std::reference_wrapper>; /** * \brief A structure to store the collision data of a single collider. -- cgit v1.2.3