浏览代码

Add early return to circle sector functions when angles are equal.
Prevents unnecessary work and division by zero (when segments=0) in DrawCircleSector/DrawCircleSectorLines when startAngle equals endAngle, matching existing behavior in DrawRing/DrawRingLines.

Myrddin Krustowski 6 月之前
父节点
当前提交
589ad0a33d
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      src/rshapes.c

+ 2 - 0
src/rshapes.c

@@ -285,6 +285,7 @@ void DrawCircleV(Vector2 center, float radius, Color color)
 // Draw a piece of a circle
 // Draw a piece of a circle
 void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
 void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
 {
 {
+    if (startAngle == endAngle) return;
     if (radius <= 0.0f) radius = 0.1f;  // Avoid div by zero
     if (radius <= 0.0f) radius = 0.1f;  // Avoid div by zero
 
 
     // Function expects (endAngle > startAngle)
     // Function expects (endAngle > startAngle)
@@ -376,6 +377,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
 // Draw a piece of a circle outlines
 // Draw a piece of a circle outlines
 void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
 void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color)
 {
 {
+    if (startAngle == endAngle) return;
     if (radius <= 0.0f) radius = 0.1f;  // Avoid div by zero issue
     if (radius <= 0.0f) radius = 0.1f;  // Avoid div by zero issue
 
 
     // Function expects (endAngle > startAngle)
     // Function expects (endAngle > startAngle)