Skip to content

[Synfig Studio] fix action LayerDuplicate for skeleton and its bone links! - #2059

Merged
ice0 merged 3 commits into
synfig:masterfrom
rodolforg:studio-fix-skeleton-duplicate
Mar 11, 2021
Merged

ice0 merged 3 commits into
synfig:masterfrom
rodolforg:studio-fix-skeleton-duplicate

Conversation

@rodolforg

@rodolforg rodolforg commented Mar 7, 2021 •

Copy link
Copy Markdown
Contributor

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.

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
@rodolforg

Copy link
Copy Markdown
Contributor Author

It's a draft 'only' because I didn't create/commit correspondent tests yet.

@rodolforg

rodolforg commented Mar 8, 2021 •

Copy link
Copy Markdown
Contributor Author

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 type_bone_valuenode , but type_bone_object.
I don't know what I did wrong.

	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

@rodolforg

rodolforg commented Mar 8, 2021 •

Copy link
Copy Markdown
Contributor Author

Ok. I had to wrap it into a ValueNode_Const…

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);

@rodolforg

Copy link
Copy Markdown
Contributor Author

I'm struggling to make a test more than I suffered to make the fix – that actually works! lol

@rodolforg rodolforg added this to the v1.4.1 milestone Mar 9, 2021
@rodolforg
rodolforg marked this pull request as ready for review March 9, 2021 07:31
@rodolforg
rodolforg requested a review from morevnaproject March 9, 2021 07:31
@rodolforg

Copy link
Copy Markdown
Contributor Author

If this PR is OK, please backport it to 1.4.x branch.
Next, and maybe last, PR with layer-duplicate action is about reuse it for copy-and-paste actions. It'll reduce code redundancy and maintenance: fixes done in LayerDuplicate action will be reflected in layer Paste!

Maybe then a lot of skeleton problems will be solved :D \o/

@rodolforg
rodolforg requested a review from ice0 March 9, 2021 08:32
@ice0
ice0 merged commit ab8cd14 into synfig:master Mar 11, 2021
@ice0

ice0 commented Mar 11, 2021

Copy link
Copy Markdown
Collaborator

Merged. Thank you!

@rodolforg rodolforg mentioned this pull request Apr 16, 2021
rodolforg added a commit to rodolforg/synfig that referenced this pull request Apr 17, 2021
rodolforg added a commit to rodolforg/synfig that referenced this pull request Apr 21, 2021
rodolforg added a commit to rodolforg/synfig that referenced this pull request Apr 26, 2021
@ice0 ice0 added the Bug label May 5, 2021
@rodolforg rodolforg modified the milestones: v1.4.1, v1.4.2 May 12, 2021
rodolforg added a commit to rodolforg/synfig that referenced this pull request May 15, 2021
rodolforg added a commit to rodolforg/synfig that referenced this pull request May 26, 2021
rodolforg added a commit to rodolforg/synfig that referenced this pull request May 27, 2021
morevnaproject pushed a commit to morevnaproject/synfig that referenced this pull request Aug 9, 2021
morevnaproject pushed a commit to morevnaproject/synfig that referenced this pull request Aug 9, 2021
@rodolforg
rodolforg deleted the studio-fix-skeleton-duplicate branch October 26, 2021 00:18
@rodolforg rodolforg added Bones and removed Backport labels Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants