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

Duplicate tracks on animation reimport - GLTF #39959

Closed
CowKeyMan opened this issue Jun 29, 2020 · 1 comment · Fixed by #39968
Closed

Duplicate tracks on animation reimport - GLTF #39959

CowKeyMan opened this issue Jun 29, 2020 · 1 comment · Fixed by #39968

Comments

@CowKeyMan
Copy link

CowKeyMan commented Jun 29, 2020

Godot version: 3.2.2

OS/device including version: Windows

Issue description: On presssing reimportfor a .glb file, my animation tracks that I created in blender (not custom ones that I created in godot, those are fine) for every single animation that I have, get duplicted. This didnt happen in 3.2.1, because I tested it, and had to revert to that version because of this issue. This happens for both .tres as well as .anim.

Note: turning off 'keep custom tracks' will 'fix' this bug, however I need custom tracks for my game, hence this is not a valid solution for myself

Steps to reproduce: Please refer to this video: https://youtu.be/rvnMbUBGHAI (notice how the tracks for bone1-3 got duplicated for every reimport I did). I also attached an image of the errors that come with the bug

Minimal reproduction project: You can test it out using this project: AnimationImportingBugTest.zip

Capture

@aaronfranke aaronfranke changed the title Duplicate tracks on animation reimport - GITF Duplicate tracks on animation reimport - GLTF Jun 29, 2020
@Sl3dge78
Copy link
Contributor

Ok this on is on me sorry, working on a fix...

Here's my reply on the pr i was cced #39968

Hey thank you for cc ing me and sorry if my PR caused any issues...

Just to understand your issue, you imported a scene with animation to external files, modified existing tracks and/or added new ones, and finally saved said animation. Then when pressing reimport what happened?

Here's what I just tested on my side and what happens in both cases :

* Import a .dae file with animation and store the animation outside the dae

* Edit an animation (by changing tracks or adding new ones) and save it

* Reimport the .dae with the Keep Custom Tracks enabled.

old behaviour (before my pr):

* Edited tracks are reverted

* Created tracks are kept

new behaviour (with my pr):

* It duplicates all tracks (that's a big issue!)

This is where the merge happens :

if (FileAccess::exists(ext_name) && p_keep_animations) {
//try to keep custom animation tracks
Ref<Animation> old_anim = ResourceLoader::load(ext_name, "Animation", true);
if (old_anim.is_valid()) {
//meergeee
for (int i = 0; i < old_anim->get_track_count(); i++) {
if (!old_anim->track_is_imported(i)) {
old_anim->copy_track(i, anim);
}
}
anim->set_loop(old_anim->has_loop());
}
}

The snippet above adds any track that isn't marked as imported from the old file to the new file, so that's why.

Maybe the operation shouldn't be a copy but a replace? If the track exists, replace it if its not imported.
If the user wants to reverts the changes he has made he can untick "keep custom tracks"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants