From 2996b84ecd9cd8776441ac0388dc30257cd21929 Mon Sep 17 00:00:00 2001 From: dooglus Date: Fri, 28 Sep 2007 03:01:15 +0000 Subject: [PATCH] For the 'Range' convert type, when working with angles, if the link parameter is outside of the [min,max] rangle, the resulting angle is whichever of min and max is closest to the link parameter. git-svn-id: http://svn.voria.com/code@794 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/valuenode_range.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/synfig-core/trunk/src/synfig/valuenode_range.cpp b/synfig-core/trunk/src/synfig/valuenode_range.cpp index 712c974..40104d0 100644 --- a/synfig-core/trunk/src/synfig/valuenode_range.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_range.cpp @@ -123,7 +123,20 @@ synfig::ValueNode_Range::operator()(Time t)const switch(get_type()) { case ValueBase::TYPE_ANGLE: - return range((*min_)(t).get(Angle()), (*max_)(t).get(Angle()), (*link_)(t).get(Angle())); + { + Angle minimum = (* min_)(t).get(Angle()); + Angle maximum = (* max_)(t).get(Angle()); + Angle link = (*link_)(t).get(Angle()); + + // if link is between min and max, use it + if (Angle::deg((link-minimum).mod()).get() < Angle::deg((maximum-minimum).mod()).get()) + return link; + // otherwise use whichever of min and max is closest to link + else if (link.dist(minimum).abs() < link.dist(maximum).abs()) + return minimum; + else + return maximum; + } case ValueBase::TYPE_INTEGER: return range((*min_)(t).get(int()), (*max_)(t).get(int()), (*link_)(t).get(int())); case ValueBase::TYPE_REAL: -- 2.7.4