X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fvaluenode_reciprocal.cpp;h=d31a995fef10a041248a07dd4d1ef07907e5b87d;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=4af20519fa3a4550e48b8eae0b8e979b052ff919;hpb=c1bc26f5ac49529976e682fbdb9eff2da11eb709;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp b/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp index 4af2051..d31a995 100644 --- a/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_reciprocal.cpp @@ -6,7 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007 Chris Moore +** Copyright (c) 2007, 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -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* @@ -81,26 +85,24 @@ ValueNode_Reciprocal::~ValueNode_Reciprocal() } bool -ValueNode_Reciprocal::set_link_vfunc(int i,ValueNode::Handle x) +ValueNode_Reciprocal::set_link_vfunc(int i,ValueNode::Handle value) { - assert(i >= 0 && i < link_count()); + assert(i>=0 && i= 0 && i < link_count()); + assert(i>=0 && i= 0 && i < link_count()); + assert(i>=0 && i= 0 && i < link_count()); + assert(i>=0 && i