From e6efdb6732204cb498c236208321011c7cb3b709 Mon Sep 17 00:00:00 2001 From: dooglus Date: Tue, 4 Mar 2008 17:56:49 +0000 Subject: [PATCH] Fix the tangents output by "Segment Tangent" and "BLine Tangent". They were scaled by a factor of 0.5 before. Incremented the canvas version to 0.4 so existing .sif files still render the same. git-svn-id: http://svn.voria.com/code@1856 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/canvas.h | 9 ++++++++- synfig-core/trunk/src/synfig/loadcanvas.cpp | 13 +++++++++++++ synfig-core/trunk/src/synfig/valuenode_blinecalctangent.cpp | 4 ++-- synfig-core/trunk/src/synfig/valuenode_segcalctangent.cpp | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/synfig-core/trunk/src/synfig/canvas.h b/synfig-core/trunk/src/synfig/canvas.h index a7de319..d9e00d7 100644 --- a/synfig-core/trunk/src/synfig/canvas.h +++ b/synfig-core/trunk/src/synfig/canvas.h @@ -79,9 +79,16 @@ * 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 ===================================================== */ diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index 200456e..5b4fe86 100644 --- a/synfig-core/trunk/src/synfig/loadcanvas.cpp +++ b/synfig-core/trunk/src/synfig/loadcanvas.cpp @@ -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 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; } diff --git a/synfig-core/trunk/src/synfig/valuenode_blinecalctangent.cpp b/synfig-core/trunk/src/synfig/valuenode_blinecalctangent.cpp index 453b781..50c3afc 100644 --- a/synfig-core/trunk/src/synfig/valuenode_blinecalctangent.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_blinecalctangent.cpp @@ -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(); } } diff --git a/synfig-core/trunk/src/synfig/valuenode_segcalctangent.cpp b/synfig-core/trunk/src/synfig/valuenode_segcalctangent.cpp index 8d57261..e27d950 100644 --- a/synfig-core/trunk/src/synfig/valuenode_segcalctangent.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_segcalctangent.cpp @@ -84,7 +84,7 @@ ValueNode_SegCalcTangent::operator()(Time t)const etl::hermite curve(segment.p1,segment.p2,segment.t1,segment.t2); etl::derivative< etl::hermite > deriv(curve, 0.0001); - return deriv((*amount_)(t).get(Real()))*(0.5); + return deriv((*amount_)(t).get(Real())); } -- 2.7.4