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;