for (iter=selected_ducks.begin(); iter!=selected_ducks.end(); ++iter)
{
etl::handle<Duck> duck(*iter);
- if ((duck->get_type() == Duck::TYPE_VERTEX || duck->get_type() == Duck::TYPE_POSITION) &&
- duck->get_value_desc().parent_is_value_node())
+ if (duck->get_type() == Duck::TYPE_VERTEX || duck->get_type() == Duck::TYPE_POSITION)
{
ValueNode_BLineCalcVertex::Handle bline_vertex(ValueNode_BLineCalcVertex::Handle::cast_dynamic(duck->get_value_desc().get_value_node()));
if (bline_vertex)
{
- ValueNode_Composite::Handle value_node_composite(ValueNode_Composite::Handle::cast_dynamic(duck->get_value_desc().get_parent_value_node()));
- if (value_node_composite &&
- value_node_composite->get_type() == ValueBase::TYPE_BLINEPOINT)
- {
- int t1_index(value_node_composite->get_link_index_from_name("t1"));
- int t2_index(value_node_composite->get_link_index_from_name("t2"));
- int width_index(value_node_composite->get_link_index_from_name("width"));
- int vertex_amount_index(bline_vertex->get_link_index_from_name("amount"));
-
- ValueNode::Handle t1_value_node(value_node_composite->get_link(t1_index));
- ValueNode::Handle t2_value_node(value_node_composite->get_link(t2_index));
- ValueNode::Handle width_value_node(value_node_composite->get_link(width_index));
- ValueNode::Handle amount_value_node(bline_vertex->get_link(vertex_amount_index));
+ synfig::Real radius = 0.0;
+ ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline"))));
+ Real amount = synfig::find_closest_point((*bline)(time), duck->get_point(), radius, bline->get_loop());
- ValueNode_BLineCalcTangent::Handle bline_tangent_1(ValueNode_BLineCalcTangent::Handle::cast_dynamic(t1_value_node));
- ValueNode_BLineCalcTangent::Handle bline_tangent_2(ValueNode_BLineCalcTangent::Handle::cast_dynamic(t2_value_node));
- ValueNode_BLineCalcWidth::Handle bline_width(ValueNode_BLineCalcWidth::Handle::cast_dynamic(width_value_node));
+ int vertex_amount_index(bline_vertex->get_link_index_from_name("amount"));
+ ValueNode::Handle vertex_amount_value_node(bline_vertex->get_link(vertex_amount_index));
- if (bline_tangent_1 || bline_tangent_2 || bline_width)
+ DuckList::iterator iter;
+ for (iter=duck_list.begin(); iter!=duck_list.end(); iter++)
+ {
+ ValueNode::Handle duck_value_node((*iter)->get_value_desc().get_value_node());
+ if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(duck_value_node))
{
- synfig::Real radius = 0.0;
- ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline"))));
- Real amount = synfig::find_closest_point((*bline)(time), duck->get_point(), radius, bline->get_loop());
-
- // we need to update the position of the tangent ducks - but how do we find these ducks?
- // this is a brute force search - but is there a better way to do it?
- if (bline_tangent_1 &&
- bline_tangent_1->get_link(bline_tangent_1->get_link_index_from_name("amount")) == amount_value_node)
- {
- Vector tangent = (*bline_tangent_1)(time, amount).get(Vector());
- DuckList::iterator iter;
- for (iter=duck_list.begin(); iter!=duck_list.end(); iter++)
- if ((*iter)->get_value_desc().get_value_node() == t1_value_node)
- (*iter)->set_point(tangent);
- }
-
- if (bline_tangent_2 &&
- bline_tangent_2->get_link(bline_tangent_2->get_link_index_from_name("amount")) == amount_value_node)
- {
- Vector tangent = (*bline_tangent_2)(time, amount).get(Vector());
- DuckList::iterator iter;
- for (iter=duck_list.begin(); iter!=duck_list.end(); iter++)
- if ((*iter)->get_value_desc().get_value_node() == t2_value_node)
- (*iter)->set_point(tangent);
- }
-
- if (bline_width &&
- bline_width->get_link(bline_width->get_link_index_from_name("amount")) == amount_value_node)
+ if (bline_tangent->get_link(bline_tangent->get_link_index_from_name("amount")) == vertex_amount_value_node)
{
- Real width = (*bline_width)(time, amount).get(Real());
- DuckList::iterator iter;
- for (iter=duck_list.begin(); iter!=duck_list.end(); iter++)
- if ((*iter)->get_value_desc().get_value_node() == width_value_node)
- (*iter)->set_point(Point(width, 0));
+ switch (bline_tangent->get_type())
+ {
+ case ValueBase::TYPE_ANGLE:
+ {
+ Angle angle((*bline_tangent)(time, amount).get(Angle()));
+ (*iter)->set_point(Point(Angle::cos(angle).get(), Angle::sin(angle).get()));
+ break;
+ }
+ case ValueBase::TYPE_REAL:
+ (*iter)->set_point(Point((*bline_tangent)(time, amount).get(Real()), 0));
+ break;
+ case ValueBase::TYPE_VECTOR:
+ (*iter)->set_point((*bline_tangent)(time, amount).get(Vector()));
+ break;
+ }
}
}
+ else if (ValueNode_BLineCalcWidth::Handle bline_width = ValueNode_BLineCalcWidth::Handle::cast_dynamic(duck_value_node))
+ {
+ if (bline_width->get_link(bline_width->get_link_index_from_name("amount")) == vertex_amount_value_node)
+ (*iter)->set_point(Point((*bline_width)(time, amount).get(Real()), 0));
+ }
}
}
}