Repository navigation
[Synfig Studio] fix action LayerDuplicate for skeleton and its bone links! - #2059
Conversation
reasons: 1. etl will be moved to synfig 2. maybe C++ standard provide this feature in future?
Now Bone Links are properly fixed when duplicating a skeleton layer AND layers linked to its bones Note, however, that duplicating a skeleton doesn't duplicate the layers linked to its bone by itself: those layers should be included in 'layers' parameter of this action
|
It's a draft 'only' because I didn't create/commit correspondent tests yet. |
|
OK, I can't create a test, because I can't create a ValueNode_BoneLink :( When I try to set a bone, it complains that my ValueNode_Bone is not of type synfig::Canvas::Handle canvas = synfig::Canvas::create();
canvas->set_id("MyCanvas");
auto instance = synfigapp::Instance::create(canvas, nullptr);
std::vector<synfig::Bone> bones(1);
bones[0] = synfig::Bone(synfig::Point(0,0), synfig::Point(0.5,0.5));
bones[0].set_parent(synfig::ValueNode_Bone_Root::create(synfig::Bone()));
bones[0].set_name("my bone 0");
auto layer = synfig::Layer::create("skeleton");
synfig::ValueBase param_bones;
param_bones.set_list_of(bones);
layer->set_param("bones", param_bones);
canvas->push_back(layer);
synfig::ValueNode_Bone::Handle bone0_vn = synfig::ValueNode_Bone::create(bones[0], canvas);
ASSERT(bone0_vn)
bones[1].set_parent(bone0_vn.get());
auto circle = synfig::Layer::create("circle");
synfig::LinkableValueNode::Handle bone_link = synfig::ValueNode_BoneLink::create(synfig::Vector(3,5));
bone_link->set_link("bone", bone0_vn);
/// PRINT ERROR: synfig-core/src/synfig/valuenodes/valuenode_bonelink.cpp:98 wrong type for Bone: need bone_valuenode but got bone_object |
|
Ok. I had to wrap it into a auto circle = synfig::Layer::create("circle");
synfig::LinkableValueNode::Handle bone_link = synfig::ValueNode_BoneLink::create(synfig::Vector(3,5));
bone_link->set_link("bone", synfig::ValueNode_Const::create(bone0_vn));
circle->connect_dynamic_param("origin", bone_link.get());
canvas->push_back(circle); |
|
I'm struggling to make a test more than I suffered to make the fix – that actually works! lol |
|
If this PR is OK, please backport it to 1.4.x branch. Maybe then a lot of skeleton problems will be solved :D \o/ |
|
Merged. Thank you! |
Now Bone Links are properly fixed when duplicating a skeleton
layer AND layers linked to its bones
Note, however, that duplicating a skeleton doesn't duplicate
the layers linked to its bone by itself: those layers should
be included in 'layers' parameter of this action
It still doesn't work on copy and paste, but with Duplicate action.