Improve the derivative class for hermites. Compare http://synfig.org/images/a/a8...
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_blinecalctangent.cpp
index 822de68..0d27157 100644 (file)
@@ -6,7 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 Chris Moore
+**     Copyright (c) 2007, 2008 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -127,21 +127,12 @@ ValueNode_BLineCalcTangent::operator()(Time t)const
                                                           blinepoint0.get_tangent2(), blinepoint1.get_tangent1());
        etl::derivative< etl::hermite<Vector> > deriv(curve);
 
-#ifdef ETL_FIXED_DERIVATIVE
        switch (get_type())
        {
-               case ValueBase::TYPE_ANGLE:  return (deriv(amount-from_vertex)*(0.5)).angle();
-               case ValueBase::TYPE_VECTOR: return deriv(amount-from_vertex)*(0.5);
+               case ValueBase::TYPE_ANGLE:  return deriv(amount-from_vertex).angle();
+               case ValueBase::TYPE_VECTOR: return deriv(amount-from_vertex);
                default: assert(0); return ValueBase();
        }
-#else
-       switch (get_type())
-       {
-               case ValueBase::TYPE_ANGLE:  return (deriv(amount-from_vertex)*(-0.5)).angle();
-               case ValueBase::TYPE_VECTOR: return deriv(amount-from_vertex)*(-0.5);
-               default: assert(0); return ValueBase();
-       }
-#endif
 }
 
 String
@@ -157,23 +148,15 @@ ValueNode_BLineCalcTangent::get_local_name()const
 }
 
 bool
-ValueNode_BLineCalcTangent::set_link_vfunc(int i,ValueNode::Handle x)
+ValueNode_BLineCalcTangent::set_link_vfunc(int i,ValueNode::Handle value)
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
-               case 0:
-                       bline_=x;
-                       signal_child_changed()(i);signal_value_changed()();
-                       return true;
-               case 1:
-                       loop_=x;
-                       signal_child_changed()(i);signal_value_changed()();
-                       return true;
-               case 2:
-                       amount_=x;
-                       signal_child_changed()(i);signal_value_changed()();
-                       return true;
+       case 0: CHECK_TYPE_AND_SET_VALUE(bline_,  ValueBase::TYPE_LIST);
+       case 1: CHECK_TYPE_AND_SET_VALUE(loop_,   ValueBase::TYPE_BOOL);
+       case 2: CHECK_TYPE_AND_SET_VALUE(amount_, ValueBase::TYPE_REAL);
        }
        return false;
 }
@@ -182,6 +165,7 @@ ValueNode::LooseHandle
 ValueNode_BLineCalcTangent::get_link_vfunc(int i)const
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
                case 0: return bline_;
@@ -202,6 +186,7 @@ String
 ValueNode_BLineCalcTangent::link_name(int i)const
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
                case 0: return "bline";
@@ -215,6 +200,7 @@ String
 ValueNode_BLineCalcTangent::link_local_name(int i)const
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
                case 0: return _("BLine");