Discard empty verbs from RawPath Diffs= 542e320d2 Discard empty verbs from RawPath (#5166)
diff --git a/.rive_head b/.rive_head index 03e19ad..bd6b5f4 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -abc600932de98bb9552585370faa27b57d96b7db +542e320d21dc6c27dca04bc7c853bd5f1ae6970a
diff --git a/src/math/raw_path.cpp b/src/math/raw_path.cpp index 73d5b9f..90cafdd 100644 --- a/src/math/raw_path.cpp +++ b/src/math/raw_path.cpp
@@ -63,6 +63,12 @@ void RawPath::line(Vec2D a) { injectImplicitMoveIfNeeded(); + if (a == m_Points.back()) + { + // Discard empty verbs, while retaining the implicit move so the path still has a + // potentially empty contour. + return; + } m_Points.push_back(a); m_Verbs.push_back(PathVerb::line); } @@ -70,6 +76,12 @@ void RawPath::quad(Vec2D a, Vec2D b) { injectImplicitMoveIfNeeded(); + if (b == a && a == m_Points.back()) + { + // Discard empty verbs, while retaining the implicit move so the path still has a + // potentially empty contour. + return; + } m_Points.push_back(a); m_Points.push_back(b); m_Verbs.push_back(PathVerb::quad); @@ -78,6 +90,12 @@ void RawPath::cubic(Vec2D a, Vec2D b, Vec2D c) { injectImplicitMoveIfNeeded(); + if (c == b && b == a && a == m_Points.back()) + { + // Discard empty verbs, while retaining the implicit move so the path still has a + // potentially empty contour. + return; + } m_Points.push_back(a); m_Points.push_back(b); m_Points.push_back(c);