Skip to content

Commit

Permalink
Fix broken bone selection for Skeleton Deformation Layer (#2365)
Browse files Browse the repository at this point in the history
Broken due to PR #2325
  • Loading branch information
rodolforg committed Oct 18, 2021
1 parent 19a88f4 commit 188126e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions synfig-studio/src/gui/states/state_bone.cpp
Expand Up @@ -652,8 +652,8 @@ StateBone_Context::event_mouse_release_handler(const Smach::event& x)
if(b){ // if bone found around the release point, then set it as active bone
ValueNode::Handle bone_value_node = b;
if (deform_layer) {
ValueNode_Composite::Handle comp = ValueNode_Composite::Handle::cast_dynamic(b);
bone_value_node = comp->get_link("first");
if (ValueNode_Composite::Handle comp = ValueNode_Composite::Handle::cast_dynamic(b))
bone_value_node = comp->get_link("first");
}
set_active_bone(bone_value_node);
}
Expand All @@ -665,15 +665,16 @@ StateBone_Context::event_mouse_release_handler(const Smach::event& x)
if(active_bone && item_index >= 0 && !list_node->list.empty()){ // if active bone is already set
ValueNode_Bone::Handle bone_node = ValueNode_Bone::Handle::cast_dynamic(active_bone);
if (deform_layer) {
ValueNode_Composite::Handle comp = ValueNode_Composite::Handle::cast_dynamic(active_bone);
if (!comp)
{
if (ValueNode_Composite::Handle comp = ValueNode_Composite::Handle::cast_dynamic(active_bone)) {
value_desc = ValueDesc(comp,comp->get_link_index_from_name("first"),value_desc);
bone_node = ValueNode_Bone::Handle::cast_dynamic(comp->get_link("first"));
} else if ((comp = ValueNode_Composite::Handle::cast_dynamic(list_node->get_link(item_index)))) {
value_desc = ValueDesc(comp, comp->get_link_index_from_name("first"),value_desc);
} else {
get_canvas_interface()->get_ui_interface()->error(_("Expected a ValueNode_Composite with a BonePair"));
assert(0);
return Smach::RESULT_ERROR;
}
value_desc = ValueDesc(comp,comp->get_link_index_from_name("first"),value_desc);
bone_node = ValueNode_Bone::Handle::cast_dynamic(comp->get_link("first"));
}

if (!bone_node)
Expand Down Expand Up @@ -959,7 +960,10 @@ StateBone_Context::find_bone(Point point,Layer::Handle layer) const
if (ret >=0 && ret < bone_list.size()) {
ValueNode_StaticList::Handle list_node;
list_node=ValueNode_StaticList::Handle::cast_dynamic(list_desc.get_value_node());
return ValueNode_Bone::Handle::cast_dynamic(list_node->get_link(ret));
if (is_skeleton_deform_layer)
return ValueNode_Bone::Handle::cast_dynamic(ValueNode_Composite::Handle::cast_dynamic(list_node->get_link(ret))->get_link("first"));
else
return ValueNode_Bone::Handle::cast_dynamic(list_node->get_link(ret));
}
}

Expand Down

0 comments on commit 188126e

Please sign in to comment.