diff --git a/src/loaders/lottie/tvgLottieModifier.cpp b/src/loaders/lottie/tvgLottieModifier.cpp index 9100ba2b..ecbfa67a 100644 --- a/src/loaders/lottie/tvgLottieModifier.cpp +++ b/src/loaders/lottie/tvgLottieModifier.cpp @@ -27,6 +27,12 @@ /* Internal Class Implementation */ /************************************************************************/ +static bool _colinear(const Point* p) +{ + return tvg::zero(*p - *(p + 1)) && tvg::zero(*(p + 2) - *(p + 3)); +} + + static void _roundCorner(Array& cmds, Array& pts, Point& prev, Point& curr, Point& next, float r) { auto lenPrev = length(prev - curr); @@ -192,14 +198,10 @@ bool LottieRoundnessModifier::modifyPath(PathCommand* inCmds, uint32_t inCmdsCnt break; } case PathCommand::CubicTo: { - auto& prev = inPts[iPts - 1]; - auto& curr = inPts[iPts + 2]; - if (iCmds < inCmdsCnt - 1 && - tvg::zero(inPts[iPts - 1] - inPts[iPts]) && - tvg::zero(inPts[iPts + 1] - inPts[iPts + 2])) { - if (inCmds[iCmds + 1] == PathCommand::CubicTo && - tvg::zero(inPts[iPts + 2] - inPts[iPts + 3]) && - tvg::zero(inPts[iPts + 4] - inPts[iPts + 5])) { + if (iCmds < inCmdsCnt - 1 && _colinear(inPts + iPts - 1)) { + auto& prev = inPts[iPts - 1]; + auto& curr = inPts[iPts + 2]; + if (inCmds[iCmds + 1] == PathCommand::CubicTo && _colinear(inPts + iPts + 2)) { _roundCorner(path.cmds, path.pts, prev, curr, inPts[iPts + 5], r); iPts += 3; break;