diff options
| author | eternalStudent <[email protected]> | 2023-04-09 23:43:06 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-09 22:43:06 +0200 |
| commit | 8f741d894ab350eec275df8eacf85636d38861f3 (patch) | |
| tree | 82583dce5d1f0036e1084ddcfd59c6e23c5cef86 | |
| parent | e57ee9c0e84de9cbf6fddf2f46786e87c64cb64e (diff) | |
| download | raylib-8f741d894ab350eec275df8eacf85636d38861f3.tar.gz raylib-8f741d894ab350eec275df8eacf85636d38861f3.zip | |
Minor fix in DrawLineBezier* (#3006)
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.
| -rw-r--r-- | src/rshapes.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rshapes.c b/src/rshapes.c index f7ee8f5c..52c5648d 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -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); @@ -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); |
