From 34d36c27549d54592051083aea6675dbaa9bb1fa Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Thu, 19 Dec 2024 20:20:29 +0100 Subject: nan test fix --- src/crepe/system/CollisionSystem.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') 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( -- cgit v1.2.3