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

Attempt applying RESET pose during import. #96308

Merged

Conversation

SaracenOne
Copy link
Member

@SaracenOne SaracenOne commented Aug 30, 2024

This PR attempts to use and set the RESET pose so it becomes the default skeletal pose when serializing an imported scene. Now that #96196 has been merged, you might notice that if you instanced + set editable children on some models, after saving, certain rotation quaternions in the pose don't actually match the base model, meaning useless data gets written to the scene which instances it.

The reason this happens is that the imported scene by default uses the rest pose as the default pose, but scenes will automatically call the RESET animation whenever saving a scene. Even when the rest and reset pose appear to be a 1:1 match, certain bones will still not match because of quantization (rests are stored as Transform3Ds, whereas poses are stored as seperate position/rotation/scale values). (Edit: actually, this isn't always the case, the pose can actually just be whatever the model came in as, though using the rest pose is what is used when importing with retargeting. None of this invalidates the point however since the idea is to make the imported pose consistent with the special RESET pose which gets set everytime a scene is saved). Making the RESET pose the default pose when importing should resolve this discontinuity.

Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the imported scenes consistent with the default "reset on save" behavior of AnimationPlayer.

I do want to note that RESET animations are created from bone rest, but not the initial bone pose, which may be different.
Godot's BoneMap system by default resets the skeleton to bone rest, since the option to do so is enabled by default for compatibility reasons.

This PR will change the initial pose if there is a RESET animation, and if the user is not using a BoneMap or has deselected the reset option.

I think it is good because any scene with RESET will be reset on save anyway.
If anyone has a problem with losing the initial pose in the 2 cases I mentioned above, we could add an option to disable "Reset on Save" on imported AnimationPlayer (and also disable this behavior as a result). But I would wait and see if someone asks for this.

@SaracenOne
Copy link
Member Author

SaracenOne commented Aug 30, 2024

Thanks @lyuma, I updated the inital comment to reflect this.

@akien-mga akien-mga merged commit 7f86ca0 into godotengine:master Aug 30, 2024
19 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

3 participants