godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.14k stars 21.17k forks source link

Importing spinning animations from blender warps/breaks the animation. #75159

Closed KnightNine closed 8 months ago

KnightNine commented 1 year ago

Godot version

4.0

System information

Windows 10

Issue description

I have this spinning animation in blender:

Blender Anim

Importing it to Godot directly from the .blend file results in the animation oscillating between the lowest and highest rotation values instead of spinning. (exporting to glTF 2.0 has the same issue.) Blend animation import

As a test i tried importing it using .dae hoping that maybe it would work fine like in 3.5 but it's the same issue and the bones are warped as well:

Dae animation import

This also means that importing a backflip animation, a spinning propeller, or a plane doing a barrel roll, would be impossible. Probably the only workaround would be to recreate the animations in the engine itself.

Steps to reproduce

Minimal reproduction project

N/A

Calinou commented 1 year ago

Looking at the GIF, it seems rotation keyframes wrap around if they reach 360 degrees (which means a keyframe can't go above 360 degrees).

KnightNine commented 1 year ago

@Calinou the bottom parent bone (which controls the outermost layer) rotates exactly 360 degrees, and in Godot, it rotates 180 degrees and then turns back. If I make the animation rotate to just under 360 degrees it works fine so you're almost right, you just cant reach 360 degrees. I also haven't tested if negative rotations also breaks the imported animations tough I would assume that you just can't reach -360 since it would be hard to overlook.

So if you want to create an animation which goes past 360 degrees, say a steering wheel, you'd need to keep in mind whenever the rotation is about to reach 360 and reset the wheel every time it's about to reach that value.

Anyways this would be finnicky as all hell for more complex animations.

KnightNine commented 1 year ago

rotation reset so at least it can be done through importing by making sure the rotation never reaches 360 or -360, though if I decide to ever change the animation frame rate I'd probably encounter some issues where I added the "rotation resets".

looking back at 3.5 these "rotation resets" seem to have been added automatically so this is a regression.

TokageItLab commented 1 year ago

Perhaps the Optimizer is removing too many keys.

Animations from glTF need to be baked, not imported with their keyframes in their entirety. At this time, if the Optimizer is enabled, some keys that rotate at constant velocity will be omitted depending on the threshold value.

I remember that I made it so that if a rotation of more than 180 degrees occurs, no omitting is done to prevent this from happening, but it may not be working properly.

For now, can you confirm that disabling the Optimizer will not cause this problem?

KnightNine commented 1 year ago

@TokageItLab How do I disable the Optimizer? Is it a setting, or something I need to change in the engine files?

TokageItLab commented 1 year ago

@KnightNine Open importer scene by double click on 3d model resource in file dock.

KnightNine commented 1 year ago

@TokageItLab yes it fixes the issue!

TokageItLab commented 1 year ago

I will see if I can improve Optimizer when I have time.

KnightNine commented 1 year ago

@TokageItLab I'm guessing you'd need to create some sorta exception flag for the optimizer to not delete the "rotation reset" keyframe pairs that are generated.