Author: Carlos Lopez <[email protected]>
Date: Sun Aug 28 10:18:50 2011 +0200
When doing waypoint interpolation for a linked to bline real value, do the
calculations at the homogeneous space. This allow constant speed along the
bline between linear waypoints for bline linked real values.
---
synfig-core/src/synfig/valuenode_animated.cpp | 77 +++++++++++++++++++-----
synfig-core/src/synfig/valuenode_animated.h | 1 +
2 files changed, 62 insertions(+), 16 deletions(-)
diff --git a/synfig-core/src/synfig/valuenode_animated.cpp
b/synfig-core/src/synfig/valuenode_animated.cpp
index e8fb7a6..6562698 100644
--- a/synfig-core/src/synfig/valuenode_animated.cpp
+++ b/synfig-core/src/synfig/valuenode_animated.cpp
@@ -49,6 +49,7 @@
#include "general.h"
#include "valuenode_animated.h"
#include "valuenode_const.h"
+#include "valuenode_bline.h"
#include "exception.h"
#include "gradient.h"
@@ -297,7 +298,28 @@ public:
WaypointList::iterator prev,iter,next=waypoint_list_.begin();
int i=0;
-
+ // Copy the waypoints to preserve them and restore later
+ waypoint_list_copy_.assign(waypoint_list_.begin(),
waypoint_list_.end());
+ // If the type is Real
+ if(get_type() == ValueBase::TYPE_REAL)
+ {
+ // If it is bline linked...
+ ValueNode_BLine::Handle
bline(ValueNode_BLine::Handle::cast_dynamic(get_bline()));
+ if(bline)
+ {
+ // ...change the Waypoints to be in the
homogeneous space.
+
for(iter=waypoint_list_.begin();iter!=waypoint_list_.end();iter++)
+ {
+ // Do it only for static waypoints, I
don't know what to do with non static
+ if(iter->is_static())
+ {
+ synfig::Real
value(iter->get_value());
+ value=std_to_hom(
(*bline)(iter->get_time()).get_list(), value, bline->get_loop());
+ iter->set_value(value);
+ }
+ }
+ }
+ }
for(iter=next++;iter!=waypoint_list_.end() &&
next!=waypoint_list_.end();prev=iter,iter=next++,i++)
{
typename curve_list_type::value_type curve;
@@ -479,28 +501,51 @@ public:
curve_list.push_back(curve);
}
+ // Restore the waypoints in any case
+ waypoint_list_.assign(waypoint_list_copy_.begin(),
waypoint_list_copy_.end());
}
virtual ValueBase operator()(Time t)const
{
+ bool resolve(false);
+ value_type ret;
if(waypoint_list_.empty())
return value_type(); //! \todo Perhaps we should
throw something here?
if(waypoint_list_.size()==1)
- return waypoint_list_.front().get_value(t);
- if(t<=r)
- return waypoint_list_.front().get_value(t);
- if(t>=s)
- return waypoint_list_.back().get_value(t);
-
- typename curve_list_type::const_iterator iter;
+
ret=waypoint_list_.front().get_value(t).get(value_type());
+ else if(t<=r)
+
ret=waypoint_list_.front().get_value(t).get(value_type());
+ else if(t>=s)
+
ret=waypoint_list_.back().get_value(t).get(value_type());
+ else
+ {
+ typename curve_list_type::const_iterator iter;
+ // This next line will set iter to the
+ // correct iterator for the given time.
+ for(iter=curve_list.begin();iter<curve_list.end() &&
t>=iter->first.get_s();++iter)
+ continue;
+ if(iter==curve_list.end())
+
ret=waypoint_list_.back().get_value(t).get(value_type());
+ else
+ {
+ resolve=true;
+ ret=iter->resolve(t);
+ }
+ }
+ if(get_type() == ValueBase::TYPE_REAL && resolve)
+ {
+ Real value(ValueBase(ret).get(Real()));
+ // If it is bline linked...
+ ValueNode_BLine::Handle
bline(ValueNode_BLine::Handle::cast_dynamic(get_bline()));
+ if(bline)
+ {
+ // ...change the Waypoints to be in the
homogeneous space.
+ value=hom_to_std( (*bline)(t).get_list(),
value, bline->get_loop());
+ return value;
+ }
- // This next line will set iter to the
- // correct iterator for the given time.
- for(iter=curve_list.begin();iter<curve_list.end() &&
t>=iter->first.get_s();++iter)
- continue;
- if(iter==curve_list.end())
- return waypoint_list_.back().get_value(t);
- return iter->resolve(t);
+ }
+ return ret;
}
};
diff --git a/synfig-core/src/synfig/valuenode_animated.h
b/synfig-core/src/synfig/valuenode_animated.h
index 093236a..079e7a3 100644
--- a/synfig-core/src/synfig/valuenode_animated.h
+++ b/synfig-core/src/synfig/valuenode_animated.h
@@ -65,6 +65,7 @@ public:
protected:
//! List of Waypoints. \see waypoint.h
WaypointList waypoint_list_;
+ WaypointList waypoint_list_copy_;
public:
WaypointList &waypoint_list() { return waypoint_list_; }
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl