aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-06 14:02:17 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-06 14:02:17 +0100
commit2a58a592fb80fff6ffe65f5cf7a7deccc325446e (patch)
tree6f30ecab5aff017625c1f0d1329968ceaa0a68ac /src
parent82863204048d65073bc5598dcb62f31e32b51430 (diff)
parent5350944a3967042e3eb1136859660addaa771593 (diff)
Merge branch 'jaro/collision-system' of github.com:lonkaars/crepe into max/AI
Diffstat (limited to 'src')
-rw-r--r--src/crepe/system/CollisionSystem.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp
index da9e3af..2a487fd 100644
--- a/src/crepe/system/CollisionSystem.cpp
+++ b/src/crepe/system/CollisionSystem.cpp
@@ -188,7 +188,7 @@ CollisionSystem::collision_handler(CollisionInternal & data1, CollisionInternal
}
Direction resolution_direction = Direction::NONE;
- if (resolution.x != 0 && resolution.y > 0) {
+ if (resolution.x != 0 && resolution.y != 0) {
resolution_direction = Direction::BOTH;
} else if (resolution.x != 0) {
resolution_direction = Direction::X_DIRECTION;
@@ -303,7 +303,7 @@ void CollisionSystem::determine_collision_handler(CollisionInfo & info) {
if (info.this_rigidbody.data.body_type == Rigidbody::BodyType::STATIC) return;
// If second body is static perform the static collision handler in this system
if (info.other_rigidbody.data.body_type == Rigidbody::BodyType::STATIC) {
- static_collision_handler(info);
+ this->static_collision_handler(info);
};
// Call collision event for user
CollisionEvent data(info);
@@ -508,7 +508,7 @@ bool CollisionSystem::get_box_circle_collision(const BoxCollider & box1,
float distance_squared = distance_x * distance_x + distance_y * distance_y;
// Compare distance squared with the square of the circle's radius
- return distance_squared <= circle2.radius * circle2.radius - 1;
+ return distance_squared < circle2.radius * circle2.radius;
}
bool CollisionSystem::get_circle_circle_collision(const CircleCollider & circle1,
@@ -529,7 +529,7 @@ bool CollisionSystem::get_circle_circle_collision(const CircleCollider & circle1
float radius_sum = circle1.radius + circle2.radius;
// Check if the distance between the centers is less than or equal to the sum of the radii
- return distance_squared <= radius_sum * radius_sum - 1;
+ return distance_squared < radius_sum * radius_sum;
}
vec2 CollisionSystem::get_current_position(const vec2 & collider_offset,
@@ -550,3 +550,5 @@ vec2 CollisionSystem::get_current_position(const vec2 & collider_offset,
// Final positions considering scaling and rotation
return (transform.position + vec2(rotated_total_offset_x1, rotated_total_offset_y1));
}
+
+