Fix the tangents output by "Segment Tangent" and "BLine Tangent". They were scaled...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 4 Mar 2008 17:56:49 +0000 (17:56 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 4 Mar 2008 17:56:49 +0000 (17:56 +0000)
git-svn-id: http://svn.voria.com/code@1856 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/canvas.h
synfig-core/trunk/src/synfig/loadcanvas.cpp
synfig-core/trunk/src/synfig/valuenode_blinecalctangent.cpp
synfig-core/trunk/src/synfig/valuenode_segcalctangent.cpp

index a7de319..d9e00d7 100644 (file)
  *      examples/logo.sifz use transparent straight blends to do
  *      masking, which no longer works now that 'straight' blending is
  *      fixed.
+ *
+ *      Tangent lengths calculated by the "Segment Tangent" and "BLine
+ *      Tangent" ValueNodes were scaled by a factor of 0.5.
+ *
+ * 0.4: svn r1856
+ *
+ *      Stop scaling tangents by 0.5.
  */
 
-#define CURRENT_CANVAS_VERSION "0.3"
+#define CURRENT_CANVAS_VERSION "0.4"
 
 /* === T Y P E D E F S ===================================================== */
 
index 200456e..5b4fe86 100644 (file)
@@ -1289,6 +1289,19 @@ CanvasParser::parse_linkable_value_node(xmlpp::Element *element,Canvas::Handle c
                }
        }
 
+       // pre 0.4 canvases had *calctangent outputs scaled down by 0.5 for some reason
+       if (element->get_name() == "blinecalctangent" || element->get_name() == "segcalctangent")
+       {
+               String version(canvas->get_version());
+               if (version == "0.1" || version == "0.2" || version == "0.3")
+               {
+                       handle<LinkableValueNode> scale_value_node=LinkableValueNode::create("scale",type);
+                       scale_value_node->set_link(scale_value_node->get_link_index_from_name("link"), value_node);
+                       scale_value_node->set_link(scale_value_node->get_link_index_from_name("scalar"), ValueNode_Const::create(Real(0.5)));
+                       value_node = scale_value_node;
+               }
+       }
+
        return value_node;
 }
 
index 453b781..50c3afc 100644 (file)
@@ -129,8 +129,8 @@ ValueNode_BLineCalcTangent::operator()(Time t)const
 
        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();
        }
 }
index 8d57261..e27d950 100644 (file)
@@ -84,7 +84,7 @@ ValueNode_SegCalcTangent::operator()(Time t)const
        etl::hermite<Vector> curve(segment.p1,segment.p2,segment.t1,segment.t2);
        etl::derivative< etl::hermite<Vector> > deriv(curve, 0.0001);
 
-       return deriv((*amount_)(t).get(Real()))*(0.5);
+       return deriv((*amount_)(t).get(Real()));
 }