Fix for FollowPathConstraint position at distance multiples of 100% Reported by Chad and simpleclub that the position of the constrained component moves to its 0 distance position when distance is set to any multiple of 100%. Fix is for editor and runtimes. Diffs= 40f9d91ac Fix for FollowPathConstraint position at distance multiples of 100% (#6149) Co-authored-by: Philip Chung <philterdesign@gmail.com>
diff --git a/.rive_head b/.rive_head index 90492b7..944467e 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -6d9aa017961638f7576a2ea52a8928c813e28dbb +40f9d91ac8063448c357682ea97d5abbfe71ce1f
diff --git a/src/constraints/follow_path_constraint.cpp b/src/constraints/follow_path_constraint.cpp index 55c54f7..8e7db06 100644 --- a/src/constraints/follow_path_constraint.cpp +++ b/src/constraints/follow_path_constraint.cpp
@@ -43,13 +43,17 @@ } float actualDistance = positiveMod(distance(), 1.0f); + if (distance() != 0 && actualDistance == 0) + { + actualDistance = 1; + } float distanceUnits = totalLength * std::min(1.0f, std::max(0.0f, actualDistance)); float runningLength = 0; ContourMeasure::PosTan posTan; for (auto contour : m_contours) { float pathLength = contour->length(); - if (distanceUnits < pathLength + runningLength) + if (distanceUnits <= pathLength + runningLength) { posTan = contour->getPosTan(distanceUnits - runningLength); break;