When converting to a "Reciprocal" ValueNode, default the link to the reciprocal of...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 8 Mar 2008 13:14:59 +0000 (13:14 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 8 Mar 2008 13:14:59 +0000 (13:14 +0000)
git-svn-id: http://svn.voria.com/code@1884 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp
synfig-core/trunk/src/synfig/valuenode_reciprocal.h

index 66d3790..023e325 100644 (file)
@@ -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*
index 820fca3..516ef47 100644 (file)
@@ -46,8 +46,7 @@ public:
        typedef etl::handle<ValueNode_Reciprocal> Handle;
        typedef etl::handle<const ValueNode_Reciprocal> ConstHandle;
 
-       ValueNode_Reciprocal(const ValueBase::Type &x);
-       ValueNode_Reciprocal(const ValueNode::Handle &x);
+       ValueNode_Reciprocal(const ValueBase &x);
 
        virtual ValueBase operator()(Time t)const;