Skip to content

Commit

Permalink
Fix CheckCollisionCircleRec() (raysan5#3584)
Browse files Browse the repository at this point in the history
  • Loading branch information
ubkp authored Nov 30, 2023
1 parent bd81bdc commit e84099b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/rshapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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 };

Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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; }
Expand Down

0 comments on commit e84099b

Please sign in to comment.