From 8855fdd4a26f69afaa5a018c6eb9cfc770f0c09d Mon Sep 17 00:00:00 2001 From: dooglus Date: Wed, 10 Oct 2007 15:54:11 +0000 Subject: [PATCH] Use the ETL 'round_to_int' function rather than re-writing it in each of these files. git-svn-id: http://svn.voria.com/code@895 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/valuenode_add.cpp | 7 ++----- synfig-core/trunk/src/synfig/valuenode_linear.cpp | 7 ++----- synfig-core/trunk/src/synfig/valuenode_scale.cpp | 7 ++----- synfig-core/trunk/src/synfig/valuenode_subtract.cpp | 7 ++----- synfig-core/trunk/src/synfig/valuenode_timedswap.cpp | 3 ++- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/synfig-core/trunk/src/synfig/valuenode_add.cpp b/synfig-core/trunk/src/synfig/valuenode_add.cpp index 172b305..9f83229 100644 --- a/synfig-core/trunk/src/synfig/valuenode_add.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_add.cpp @@ -38,6 +38,7 @@ #include "vector.h" #include "angle.h" #include "real.h" +#include #endif @@ -173,11 +174,7 @@ synfig::ValueNode_Add::operator()(Time t)const case ValueBase::TYPE_COLOR: return ((*ref_a)(t).get(Color())+(*ref_b)(t).get(Color()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_INTEGER: - { - 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); - } + return round_to_int(((*ref_a)(t).get(int())+(*ref_b)(t).get(int()))*(*scalar)(t).get(Real())); case ValueBase::TYPE_REAL: return ((*ref_a)(t).get(Vector::value_type())+(*ref_b)(t).get(Vector::value_type()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_TIME: diff --git a/synfig-core/trunk/src/synfig/valuenode_linear.cpp b/synfig-core/trunk/src/synfig/valuenode_linear.cpp index f0d6c11..b017c9a 100644 --- a/synfig-core/trunk/src/synfig/valuenode_linear.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_linear.cpp @@ -34,6 +34,7 @@ #include "valuenode_const.h" #include "general.h" #include "color.h" +#include #endif @@ -114,11 +115,7 @@ ValueNode_Linear::operator()(Time t)const case ValueBase::TYPE_COLOR: return (*m_)(t).get( Color())*t+(*b_)(t).get( Color()); case ValueBase::TYPE_INTEGER: - { - Real ret = (*m_)(t).get(int())*t+(*b_)(t).get(int()) + 0.5f; - if (ret < 0) return static_cast(ret-1); - return static_cast(ret); - } + return round_to_int((*m_)(t).get(int())*t+(*b_)(t).get(int())); case ValueBase::TYPE_REAL: return (*m_)(t).get( Real())*t+(*b_)(t).get( Real()); case ValueBase::TYPE_TIME: diff --git a/synfig-core/trunk/src/synfig/valuenode_scale.cpp b/synfig-core/trunk/src/synfig/valuenode_scale.cpp index b2f62b7..0ab0735 100644 --- a/synfig-core/trunk/src/synfig/valuenode_scale.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_scale.cpp @@ -39,6 +39,7 @@ #include "vector.h" #include "time.h" #include "angle.h" +#include #endif @@ -176,11 +177,7 @@ synfig::ValueNode_Scale::operator()(Time t)const return ret; } else if(get_type()==ValueBase::TYPE_INTEGER) - { - Real ret = (*value_node)(t).get(int())*(*scalar)(t).get(Real()) + 0.5f; - if (ret < 0) return static_cast(ret-1); - return static_cast(ret); - } + return round_to_int((*value_node)(t).get(int())*(*scalar)(t).get(Real())); else if(get_type()==ValueBase::TYPE_REAL) return (*value_node)(t).get(Real())*(*scalar)(t).get(Real()); else if(get_type()==ValueBase::TYPE_TIME) diff --git a/synfig-core/trunk/src/synfig/valuenode_subtract.cpp b/synfig-core/trunk/src/synfig/valuenode_subtract.cpp index 81fca92..27df6a0 100644 --- a/synfig-core/trunk/src/synfig/valuenode_subtract.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_subtract.cpp @@ -38,6 +38,7 @@ #include "vector.h" #include "angle.h" #include "real.h" +#include #endif @@ -173,11 +174,7 @@ synfig::ValueNode_Subtract::operator()(Time t)const case ValueBase::TYPE_COLOR: return ((*ref_a)(t).get(Color())-(*ref_b)(t).get(Color()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_INTEGER: - { - 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); - } + return round_to_int(((*ref_a)(t).get(int())-(*ref_b)(t).get(int()))*(*scalar)(t).get(Real())); case ValueBase::TYPE_REAL: return ((*ref_a)(t).get(Vector::value_type())-(*ref_b)(t).get(Vector::value_type()))*(*scalar)(t).get(Real()); case ValueBase::TYPE_TIME: diff --git a/synfig-core/trunk/src/synfig/valuenode_timedswap.cpp b/synfig-core/trunk/src/synfig/valuenode_timedswap.cpp index 20be99f..549feac 100644 --- a/synfig-core/trunk/src/synfig/valuenode_timedswap.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_timedswap.cpp @@ -35,6 +35,7 @@ #include "valuenode_const.h" #include #include "color.h" +#include #endif @@ -220,7 +221,7 @@ synfig::ValueNode_TimedSwap::operator()(Time t)const { float a=(float)(*after)(t).get(int()); float b=(float)(*before)(t).get(int()); - return static_cast((b-a)*amount+a+0.5f); + return round_to_int((b-a)*amount+a); } case ValueBase::TYPE_REAL: { -- 2.7.4