Skip to content

Commit 55a54ad

Browse files
committed
Rework pathsampler fix
1 parent d3f6c9e commit 55a54ad

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/base/gfx/pathsampler.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@ void PathSampler::path(const Geom::Point &pConv0,
2424
constexpr static size_t maxRecursion = 20;
2525
if (recurseCnt >= maxRecursion) return;
2626

27-
const auto sqrLength = (pConv1 - pConv0).sqrAbs();
28-
if (Math::Floating::is_zero(sqrLength)) return;
29-
3027
const auto i = (i0 + i1) / 2.0;
3128
const auto pConv = getPoint(i);
29+
3230
const auto area = Geom::Triangle{{pConv0, pConv, pConv1}}.area();
33-
const auto height = 2 * area / sqrt(sqrLength);
31+
const auto sqrLength = (pConv1 - pConv0).sqrAbs();
32+
const auto height = Math::Floating::is_zero(sqrLength)
33+
? 0.0
34+
: 2 * area / sqrt(sqrLength);
3435

3536
const auto sqrAbs0 = (pConv - pConv0).sqrAbs();
3637
const auto sqrAbs1 = (pConv - pConv1).sqrAbs();
3738

3839
auto needMore = height > options.curveHeightMax
39-
|| (sqrLength < sqrAbs0) || (sqrLength < sqrAbs1);
40+
|| sqrLength < sqrAbs0 || sqrLength < sqrAbs1;
4041

4142
if (needMore && sqrAbs0 > options.distanceMax)
4243
path(pConv0, pConv, i0, i, recurseCnt + 1);

0 commit comments

Comments
 (0)