From: dooglus Date: Tue, 18 Sep 2007 19:41:49 +0000 (+0000) Subject: Use a switch statement in the operator() like the other valuenode types do. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d2938ec49f02ec693cff4dc83531142bacdb0328;p=synfig.git Use a switch statement in the operator() like the other valuenode types do. git-svn-id: http://svn.voria.com/code@711 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/valuenode_subtract.cpp b/synfig-core/trunk/src/synfig/valuenode_subtract.cpp index 4d31718..e4c9756 100644 --- a/synfig-core/trunk/src/synfig/valuenode_subtract.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_subtract.cpp @@ -192,22 +192,26 @@ synfig::ValueNode_Subtract::operator()(Time t)const { if(!ref_a || !ref_b) throw runtime_error(strprintf("ValueNode_Subtract: %s",_("One or both of my parameters aren't set!"))); - if(get_type()==ValueBase::TYPE_ANGLE) + switch(get_type()) + { + case ValueBase::TYPE_ANGLE: return ((*ref_a)(t).get(Angle())-(*ref_b)(t).get(Angle()))*(*scalar)(t).get(Real()); - if(get_type()==ValueBase::TYPE_COLOR) + case ValueBase::TYPE_COLOR: return ((*ref_a)(t).get(Color())-(*ref_b)(t).get(Color()))*(*scalar)(t).get(Real()); - if(get_type()==ValueBase::TYPE_INTEGER) + case ValueBase::TYPE_INTEGER: { - Real value = ((*ref_a)(t).get(int())-(*ref_b)(t).get(int()))*(*scalar)(t).get(Real()) + 0.5f; - if (value < 0) return static_cast(value-1); - return static_cast(value); + Real ret = ((*ref_a)(t).get(int())-(*ref_b)(t).get(int()))*(*scalar)(t).get(Real()) + 0.5f; + if (ret < 0) return static_cast(ret-1); + return static_cast(ret); } - if(get_type()==ValueBase::TYPE_REAL) + case ValueBase::TYPE_REAL: return ((*ref_a)(t).get(Vector::value_type())-(*ref_b)(t).get(Vector::value_type()))*(*scalar)(t).get(Real()); - if(get_type()==ValueBase::TYPE_VECTOR) + case ValueBase::TYPE_VECTOR: return ((*ref_a)(t).get(Vector())-(*ref_b)(t).get(Vector()))*(*scalar)(t).get(Real()); - - synfig::error(get_id()+':'+strprintf(_("Cannot subtract types of %s and %s"),ValueBase::type_name(ref_a->get_type()).c_str(),ValueBase::type_name(ref_b->get_type()).c_str())); + default: + assert(0); + break; + } return ValueBase(); }