aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-19 20:20:29 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-19 20:20:29 +0100
commit34d36c27549d54592051083aea6675dbaa9bb1fa (patch)
treeb8e953b0285c58807115ee044eedab880e7d00d8
parent3e7a0a5a2c5ad14ee388f3ac460bf63bdb6ccfd5 (diff)
nan test fix
-rw-r--r--src/crepe/system/CollisionSystem.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp
index 0b9ea61..0bceac7 100644
--- a/src/crepe/system/CollisionSystem.cpp
+++ b/src/crepe/system/CollisionSystem.cpp
@@ -319,11 +319,14 @@ vec2 CollisionSystem::get_box_circle_detection(const BoxColliderInternal & box,
= std::sqrt(closest_delta.x * closest_delta.x + closest_delta.y * closest_delta.y);
vec2 collision_normal = closest_delta / distance;
- // Compute the resolution vector
- return vec2{collision_normal * penetration_depth};
- }
- // No collision
- return vec2{NAN, NAN};;
+ // Compute penetration depth
+ float penetration_depth = scaled_circle_radius - distance;
+
+ // Compute the resolution vector
+ return vec2{collision_normal * penetration_depth};
+ }
+ // No collision
+ return vec2{NAN, NAN};
}
vec2 CollisionSystem::get_circle_circle_detection(