summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorubkp <[email protected]>2023-11-30 06:11:45 -0300
committerGitHub <[email protected]>2023-11-30 10:11:45 +0100
commite84099bfd42669250a5df4b29f8ffebbd21fbc82 (patch)
treeae64ce2815af119453c505c8fc9ddb176ca9f0e4 /src
parentbd81bdc24a2e896d641706fd23bb379d19cb2426 (diff)
downloadraylib-e84099bfd42669250a5df4b29f8ffebbd21fbc82.tar.gz
raylib-e84099bfd42669250a5df4b29f8ffebbd21fbc82.zip
Fix CheckCollisionCircleRec() (#3584)
Diffstat (limited to 'src')
-rw-r--r--src/rshapes.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/rshapes.c b/src/rshapes.c
index bababf8c..4b3f2cfd 100644
--- a/src/rshapes.c
+++ b/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; }