void Duck::set_sub_trans_point(const synfig::Point &x, const synfig::Time &time) { set_sub_trans_point(x); if(get_type() == Duck::TYPE_VERTEX || get_type() == Duck::TYPE_POSITION || get_type() == Duck::TYPE_WIDTHPOINT_POSITION) { ValueNode_BLineCalcVertex::Handle bline_vertex; ValueNode_Composite::Handle composite; if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(get_value_desc().get_value_node())) || ((composite = ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node())) && composite->get_type() == ValueBase::TYPE_BLINEPOINT && (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point"))))) { synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link("bline")); synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } ValueNode_Composite::Handle wpoint_composite; ValueNode_WPList::Handle wplist; wpoint_composite=ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node()); if(wpoint_composite && wpoint_composite->get_type() == ValueBase::TYPE_WIDTHPOINT) if(get_value_desc().parent_is_value_node()) { wplist=ValueNode_WPList::Handle::cast_dynamic(get_value_desc().get_parent_value_node()); if(wplist) { ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(wplist->get_bline())); synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } } } }
void Duck::set_sub_trans_point(const synfig::Point &x, const synfig::Time &time) { if (get_type() == Duck::TYPE_TANGENT || get_type() == Duck::TYPE_ANGLE) { Angle old_angle = get_point().angle(); set_point((x-get_sub_trans_origin())/get_scalar()); Angle change = get_point().angle() - old_angle; while (change < Angle::deg(-180)) change += Angle::deg(360); while (change > Angle::deg(180)) change -= Angle::deg(360); //int old_halves = round_to_int(Angle::deg(rotations).get()/180); rotations += change; //int new_halves = round_to_int(Angle::deg(rotations).get()/180); /*if (old_halves != new_halves && (new_halves > 1 || new_halves < -1 || old_halves > 1 || old_halves < -1)) synfig::info("rotation: %.2f turns", new_halves/2.0)*/; } else if(get_type() == Duck::TYPE_VERTEX || get_type() == Duck::TYPE_POSITION || get_type() == Duck::TYPE_WIDTHPOINT_POSITION) { set_point((x-get_sub_trans_origin())/get_scalar()); ValueNode_BLineCalcVertex::Handle bline_vertex; ValueNode_Composite::Handle composite; if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(get_value_desc().get_value_node())) || ((composite = ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node())) && composite->get_type() == ValueBase::TYPE_BLINEPOINT && (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point"))))) { synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link("bline")); synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } ValueNode_Composite::Handle wpoint_composite; ValueNode_WPList::Handle wplist; wpoint_composite=ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node()); if(wpoint_composite && wpoint_composite->get_type() == ValueBase::TYPE_WIDTHPOINT) if(get_value_desc().parent_is_value_node()) { wplist=ValueNode_WPList::Handle::cast_dynamic(get_value_desc().get_parent_value_node()); if(wplist) { ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(wplist->get_bline())); synfig::Point closest_point = get_point(); synfig::Real radius = 0.0; synfig::find_closest_point( (*bline)(time), get_point(), radius, bline->get_loop(), &closest_point); set_point(closest_point); } } } else set_point((x-get_sub_trans_origin())/get_scalar()); }