From c354dc9e30289e747b15e1ae66fbe5fe0d617e67 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 11 May 2012 02:47:24 +0000 Subject: [PATCH] Fix brokenness in the curve smoothing Originally committed to SVN as r6760. --- aegisub/src/spline.cpp | 12 ++++++------ aegisub/src/spline_curve.cpp | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/aegisub/src/spline.cpp b/aegisub/src/spline.cpp index e3a202273..d7c702c12 100644 --- a/aegisub/src/spline.cpp +++ b/aegisub/src/spline.cpp @@ -281,14 +281,14 @@ void Spline::Smooth(float smooth) { if (size() < 3) return; // Smooth curve - iterator curve1 = end(); - --curve1; + iterator cur_curve = end(); + --cur_curve; for (iterator cur = begin(); cur != end(); ) { - iterator curve0 = curve1; - curve1 = cur; + iterator prev_curve = cur_curve; + cur_curve = cur; ++cur; - iterator curve2 = cur == end() ? begin() : cur; + iterator next_curve = cur == end() ? begin() : cur; - curve1->Smooth(curve0->p1, curve2->p2, smooth); + cur_curve->Smooth(prev_curve->p1, next_curve->EndPoint(), smooth); } } diff --git a/aegisub/src/spline_curve.cpp b/aegisub/src/spline_curve.cpp index 0e4569583..08407513a 100644 --- a/aegisub/src/spline_curve.cpp +++ b/aegisub/src/spline_curve.cpp @@ -74,18 +74,18 @@ std::pair SplineCurve::Split(float t) { return std::make_pair(SplineCurve(p1), SplineCurve(p1)); } -void SplineCurve::Smooth(Vector2D p0, Vector2D p3, float smooth) { +void SplineCurve::Smooth(Vector2D p0, Vector2D p5, float smooth) { if (type != LINE || p1 == p2) return; smooth = mid(0.f, smooth, 1.f); // Calculate intermediate points Vector2D c1 = (p0 + p1) / 2.f; Vector2D c2 = (p1 + p2) / 2.f; - Vector2D c3 = (p2 + p3) / 2.f; + Vector2D c3 = (p2 + p5) / 2.f; float len1 = (p1 - p0).Len(); float len2 = (p2 - p1).Len(); - float len3 = (p3 - p2).Len(); + float len3 = (p5 - p2).Len(); float k1 = len1 / (len1 + len2); float k2 = len2 / (len2 + len3);