Skip to content

Commit 625bc4c

Browse files
mymedia2hermet
authored andcommitted
Finite loop in VBezier::tAtLength()
1 parent ddbc9dc commit 625bc4c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/vector/vbezier.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ float VBezier::tAtLength(float l, float totalLength) const
8181
t *= 0.5;
8282

8383
float lastBigger = 1.0;
84-
while (1) {
84+
for (int num = 0; num < 100500; num++) {
8585
VBezier right = *this;
8686
VBezier left;
8787
right.parameterSplitLeft(t, &left);
8888
float lLen = left.length();
89-
if (fabs(lLen - l) < error) break;
89+
if (fabs(lLen - l) < error) return t;
9090

9191
if (lLen < l) {
9292
t += (lastBigger - t) * 0.5f;
@@ -95,6 +95,7 @@ float VBezier::tAtLength(float l, float totalLength) const
9595
t -= t * 0.5f;
9696
}
9797
}
98+
vWarning << "no convergence";
9899
return t;
99100
}
100101

0 commit comments

Comments
 (0)