X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftags%2Fstable%2Fsrc%2Fsynfig%2Fvaluenode_animated.cpp;h=c2a32fccae628cc9dfa9dcc332438d211bb694a5;hb=47fce282611fbba1044921d22ca887f9b53ad91a;hp=aabf805db4f1fc681706004d93d85dc9a80d2676;hpb=d3408370fc3297609b3aa8d4ff7edf1f238df251;p=synfig.git diff --git a/synfig-core/tags/stable/src/synfig/valuenode_animated.cpp b/synfig-core/tags/stable/src/synfig/valuenode_animated.cpp index aabf805..c2a32fc 100644 --- a/synfig-core/tags/stable/src/synfig/valuenode_animated.cpp +++ b/synfig-core/tags/stable/src/synfig/valuenode_animated.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ /*! \file valuenode_animated.cpp -** \brief Template File +** \brief Implementation of the "Animated" valuenode conversion. ** ** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** 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 @@ -160,6 +161,7 @@ struct is_angle_type } }; +#ifdef ANGLES_USE_LINEAR_INTERPOLATION template <> struct is_angle_type { @@ -168,6 +170,7 @@ struct is_angle_type return true; } }; +#endif // ANGLES_USE_LINEAR_INTERPOLATION /* === G L O B A L S ======================================================= */ @@ -234,7 +237,7 @@ private: Time r,s; public: - ValueNode* clone(const GUID& deriv_guid)const + ValueNode* clone(const synfig::GUID& deriv_guid)const { { ValueNode* x(find_value_node(get_guid()^deriv_guid).get()); if(x)return x; } _Hermite* ret(new _Hermite()); @@ -374,34 +377,36 @@ public: } else { + const Real& t(iter->get_tension()); // Tension + const Real& c(iter->get_continuity()); // Continuity + const Real& b(iter->get_bias()); // Bias - const Real& t(iter->get_tension()); // Tension - const Real& c(iter->get_continuity()); // Continuity - const Real& b(iter->get_bias()); // Bias + // The following line works where the previous line fails. + value_type Pp; Pp=curve_list.back().second.p1(); // P_{i-1} - // The folloing line works where the previous line fails. - value_type Pp; Pp=curve_list.back().second.p1(); // P_{i-1} + const value_type& Pc(curve.second.p1()); // P_i + const value_type& Pn(curve.second.p2()); // P_{i+1} - const value_type& Pc(curve.second.p1()); // P_i - const value_type& Pn(curve.second.p2()); // P_{i+1} + // TCB + value_type vect(static_cast + (subtract_func(Pc,Pp) * + (((1.0-t) * (1.0+c) * (1.0+b)) / 2.0) + + (Pn-Pc) * (((1.0-t) * (1.0-c) * (1.0-b)) / 2.0))); - // TCB - value_type vect(static_cast(subtract_func(Pc,Pp)*(((1.0-t)*(1.0+c)*(1.0+b))/2.0)+(Pn-Pc)*(((1.0-t)*(1.0-c)*(1.0-b))/2.0))); - - // Tension Only - //value_type vect=(value_type)((Pn-Pp)*(1.0-t)); + // Tension Only + //value_type vect=(value_type)((Pn-Pp)*(1.0-t)); - // Linear - //value_type vect=(value_type)(Pn-Pc); + // Linear + //value_type vect=(value_type)(Pn-Pc); - // Debugging stuff - //synfig::info("%d:t1: %s",i,tangent_info(Pp,Pn,vect).c_str()); + // Debugging stuff + //synfig::info("%d:t1: %s",i,tangent_info(Pp,Pn,vect).c_str()); - // Adjust for time - //vect=value_type(vect*(curve.second.get_dt()*2.0)/(curve.second.get_dt()+curve_list.back().second.get_dt())); - //vect=value_type(vect*(curve.second.get_dt())/(curve_list.back().second.get_dt())); + // Adjust for time + //vect=value_type(vect*(curve.second.get_dt()*2.0)/(curve.second.get_dt()+curve_list.back().second.get_dt())); + //vect=value_type(vect*(curve.second.get_dt())/(curve_list.back().second.get_dt())); - curve.second.t1()=vect; + curve.second.t1()=vect; } } else if( @@ -428,7 +433,8 @@ public: value_type Pn; Pn=after_next->get_value().get(T()); // P_{i+1} // TCB - value_type vect(static_cast(subtract_func(Pc,Pp)*(((1.0-t)*(1.0-c)*(1.0+b))/2.0)+(Pn-Pc)*(((1.0-t)*(1.0+c)*(1.0-b))/2.0))); + value_type vect(static_cast(subtract_func(Pc,Pp) * (((1.0-t)*(1.0-c)*(1.0+b))/2.0) + + (Pn-Pc) * (((1.0-t)*(1.0+c)*(1.0-b))/2.0))); // Tension Only //value_type vect((value_type)((Pn-Pp)*(1.0-t))); @@ -455,25 +461,38 @@ public: // Adjust for time const float timeadjust(0.5); - if(!curve_list.empty()) - curve.second.t1()*=(curve.second.get_dt()*(timeadjust+1))/(curve.second.get_dt()*timeadjust+curve_list.back().second.get_dt()); - if(after_next!=waypoint_list_.end()) - curve.second.t2()*=(curve.second.get_dt()*(timeadjust+1))/(curve.second.get_dt()*timeadjust+(after_next->get_time()-next->get_time())); - if(iter_get_after==INTERPOLATION_HALT) curve.second.t1()*=0; + // if this isn't the first curve + else if(iter_get_after != INTERPOLATION_LINEAR && !curve_list.empty()) + // adjust it for the curve that came before it + curve.second.t1() = static_cast(curve.second.t1() * // cast to prevent warning + // (time span of this curve) * 1.5 + // ----------------------------------------------------------------- + // ((time span of this curve) * 0.5) + (time span of previous curve) + (curve.second.get_dt()*(timeadjust+1)) / + (curve.second.get_dt()*timeadjust + curve_list.back().second.get_dt())); if(next_get_before==INTERPOLATION_HALT) curve.second.t2()*=0; - } + // if this isn't the last curve + else if(next_get_before != INTERPOLATION_LINEAR && after_next!=waypoint_list_.end()) + // adjust it for the curve that came after it + curve.second.t2() = static_cast(curve.second.t2() * // cast to prevent warning + // (time span of this curve) * 1.5 + // ------------------------------------------------------------- + // ((time span of this curve) * 0.5) + (time span of next curve) + (curve.second.get_dt()*(timeadjust+1)) / + (curve.second.get_dt()*timeadjust+(after_next->get_time()-next->get_time()))); + } // not CONSTANT } // Set up the time to the default stuff curve.first.set_rs(iter->get_time(), next->get_time()); curve.first.p1()=iter->get_time(); curve.first.p2()=next->get_time(); - curve.first.t1()=(curve.first.p2()-curve.first.p1())*(1.0f-iter->get_time_tension()); - curve.first.t2()=(curve.first.p2()-curve.first.p1())*(1.0f-next->get_time_tension()); + curve.first.t1()=(curve.first.p2()-curve.first.p1())*(1.0f-iter->get_temporal_tension()); + curve.first.t2()=(curve.first.p2()-curve.first.p1())*(1.0f-next->get_temporal_tension()); curve.first.sync(); @@ -519,7 +538,7 @@ private: Time r,s; public: - ValueNode* clone(const GUID& deriv_guid)const + ValueNode* clone(const synfig::GUID& deriv_guid)const { { ValueNode* x(find_value_node(get_guid()^deriv_guid).get()); if(x)return x; } _Constant* ret(new _Constant()); @@ -617,7 +636,7 @@ private: Time r,s; public: - ValueNode* clone(const GUID& deriv_guid)const + ValueNode* clone(const synfig::GUID& deriv_guid)const { { ValueNode* x(find_value_node(get_guid()^deriv_guid).get()); if(x)return x; } _AnimBool* ret(new _AnimBool()); @@ -1027,7 +1046,7 @@ synfig::ValueNode_Animated::create(ValueBase::Type type) case ValueBase::TYPE_STRING: return ValueNode_Animated::Handle(new _Constant); case ValueBase::TYPE_GRADIENT: - return ValueNode_Animated::Handle(new _Constant); + return ValueNode_Animated::Handle(new _Hermite); case ValueBase::TYPE_BOOL: return ValueNode_Animated::Handle(new _AnimBool); case ValueBase::TYPE_CANVAS: @@ -1035,7 +1054,7 @@ synfig::ValueNode_Animated::create(ValueBase::Type type) default: throw Exception::BadType(strprintf(_("%s: You cannot use a %s in an animated ValueNode"),"synfig::ValueNode_Animated::create()", - ValueBase::type_name(type).c_str()) + ValueBase::type_local_name(type).c_str()) ); break; }