Author: Carlos Lopez <[email protected]>
Date: Thu Oct 20 19:30:22 2011 +0200
Fix ValueDescSet action to consider width points with no standard boundaries
---
.../src/synfigapp/actions/valuedescset.cpp | 57 ++++++++++++-------
1 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/synfig-studio/src/synfigapp/actions/valuedescset.cpp
b/synfig-studio/src/synfigapp/actions/valuedescset.cpp
index 6a5aa8e..9cda937 100644
--- a/synfig-studio/src/synfigapp/actions/valuedescset.cpp
+++ b/synfig-studio/src/synfigapp/actions/valuedescset.cpp
@@ -538,29 +538,14 @@ Action::ValueDescSet::prepare()
ValueNode_WPList::Handle
wplist=ValueNode_WPList::Handle::cast_dynamic(value_desc.get_parent_value_node());
if(wplist)
{
+ bool wplistloop(wplist->get_loop());
ValueNode_BLine::Handle
bline(ValueNode_BLine::Handle::cast_dynamic(wplist->get_bline()));
ValueNode_Composite::Handle
wpoint_composite(ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()));
- if(wpoint_composite)
+ if(bline && wpoint_composite)
{
- Real radius = 0.0;
- ValueBase new_amount;
- if (wplist->get_loop())
- {
- // The wplist is looped.
Animation may require a position parameter
- // outside the range of 0-1, so
make sure that the position doesn't
- // change drastically.
- Real
amount_old((*(wpoint_composite->get_link("position")))(time).get(Real()));
- Real amount_new =
synfig::find_closest_point((*bline)(time), value, radius, bline->get_loop());
- Real difference = fmod(
fmod(amount_new - amount_old, 1.0) + 1.0 , 1.0);
- //fmod is called twice to avoid
negative values
- if (difference > 0.5)
-
difference=difference-1.0;
- new_amount =
amount_old+difference;
- }
- else
- new_amount =
synfig::find_closest_point((*bline)(time), value, radius, bline->get_loop());
- bool homogeneous=false;
+ bool blineloop(bline->get_loop());
// Retrieve the homogeneous layer
parameter
+ bool homogeneous=false;
Layer::Handle layer_parent;
std::set<Node*>::iterator iter;
for(iter=wplist->parent_set.begin();iter!=wplist->parent_set.end();++iter)
@@ -573,9 +558,39 @@ Action::ValueDescSet::prepare()
break;
}
}
- if(homogeneous)
+ Real radius = 0.0;
+ ValueBase new_amount;
+ WidthPoint
wp((*wpoint_composite)(time));
+ if (wplistloop)
+ {
+ // The wplist is looped.
Animation may require a position parameter
+ // outside the range of 0-1, so
make sure that the position doesn't
+ // change drastically.
+ Real
amount_old(wp.get_norm_position(wplistloop));
+ // If it is homogeneous then
convert it to standard
+
amount_old=homogeneous?hom_to_std((*bline)(time), amount_old, wplistloop,
blineloop):amount_old;
+ // grab a new position given by
duck's position on the bline
+ Real amount_new =
synfig::find_closest_point((*bline)(time), value, radius, blineloop);
+ // calculate the difference
between old and new amounts
+ Real difference = fmod(
fmod(amount_new - amount_old, 1.0) + 1.0 , 1.0);
+ //fmod is called twice to avoid
negative values
+ if (difference > 0.5)
+
difference=difference-1.0;
+ // calculate a new value for
the position
+
new_amount=amount_old+difference;
+ // restore the homogeneous
value if needed
+ new_amount =
homogeneous?ValueBase(std_to_hom((*bline)(time), new_amount, wplistloop,
blineloop)):new_amount;
+ // convert the new_value in
terms of current boundaries
+ new_amount =
wp.get_lower_bound()+new_amount*(wp.get_upper_bound()-wp.get_lower_bound());
+ }
+ else
{
-
new_amount=std_to_hom((*bline)(time), new_amount, wplist->get_loop(),
bline->get_loop() );
+ // grab a new amount given by
duck's position on the bline
+ new_amount =
synfig::find_closest_point((*bline)(time), value , radius, blineloop);
+ // if it is homogeneous then
convert to it
+
new_amount=homogeneous?ValueBase(std_to_hom((*bline)(time), new_amount,
wplistloop, blineloop)):new_amount;
+ // convert the value inside the
boundaries
+ new_amount =
wp.get_lower_bound()+new_amount*(wp.get_upper_bound()-wp.get_lower_bound());
}
Action::Handle
action(Action::create("ValueDescSet"));
if(!action)
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl