From: Nikita Kitaev Date: Wed, 25 Nov 2009 20:30:36 +0000 (-0800) Subject: Change Link to BLine Reverse Manipulation X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2a78e732ada65bd595dba2f6f93574f3fc59e8fa;p=synfig.git Change Link to BLine Reverse Manipulation It now sets the "amount" parameter for looped links to be as close as possible to the old one, rather than lie in the range 0...1. --- diff --git a/synfig-studio/src/gtkmm/canvasview.cpp b/synfig-studio/src/gtkmm/canvasview.cpp index 5afa535..594ad39 100644 --- a/synfig-studio/src/gtkmm/canvasview.cpp +++ b/synfig-studio/src/gtkmm/canvasview.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -2884,8 +2885,18 @@ CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDes { ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline"))); Real radius = 0.0; - Real amount = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop()); - return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount); + if (((*(bline_vertex->get_link("loop")))(get_time()).get(bool()))){ + Real amount_old((*(bline_vertex->get_link("amount")))(get_time()).get(Real())); + Real amount_new = synfig::find_closest_point((*bline)(get_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; + return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount_old+difference); + + } else { + Real amount = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop()); + return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount); + } } if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node()))