From 7f8808c9411c13af757a64575324517c17200cbb Mon Sep 17 00:00:00 2001 From: dooglus Date: Tue, 18 Sep 2007 19:44:05 +0000 Subject: [PATCH] Round integers towards zero in linear convert type. git-svn-id: http://svn.voria.com/code@712 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/valuenode_linear.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/synfig-core/trunk/src/synfig/valuenode_linear.cpp b/synfig-core/trunk/src/synfig/valuenode_linear.cpp index df82057..9c1788f 100644 --- a/synfig-core/trunk/src/synfig/valuenode_linear.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_linear.cpp @@ -86,6 +86,12 @@ ValueNode_Linear::ValueNode_Linear(const ValueBase &value): DCAST_HACK_ENABLE(); } +LinkableValueNode* +ValueNode_Linear::create_new()const +{ + return new ValueNode_Linear(get_type()); +} + ValueNode_Linear* ValueNode_Linear::create(const ValueBase &x) { @@ -107,7 +113,11 @@ ValueNode_Linear::operator()(Time t)const case ValueBase::TYPE_COLOR: return (*m_)(t).get( Color())*t+(*b_)(t).get( Color()); case ValueBase::TYPE_INTEGER: - return static_cast((*m_)(t).get(int())*t+(*b_)(t).get(int()) + 0.5f); + { + 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); + } case ValueBase::TYPE_REAL: return (*m_)(t).get( Real())*t+(*b_)(t).get( Real()); case ValueBase::TYPE_TIME: @@ -219,9 +229,3 @@ ValueNode_Linear::get_link_index_from_name(const String &name)const throw Exception::BadLinkName(name); } - -LinkableValueNode* -ValueNode_Linear::create_new()const -{ - return new ValueNode_Linear(get_type()); -} -- 2.7.4