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

.blend files import with incorrect base poses #64598

Closed
jitspoe opened this issue Aug 19, 2022 · 12 comments
Closed

.blend files import with incorrect base poses #64598

jitspoe opened this issue Aug 19, 2022 · 12 comments

Comments

@jitspoe
Copy link
Contributor

jitspoe commented Aug 19, 2022

Godot version

v4.0.alpha.custom_build [2475393]

System information

Windows 10, GLES3, NVidia RTX 3080

Issue description

When importing a .blend file, sometimes the base poses are completely (or just slightly) off. Seems to be completely random, as I haven't tracked down what causes it to happen. Sometimes a thumb will be messed up. Sometimes the arms will be in a crazy pose. Animations will all be offset by this broken initial pose.

Examples:
image

Right arm is in the wrong pose. After a reimport, while changing nothing with the .blend file, sometimes other bones will have incorrect poses.

image

Here we can see one of the left fingers is off, the right foot is twisted, and the right hand is twisted. Also, the index for the weapon attachment changed from the hand to the head (see #64512 -- not sure if that's related).

image

Another reimport resulted in this, with both arms posed incorrectly.

Steps to reproduce

Re-save an imported .blend file, or go to the blend file in godot and reimport it. Reload the editor to ensure things update, and note that some bones might randomly have different poses.

Minimal reproduction project

Here's the .blend file I'm using. I have it in a tree like this, though I don't think it matters:

image

Edit: Here's a project that reproduces the issue: https://github.com/godotengine/godot/files/9457268/test_broken_blend_import.zip

@fire
Copy link
Member

fire commented Aug 19, 2022

As mentioned in the other thread try 120 fps.

@jitspoe
Copy link
Contributor Author

jitspoe commented Aug 20, 2022

As mentioned in the other thread try 120 fps.

LOL, nope.

image

@fire
Copy link
Member

fire commented Aug 20, 2022

Confirmed. We need to devise a way to make the bone attachments more deterministic. I would trial renaming to be the bone name.

Edited:

Can you provide a test project?

@TokageItLab
Copy link
Member

Related by #61641?

@TokageItLab TokageItLab added this to the 4.0 milestone Aug 20, 2022
@jitspoe
Copy link
Contributor Author

jitspoe commented Aug 22, 2022

Related by #61641?

Ah, sounds like it's related. So it's an exporter issue? What's strange is I tried importing the .gltf file it created, and it was OK in blender. Perhaps the issue is just that the bone order changes and some of the bones retain their poses from the previous ID somehow? Seems this could still be an issue if the skeleton is modified if that's the case (though it would be a lot less frequent).

@jitspoe
Copy link
Contributor Author

jitspoe commented Aug 30, 2022

Ok, so I've confirmed this is NOT an exporter issue. I was able to import the exported .gltf file just fine. In fact, the .blend file in a fresh scene imports correctly. The problem is that Godot is saving bone positions in the scene file which are messing with the imported blender/gltf file.

[node name="Skeleton3D" parent="AimedPoint/Visual/main_character/Game_engine" index="0"]
bones/2/rotation = Quaternion(0.982916, -0.0617198, -0.117551, 0.127471)
bones/14/rotation = Quaternion(-0.332453, -0.113715, 0.187499, 0.917272)
bones/15/rotation = Quaternion(-0.0709867, -0.0900624, -0.133388, 0.984407)
bones/16/rotation = Quaternion(-0.0121374, 0.308126, -0.0798156, 0.947914)
bones/25/rotation = Quaternion(-0.369574, 0.377385, 0.527481, 0.665402)
bones/26/rotation = Quaternion(-0.0591414, 0.195179, 0.0844345, 0.975335)
bones/27/rotation = Quaternion(-0.0292103, -0.193134, -0.0194931, 0.980544)
bones/34/rotation = Quaternion(-0.0709867, -0.0900624, -0.133388, 0.984407)
bones/35/rotation = Quaternion(-0.369574, 0.377385, 0.527481, 0.665402)
bones/36/rotation = Quaternion(-0.0591414, 0.195179, 0.0844345, 0.975335)
bones/37/rotation = Quaternion(-0.0292103, -0.193134, -0.0194931, 0.980544)

I'll see if I can separate this cleanly into an example project.

@jitspoe
Copy link
Contributor Author

jitspoe commented Aug 31, 2022

Here's the example project file. I think, fundamentally, what the problem is, is that the editor does not update the model when reimporting, leaving the old version of the model in memory, and when the file gets saved, the old bone transforms overwrite the newly imported data. This combined with the bone indexes shuffling around, means we get wacky, random poses.

test_broken_blend_import.zip

@TokageItLab
Copy link
Member

I assume the shuffling of the bone ID is an exporter issue, not an importer issue, and that it was resolved in #61641 (comment).

@jitspoe
Copy link
Contributor Author

jitspoe commented Aug 31, 2022

I assume the shuffling of the bone ID is an exporter issue, not an importer issue, and that it was resolved in #61641 (comment).

I got the latest gltf exporter from github, but it did not fix this issue. The bone shuffling amplifies the bug, since it randomizes the bone indexes, but the problem is that bone poses are being stored in the scene, so those poses override what's in the .blend or gltf file.

EDIT: Correction: I don't know if getting the latest gltf exporter would have had an impact. I just realized the editor settings were pointed to an older version of blender (3.1), which I did not update.

This has actually always been a problem with Godot when you have editable children enabled on an imported object and re-import. The data in memory overwrites the new import data and messes things up. It's just more prevalent in Godot 4, since that seems to be the intended workflow, instead of creating an inherited scene like you had to do in Godot 3.

It's usually not a problem if you don't have the scene open. But if you have the scene open and re-import, it can break things. Perhaps forcing the scene to update with the re-imported data would fix it? (That'd also be nice so we don't have to restart the editor after every import to see the changes - related: #55420).

@TokageItLab
Copy link
Member

TokageItLab commented Feb 17, 2023

@jitspoe Does #72342 fix this?

@fire

This comment was marked as off-topic.

@lyuma
Copy link
Contributor

lyuma commented Feb 22, 2023

I'm going to tentatively close this issue pending feedback from the original reporter. We believe it is fixed in 4.0rc3

please comment or reopen if you can still reproduce it.

@lyuma lyuma closed this as completed Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants