aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/CollisionSystem.cpp
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-09 13:24:27 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-09 13:24:27 +0100
commitee56ebd4cf1ca1ef04f1f8c36431ebb54447cc46 (patch)
treec15bbd0f6524064569690b4436b5d91f3feeafd4 /src/crepe/system/CollisionSystem.cpp
parenta4d76993e51ac4486fc313e868285eb7b4cb89f2 (diff)
parent4d74c80d9c3c9fdca9b07d960a1f9fd3e38cdfad (diff)
Merge remote-tracking branch 'origin/master' into max/AI
Diffstat (limited to 'src/crepe/system/CollisionSystem.cpp')
-rw-r--r--src/crepe/system/CollisionSystem.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp
index 1282f7a..44a0431 100644
--- a/src/crepe/system/CollisionSystem.cpp
+++ b/src/crepe/system/CollisionSystem.cpp
@@ -155,8 +155,8 @@ CollisionSystem::collision_handler(CollisionInternal & data1, CollisionInternal
data1.rigidbody);
vec2 collider_pos2 = this->get_current_position(collider2.offset, data2.transform,
data2.rigidbody);
- resolution = this->get_circle_box_resolution(collider2, collider1, collider_pos2,
- collider_pos1, true);
+ resolution = -this->get_circle_box_resolution(collider2, collider1, collider_pos2,
+ collider_pos1);
break;
}
case CollisionInternalType::CIRCLE_CIRCLE: {
@@ -182,7 +182,7 @@ CollisionSystem::collision_handler(CollisionInternal & data1, CollisionInternal
vec2 collider_pos2 = this->get_current_position(collider2.offset, data2.transform,
data2.rigidbody);
resolution = this->get_circle_box_resolution(collider1, collider2, collider_pos1,
- collider_pos2, false);
+ collider_pos2);
break;
}
}
@@ -268,8 +268,7 @@ vec2 CollisionSystem::get_circle_circle_resolution(const CircleCollider & circle
vec2 CollisionSystem::get_circle_box_resolution(const CircleCollider & circle_collider,
const BoxCollider & box_collider,
const vec2 & circle_position,
- const vec2 & box_position,
- bool inverse) const {
+ const vec2 & box_position) const {
vec2 delta = circle_position - box_position;
// Compute half-dimensions of the box
@@ -291,7 +290,7 @@ vec2 CollisionSystem::get_circle_box_resolution(const CircleCollider & circle_co
// Compute penetration depth
float penetration_depth = circle_collider.radius - distance;
- if (inverse) collision_normal = -collision_normal;
+
// Compute the resolution vector
vec2 resolution = collision_normal * penetration_depth;