From: dooglus Date: Sat, 8 Mar 2008 13:14:59 +0000 (+0000) Subject: When converting to a "Reciprocal" ValueNode, default the link to the reciprocal of... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1e5f0eeebce699f15e011e3cddbf5f790b2e003f;p=synfig.git When converting to a "Reciprocal" ValueNode, default the link to the reciprocal of the current value so the value remains the same. git-svn-id: http://svn.voria.com/code@1884 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp b/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp index 66d3790..023e325 100644 --- a/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp @@ -50,23 +50,27 @@ using namespace synfig; /* === M E T H O D S ======================================================= */ -ValueNode_Reciprocal::ValueNode_Reciprocal(const ValueBase::Type &x): - LinkableValueNode(x) +ValueNode_Reciprocal::ValueNode_Reciprocal(const ValueBase &x): + LinkableValueNode(x.get_type()) { -} + Real value(x.get(Real())); + Real infinity(999999.0); + Real epsilon(0.000001); -ValueNode_Reciprocal::ValueNode_Reciprocal(const ValueNode::Handle &x): - LinkableValueNode(x->get_type()) -{ - set_link("link", x); - set_link("epsilon", ValueNode_Const::create(Real(0.000001))); - set_link("infinite", ValueNode_Const::create(Real(999999.0))); + if (value == 0) + value = infinity; + else + value = 1.0/value; + + set_link("link", ValueNode_Const::create(Real(value))); + set_link("epsilon", ValueNode_Const::create(Real(epsilon))); + set_link("infinite", ValueNode_Const::create(Real(infinity))); } ValueNode_Reciprocal* ValueNode_Reciprocal::create(const ValueBase &x) { - return new ValueNode_Reciprocal(ValueNode_Const::create(x)); + return new ValueNode_Reciprocal(x); } LinkableValueNode* diff --git a/synfig-core/trunk/src/synfig/valuenode_reciprocal.h b/synfig-core/trunk/src/synfig/valuenode_reciprocal.h index 820fca3..516ef47 100644 --- a/synfig-core/trunk/src/synfig/valuenode_reciprocal.h +++ b/synfig-core/trunk/src/synfig/valuenode_reciprocal.h @@ -46,8 +46,7 @@ public: typedef etl::handle Handle; typedef etl::handle ConstHandle; - ValueNode_Reciprocal(const ValueBase::Type &x); - ValueNode_Reciprocal(const ValueNode::Handle &x); + ValueNode_Reciprocal(const ValueBase &x); virtual ValueBase operator()(Time t)const;