From 0e0ee2e8e32ac86175d8f63aa3d6ea65044600e7 Mon Sep 17 00:00:00 2001 From: kai-z99 Date: Wed, 29 May 2024 21:23:21 -0700 Subject: [PATCH] epsilon --- src/rshapes.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index 0d9edc87d..cb85c1c54 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -2320,17 +2320,17 @@ RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Ve { float dx = p1.x - p2.x; float dy = p1.y - p2.y; + + if ((fabsf(dx) + fabsf(dy)) <= FLT_EPSILON) + { + return CheckCollisionCircles(p1, 0, center, radius); + } + float lengthSQ = ((dx * dx) + (dy * dy)); float dotProduct = (((center.x - p1.x) * (p2.x - p1.x)) + ((center.y - p1.y) * (p2.y - p1.y))) / (lengthSQ); - if (dotProduct > 1.0f) - { - dotProduct = 1.0f; - } - else if (dotProduct < 0.0f) - { - dotProduct = 0.0f; - } + if (dotProduct > 1.0f) dotProduct = 1.0f; + else if (dotProduct < 0.0f) dotProduct = 0.0f; float dx2 = (p1.x - (dotProduct * (dx))) - center.x; float dy2 = (p1.y - (dotProduct * (dy))) - center.y;