Skip to content

Commit

Permalink
Minor fix in DrawLineBezier* (#3006)
Browse files Browse the repository at this point in the history
When `i` starts with `0`, `t` is also `0`, which results in `previous == startPos == current`, this segment is not only redundant, but it also causes division-by-zero since `sqrtf(dx*dx + dy*dy)` is zero.
  • Loading branch information
eternalStudent authored Apr 9, 2023
1 parent e57ee9c commit 8f741d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rshapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, fl

Vector2 points[2*BEZIER_LINE_DIVISIONS + 2] = { 0 };

for (int i = 0; i <= BEZIER_LINE_DIVISIONS; i++)
for (int i = 1; i <= BEZIER_LINE_DIVISIONS; i++)
{
t = step*i;
float a = powf(1 - t, 2);
Expand Down Expand Up @@ -286,7 +286,7 @@ void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlP

Vector2 points[2*BEZIER_LINE_DIVISIONS + 2] = { 0 };

for (int i = 0; i <= BEZIER_LINE_DIVISIONS; i++)
for (int i = 1; i <= BEZIER_LINE_DIVISIONS; i++)
{
t = step*i;
float a = powf(1 - t, 3);
Expand Down

0 comments on commit 8f741d8

Please sign in to comment.