Fix bug in value node range. If link is smaller than minimum it was returned link.
authorCarlos Lopez <genetita@gmail.com>
Sun, 25 Oct 2009 16:45:20 +0000 (17:45 +0100)
committerCarlos Lopez <genetita@gmail.com>
Sun, 25 Oct 2009 16:45:20 +0000 (17:45 +0100)
synfig-core/src/synfig/valuenode_range.cpp

index c45f369..c4107f8 100644 (file)
@@ -127,7 +127,9 @@ synfig::ValueNode_Range::operator()(Time t)const
                Angle minimum = (* min_)(t).get(Angle());
                Angle maximum = (* max_)(t).get(Angle());
                Angle link    = (*link_)(t).get(Angle());
-
+// This code was removed because it didn't work with link < minimum
+// It is sane to completely delete it if the replacement code is fine.
+/* ***********************************************
                // if link is between min and max, use it
                if (Angle::deg((link-minimum).mod()).get() < Angle::deg((maximum-minimum).mod()).get())
                        return link;
@@ -136,6 +138,13 @@ synfig::ValueNode_Range::operator()(Time t)const
                        return minimum;
                else
                        return maximum;
+*********************************************** */
+               if(Angle::rad(maximum).get()>=Angle::rad(link).get() && Angle::rad(link).get()>=Angle::rad(minimum).get())
+                       return link;
+               else if (Angle::rad(minimum).get()>Angle::rad(link).get())
+                       return minimum;
+               else
+                       return maximum;
        }
        case ValueBase::TYPE_INTEGER:
                return std::max((*min_)(t).get(int()),  std::min((*max_)(t).get(int()),  (*link_)(t).get(int())));