common bezier: fix a regression bug.

revert issued code from def6393d82.
This commit is contained in:
Hermet Park 2023-07-12 19:34:26 +09:00 committed by Hermet Park
parent def6393d82
commit d7058e41e4

View file

@ -23,6 +23,8 @@
#include "tvgMath.h"
#include "tvgBezier.h"
#define BEZIER_EPSILON 1e-4f
/************************************************************************/
/* Internal Class Implementation */
/************************************************************************/
@ -74,7 +76,7 @@ float bezLength(const Bezier& cur)
auto len = _lineLength(cur.start, cur.ctrl1) + _lineLength(cur.ctrl1, cur.ctrl2) + _lineLength(cur.ctrl2, cur.end);
auto chord = _lineLength(cur.start, cur.end);
if (!mathEqual(len, chord)) {
if (fabsf(len - chord) > BEZIER_EPSILON) {
bezSplit(cur, left, right);
return bezLength(left) + bezLength(right);
}
@ -122,7 +124,7 @@ float bezAt(const Bezier& bz, float at)
Bezier left;
bezSplitLeft(right, t, left);
len = bezLength(left);
if (mathEqual(len, at) || mathEqual(smallest, biggest)) {
if (fabsf(len - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < BEZIER_EPSILON) {
break;
}
if (len < at) {