Changed startAngle and endAngle comparison to use FLT_EPSILON instead of direct comparison of floating numbers

This commit is contained in:
Myrddin Krustowski 2025-03-18 12:40:39 +02:00
parent 589ad0a33d
commit 9ad9a348d1

View File

@ -285,7 +285,8 @@ void DrawCircleV(Vector2 center, float radius, Color color)
// Draw a piece of a circle
void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
{
if (startAngle == endAngle) return;
if (FLT_EPSILON < endAngle - startAngle && endAngle - startAngle < FLT_EPSILON) return;
if (radius <= 0.0f) radius = 0.1f; // Avoid div by zero
// Function expects (endAngle > startAngle)
@ -377,7 +378,8 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
// Draw a piece of a circle outlines
void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
{
if (startAngle == endAngle) return;
if (FLT_EPSILON < endAngle - startAngle && endAngle - startAngle < FLT_EPSILON) return;
if (radius <= 0.0f) radius = 0.1f; // Avoid div by zero issue
// Function expects (endAngle > startAngle)
@ -498,7 +500,7 @@ void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Co
// Draw ring
void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color)
{
if (startAngle == endAngle) return;
if (FLT_EPSILON < endAngle - startAngle && endAngle - startAngle < FLT_EPSILON) return;
// Function expects (outerRadius > innerRadius)
if (outerRadius < innerRadius)
@ -589,7 +591,7 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
// Draw ring outline
void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color)
{
if (startAngle == endAngle) return;
if (FLT_EPSILON < endAngle - startAngle && endAngle - startAngle < FLT_EPSILON) return;
// Function expects (outerRadius > innerRadius)
if (outerRadius < innerRadius)