Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import hints breaking node paths in animations #43044

Merged

Conversation

rburing
Copy link
Member

@rburing rburing commented Oct 23, 2020

Keep track of renamed nodes (which are processed first) so that in the animations (which are processed last) the paths can be fixed.

Fixes #38809. Importing the minimal example there now gives the following verbose output:

Fix: Renamed Marker-col to Marker
Fix: Correcting node path in animation track: Marker-col should be Marker

Small bonus: fixes the unreported bug that the convcolonly hint was not removed in case of an empty object with a draw type.

Bugsquad Edit:

@Calinou Calinou added bug cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:import labels Oct 24, 2020
@Calinou Calinou added this to the 4.0 milestone Oct 24, 2020
@rburing rburing force-pushed the fix_import_hints_breaking_animations branch from 713ae75 to e82b8d1 Compare October 24, 2020 12:49
@akien-mga akien-mga requested review from reduz and fire October 28, 2020 09:04
@fire
Copy link
Member

fire commented Oct 28, 2020

Slow to get to this, putting it on my todo list.

@fire
Copy link
Member

fire commented Nov 17, 2020

https://github.com/godotengine/godot-tests/tree/master/tests/blend_export/blend

Can you make a test case pr with the new tests?

Edited: reviewing

@rburing
Copy link
Member Author

rburing commented Nov 17, 2020

To clarify the (small) scope of this PR, let me note that the code that deals with empties is barely touched here (only fixing one renaming oversight). There remains a separate issue with them, namely importing them as custom collision shapes (based on the draw type) only works with files exported from Blender using ol' Better Collada: godotengine/godot-docs#4374

@fire
Copy link
Member

fire commented Nov 17, 2020

I added 43044-marker.blend to https://github.com/godotengine/godot-tests/tree/master/tests/blend_export .

Currently building the engine to test that it breaks in 4.0 standard and works in your pr.

Edited link.

@fire
Copy link
Member

fire commented Nov 17, 2020

I couldn't see a difference, maybe I'm misunderstanding how this works. Notice I have a mesh called marker next to marker-col.

This PR.
image

Master.

image

@rburing
Copy link
Member Author

rburing commented Nov 17, 2020

The original marker.blend file in #38809 contains only Marker-col; the 43044-marker.blend test file contains a second Marker in addition to Marker-col. This reveals the following (hidden?) functionality:

if (mi->get_parent() && !mi->get_parent()->has_node(fixed_name)) {
mi->set_name(fixed_name);

Namely, the -col suffix is not removed if it clashes with an existing name. In that case there is no need to fix animations, so the animations from the 43044-marker.blend work even on master without modifications (and in my PR, the new code is simply not triggered, and so it also works). When there is no clash with an existing name (as will be the common case, and as it was in #38809), there will be a rename that removes the -col suffix, and the code in my PR will be triggered, fixing the animations.

So, 43044-marker.blend currently does not test the code in this PR (the original marker.blend does).

@fire
Copy link
Member

fire commented Nov 17, 2020

I wonder why Marker-col and not Marker2? That seems odd.

@rburing
Copy link
Member Author

rburing commented Nov 17, 2020

The quoted if statement completely prevents the rename (in case that there would be a clash), so in that sense it is normal.

If Marker2 is preferred then the logic should be changed.

@rburing rburing changed the title Fix import hints breaking animations Fix import hints breaking node paths in animations Nov 17, 2020
@reduz
Copy link
Member

reduz commented Nov 27, 2020

I will be reworking this code in the coming weeks, can probably use it as a reference but suggest review for 3.2

@fire
Copy link
Member

fire commented Jun 8, 2021

What is the current state of this? Need some help to retest master.

@reduz
Copy link
Member

reduz commented Jan 6, 2022

This looks good, but likely needs a rebase. Any volunteers?

@rburing
Copy link
Member Author

rburing commented Jan 6, 2022

Thanks for the feedback. I'll rebase today.

@rburing rburing force-pushed the fix_import_hints_breaking_animations branch from e82b8d1 to 80c2dbd Compare January 6, 2022 15:37
@rburing rburing requested a review from a team as a code owner January 6, 2022 15:37
@rburing rburing force-pushed the fix_import_hints_breaking_animations branch 2 times, most recently from 67a8022 to 75b5cb8 Compare January 6, 2022 16:30
@rburing
Copy link
Member Author

rburing commented Jan 6, 2022

Rebased it is.

@rburing rburing force-pushed the fix_import_hints_breaking_animations branch from 75b5cb8 to 88bf673 Compare January 7, 2022 18:31
@rburing
Copy link
Member Author

rburing commented Jan 7, 2022

Originally this PR was doing the renaming work in the same loop as the one where tracks are being removed if they reference nodes with a noimp (no import) hint. That original version would have introduced a bug if an animation would have a track referencing a node with a noimp hint and a track referencing a node with an import hint that would trigger a rename. In the latest version the removing and renaming are done in two separate loops (first removing, then renaming), for simplicity and safety.

@rburing rburing force-pushed the fix_import_hints_breaking_animations branch from 88bf673 to 1cdad6c Compare January 18, 2022 11:20
@rburing
Copy link
Member Author

rburing commented Jan 18, 2022

I added a local variable bool nodes_were_renamed = r_node_renames.size() != 0, so that we try to fix node paths (which involves iterating over all tracks of all animations) only when nodes_were_renamed.

If the original PR looked good and the (small) improvements are agreeable, then does it mean a positive review? :)

@akien-mga akien-mga merged commit ca93518 into godotengine:master Jan 18, 2022
@akien-mga
Copy link
Member

Thanks!

@rburing rburing deleted the fix_import_hints_breaking_animations branch January 18, 2022 13:34
@akien-mga
Copy link
Member

This might warrant a dedicated backport PR for 3.x if needed there, as the change is not trivial to cherry-pick.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants