For the 'Range' convert type, when working with angles, if the link parameter is...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Fri, 28 Sep 2007 03:01:15 +0000 (03:01 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Fri, 28 Sep 2007 03:01:15 +0000 (03:01 +0000)
git-svn-id: http://svn.voria.com/code@794 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/valuenode_range.cpp

index 712c974..40104d0 100644 (file)
@@ -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: