aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/CollisionSystem.h
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-19 20:17:28 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-19 20:17:28 +0100
commit3e7a0a5a2c5ad14ee388f3ac460bf63bdb6ccfd5 (patch)
tree8bb56303e780e1992768a1433cf99ae4fd884907 /src/crepe/system/CollisionSystem.h
parentd2c8a2bf07275f5458c576990b8742a710b15013 (diff)
parent8cd4b07e866d33589a7218367a5639b602c40c67 (diff)
updated nan
Diffstat (limited to 'src/crepe/system/CollisionSystem.h')
-rw-r--r--src/crepe/system/CollisionSystem.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/crepe/system/CollisionSystem.h b/src/crepe/system/CollisionSystem.h
index b7808f1..7be280a 100644
--- a/src/crepe/system/CollisionSystem.h
+++ b/src/crepe/system/CollisionSystem.h
@@ -21,6 +21,7 @@ namespace crepe {
class CollisionSystem : public System {
public:
using System::System;
+
private:
//! Enum representing movement directions during collision resolution.
enum class Direction {
@@ -33,13 +34,13 @@ private:
//! Movement in both X and Y directions.
BOTH,
};
+
public:
-
//! Structure representing components of the collider
struct ColliderInfo {
- Transform & transform;
- Rigidbody & rigidbody;
- Metadata & metadata;
+ Transform & transform;
+ Rigidbody & rigidbody;
+ Metadata & metadata;
};
/**
@@ -54,7 +55,7 @@ public:
vec2 resolution;
//! The direction of movement for resolving the collision.
Direction resolution_direction = Direction::NONE;
- CollisionInfo operator - () const;
+ CollisionInfo operator-() const;
};
private:
@@ -90,9 +91,9 @@ private:
//! Structure of a collider with additional components
template <typename ColliderType>
struct ColliderInternal {
- ColliderType& collider;
- Transform& transform;
- Rigidbody& rigidbody;
+ ColliderType & collider;
+ Transform & transform;
+ Rigidbody & rigidbody;
};
//! Predefined BoxColliderInternal. (System is only made for this type)
using BoxColliderInternal = ColliderInternal<BoxCollider>;
@@ -113,7 +114,8 @@ private:
* \param collider2 Second collider variant (BoxCollider or CircleCollider).
* \return The combined type of the two colliders.
*/
- CollisionInternalType get_collider_type(const collider_variant & collider1, const collider_variant & collider2) const;
+ CollisionInternalType get_collider_type(const collider_variant & collider1,
+ const collider_variant & collider2) const;
private:
/**
@@ -126,8 +128,8 @@ private:
* \param data1 Collision data for the first collider.
* \param data2 Collision data for the second collider.
*/
- CollisionInfo get_collision_info(const CollisionInternal & data1, const CollisionInternal & data2) const;
-
+ CollisionInfo get_collision_info(const CollisionInternal & data1,
+ const CollisionInternal & data2) const;
/**
* \brief Corrects the collision resolution vector and determines its direction.
@@ -142,8 +144,7 @@ private:
* \param rigidbody rigidbody data used to correct resolution
* \return A Direction indicating the resolution direction
*/
- Direction resolution_correction(vec2 & resolution,const Rigidbody::Data & rigidbody);
-
+ Direction resolution_correction(vec2 & resolution, const Rigidbody::Data & rigidbody);
/**
* \brief Determines the appropriate collision handler for a given collision event.
@@ -220,7 +221,8 @@ private:
* \param other_metadata Rigidbody of second object
* \return Returns true if there is at least one comparison found.
*/
- bool should_collide(const CollisionInternal & self, const CollisionInternal & other) const; //done
+ bool should_collide(const CollisionInternal & self,
+ const CollisionInternal & other) const; //done
/**
* \brief Checks for collision between two colliders.
@@ -234,7 +236,8 @@ private:
* \param type The type of collider pair.
* \return True if a collision is detected, otherwise false.
*/
- bool detect_collision(CollisionInternal & first_info, CollisionInternal & second_info, const CollisionInternalType & type);
+ bool detect_collision(CollisionInternal & first_info, CollisionInternal & second_info,
+ const CollisionInternalType & type);
/**
* \brief Detects collisions between two BoxColliders.
@@ -247,7 +250,8 @@ private:
* \param box2 Information about the second BoxCollider.
* \return If colliding, returns the resolution vector; otherwise, returns {NaN, NaN}.
*/
- vec2 get_box_box_detection(const BoxColliderInternal & box1, const BoxColliderInternal & box2) const;
+ vec2 get_box_box_detection(const BoxColliderInternal & box1,
+ const BoxColliderInternal & box2) const;
/**
* \brief Check collision for box on circle collider
@@ -260,7 +264,8 @@ private:
* \param circle2 Information about the circleCollider.
* \return If colliding, returns the resolution vector; otherwise, returns {NaN, NaN}.
*/
- vec2 get_box_circle_detection(const BoxColliderInternal & box1, const CircleColliderInternal & circle2) const;
+ vec2 get_box_circle_detection(const BoxColliderInternal & box1,
+ const CircleColliderInternal & circle2) const;
/**
* \brief Check collision for circle on circle collider
@@ -273,7 +278,8 @@ private:
* \param circle2 Information about the second circleCollider.
* \return If colliding, returns the resolution vector; otherwise, returns {NaN, NaN}.
*/
- vec2 get_circle_circle_detection(const CircleColliderInternal & circle1, const CircleColliderInternal & circle2) const;
+ vec2 get_circle_circle_detection(const CircleColliderInternal & circle1,
+ const CircleColliderInternal & circle2) const;
};
/**