aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/CollisionSystem.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-06 15:32:31 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-06 15:32:31 +0100
commit27a5332ee8e905d346a088ac7f4d1d1bb30025c4 (patch)
tree4fd6de40c24db089937a7e7573950f8c8117c33a /src/crepe/system/CollisionSystem.cpp
parent5350944a3967042e3eb1136859660addaa771593 (diff)
review feedback
Diffstat (limited to 'src/crepe/system/CollisionSystem.cpp')
-rw-r--r--src/crepe/system/CollisionSystem.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp
index 44ea7ee..e196e10 100644
--- a/src/crepe/system/CollisionSystem.cpp
+++ b/src/crepe/system/CollisionSystem.cpp
@@ -158,8 +158,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: {
@@ -185,7 +185,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;
}
}
@@ -272,7 +272,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
@@ -294,7 +294,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;