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

Can't reset root node type to Node3D in advanced import settings #78140

Closed
mbrlabs opened this issue Jun 12, 2023 · 6 comments · Fixed by #79907
Closed

Can't reset root node type to Node3D in advanced import settings #78140

mbrlabs opened this issue Jun 12, 2023 · 6 comments · Fixed by #79907

Comments

@mbrlabs
Copy link
Contributor

mbrlabs commented Jun 12, 2023

Godot version

4.0.3 and latest 4.1 (2d6b880)

System information

Manjaro Linux

Issue description

When you change the root type of an imported scene (in my case it's a glb file) you can't change it back to a Node3D. Changing it to any other 3D node works though.

Steps to reproduce

  1. Import a glb file
  2. Double click it to open the advanced import settings and change the root type to StaticBody3D or any other type that inherits from Node3D. Click reimport.
  3. Now try to change it from StaticBody3D to Node3D. This will fail silently.

Minimal reproduction project

RootTypeBug.zip

@AThousandShips
Copy link
Member

Might have found the cause of this, will try investigate when I have the time, it checks for the root type and doesn't do anything if it is Node3D, I think that check needs to be different

@mbrlabs
Copy link
Contributor Author

mbrlabs commented Jun 12, 2023

Yeah, i guess you found this:

if (root_type != "Node3D") {
Node *base_node = Object::cast_to<Node>(ClassDB::instantiate(root_type));
if (base_node) {
scene->replace_by(base_node);
scene->set_owner(nullptr);
memdelete(scene);
scene = base_node;
}
}

Not sure why Node3D is excluded here. I removed the check but it didn't seem to do anything. Didn't dig too deep into this though, so feel free to investigate further :)

@kdiduk
Copy link
Contributor

kdiduk commented Jul 7, 2023

I've found something interesting.

void SceneImportSettings::_re_import() {
HashMap<StringName, Variant> main_settings;
main_settings = defaults;

When any node, apart from Node3D is selected in the dialog, the dictionary defaults contains an entry with the key nodes/root_type and the string value with the name of selected node type.

However, for some reason, when we select Node3D, the dictionary defaults doesn't have an entry with the key nodes/root_type.

@capnm
Copy link
Contributor

capnm commented Jul 8, 2023

The workaround is to use the "non-advanced" import settings, the 🐛 seems to be somewhere in the flawed logic of the new one ...

@kdiduk
Copy link
Contributor

kdiduk commented Jul 25, 2023

I've found the problem and made a pull-request 😌 It turned out that it affected literally any import setting, not only Root Type. That is, when we change any setting to non-default value and reimported the scene, afterwards it was not possible to set it back to a default value.

Although it was tricky to find it, the fix for it is just one line.

kdiduk added a commit to kdiduk/godot that referenced this issue Jul 28, 2023
This commit fixes godotengine#78140

When the scene was re-imported with non-default values of some settings, re-importing it again using default values for those settings didn't have the effect.

The problem was that when handling the reimport, a wrong dictionary of the settings was used.
IntangibleMatter pushed a commit to IntangibleMatter/godot that referenced this issue Aug 13, 2023
This commit fixes godotengine#78140

When the scene was re-imported with non-default values of some settings, re-importing it again using default values for those settings didn't have the effect.

The problem was that when handling the reimport, a wrong dictionary of the settings was used.
mandryskowski pushed a commit to mandryskowski/godot that referenced this issue Oct 11, 2023
This commit fixes godotengine#78140

When the scene was re-imported with non-default values of some settings, re-importing it again using default values for those settings didn't have the effect.

The problem was that when handling the reimport, a wrong dictionary of the settings was used.
@mikest
Copy link

mikest commented Oct 14, 2023

I have run into this issue while Reimporting gltf models after changing the root node type from Node3D to RigidBody3D. I can no longer change back to Node3D. The changes don't stick on re-import.

This would be on 4.1.2

YuriSizov pushed a commit to YuriSizov/godot that referenced this issue Oct 24, 2023
This commit fixes godotengine#78140

When the scene was re-imported with non-default values of some settings, re-importing it again using default values for those settings didn't have the effect.

The problem was that when handling the reimport, a wrong dictionary of the settings was used.

(cherry picked from commit 8b729e5)
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.

6 participants