Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_reciprocal.cpp
index 66d3790..d31a995 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*
@@ -147,6 +151,9 @@ ValueNode_Reciprocal::get_link_index_from_name(const String &name)const
 ValueBase
 ValueNode_Reciprocal::operator()(Time t)const
 {
+       if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
+               printf("%s:%d operator()\n", __FILE__, __LINE__);
+
        Real link     = (*link_)    (t).get(Real());
        Real epsilon  = (*epsilon_) (t).get(Real());
        Real infinite = (*infinite_)(t).get(Real());