2
0
Эх сурвалжийг харах

Fix CheckCollisionCircleRec() (#3584)

ubkp 1 жил өмнө
parent
commit
e84099bfd4
1 өөрчлөгдсөн 12 нэмэгдсэн , 12 устгасан
  1. 12 12
      src/rshapes.c

+ 12 - 12
src/rshapes.c

@@ -1549,7 +1549,7 @@ void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color)
     Vector2 delta = { 0 };
     float length = 0.0f;
     float scale = 0.0f;
-    
+
     for (int i = 0; i < pointCount - 1; i++)
     {
         delta = (Vector2){ points[i + 1].x - points[i].x, points[i + 1].y - points[i].y };
@@ -1568,7 +1568,7 @@ void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color)
         DrawTriangleStrip(strip, 4, color);
     }
 #if defined(SUPPORT_SPLINE_SEGMENT_CAPS)
-    
+
 #endif
 }
 
@@ -1718,7 +1718,7 @@ void DrawSplineCatmullRom(Vector2 *points, int pointCount, float thick, Color co
 void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Color color)
 {
     if (pointCount < 3) return;
-    
+
     for (int i = 0; i < pointCount - 2; i++)
     {
         DrawSplineSegmentBezierQuadratic(points[i], points[i + 1], points[i + 2], thick, color);
@@ -1729,7 +1729,7 @@ void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Col
 void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color color)
 {
     if (pointCount < 4) return;
-    
+
     for (int i = 0; i < pointCount - 3; i++)
     {
         DrawSplineSegmentBezierCubic(points[i], points[i + 1], points[i + 2], points[i + 3], thick, color);
@@ -1740,7 +1740,7 @@ void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color c
 void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color)
 {
     // NOTE: For the linear spline we don't use subdivisions, just a single quad
-    
+
     Vector2 delta = { p2.x - p1.x, p2.y - p1.y };
     float length = sqrtf(delta.x*delta.x + delta.y*delta.y);
 
@@ -1768,9 +1768,9 @@ void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, floa
     Vector2 currentPoint = { 0 };
     Vector2 nextPoint = { 0 };
     float t = 0.0f;
-    
+
     Vector2 points[2*SPLINE_SEGMENT_DIVISIONS + 2] = { 0 };
-    
+
     float a[4] = { 0 };
     float b[4] = { 0 };
 
@@ -1825,7 +1825,7 @@ void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4,
     Vector2 currentPoint = p1;
     Vector2 nextPoint = { 0 };
     float t = 0.0f;
-    
+
     Vector2 points[2*SPLINE_SEGMENT_DIVISIONS + 2] = { 0 };
 
     for (int i = 0; i <= SPLINE_SEGMENT_DIVISIONS; i++)
@@ -2132,11 +2132,11 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
 {
     bool collision = false;
 
-    int recCenterX = (int)(rec.x + rec.width/2.0f);
-    int recCenterY = (int)(rec.y + rec.height/2.0f);
+    float recCenterX = rec.x + rec.width/2.0f;
+    float recCenterY = rec.y + rec.height/2.0f;
 
-    float dx = fabsf(center.x - (float)recCenterX);
-    float dy = fabsf(center.y - (float)recCenterY);
+    float dx = fabsf(center.x - recCenterX);
+    float dy = fabsf(center.y - recCenterY);
 
     if (dx > (rec.width/2.0f + radius)) { return false; }
     if (dy > (rec.height/2.0f + radius)) { return false; }