godot: Automatic mesh upgrade tool breaks `ext_resource` reference and embeds mesh data in scene file
Godot version
4.2beta3
System information
macOS 13.6.1
Issue description
After running the new automatic mesh conversion tool choosing to “Upgrade and save”, one of my scene files has been broken. It appears that something has gone wrong importing one (or both) of the imported meshes the scene references:
[ext_resource type="PackedScene" uid="uid://bq61epp0aqoyf" path="res://Models/Blob.glb" id="2_53eok"]
[ext_resource type="PackedScene" uid="uid://c5h71rygd5fkg" path="res://Models/BlobConnectionCover.dae" id="4_dnxis"]
These are referenced in the scene as nodes with some overrides, like:
[node name="BlobMesh" parent="Model" instance=ExtResource("2_53eok")]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, -0.425, 0)
[node name="Blob" parent="Model/BlobMesh" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
material_override = SubResource("ShaderMaterial_13t46")
instance_shader_parameters/Glow = 0.0
[node name="ConnectionCoverLeft" parent="Model" instance=ExtResource("4_dnxis")]
visible = false
[node name="ConnectionCover" parent="Model/ConnectionCoverLeft" index="0"]
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, -0.025, 0)
material_override = SubResource("ShaderMaterial_in6u2")
cast_shadow = 0
instance_shader_parameters/Glow = 0.0
After the conversion tool, while the references in scene nodes remain unchanged (except for new resource ids), the ext_resources referencing the meshes are now empty:
[ext_resource type="PackedScene" path="" id="9_yxliy"]
[ext_resource type="PackedScene" path="" id="10_yiqah"]
These references with no uids and no paths, cause the scene to fail loading due to these broken references, and of course they no longer reference the intended imported meshes. Additionally, the converter tool (or importer?) has instead tried to embed the entire meshes and the packed scene in the scene file, in the form of big subresources like:
[sub_resource type="ArrayMesh" id="ArrayMesh_g37c8"]
resource_name = "Blob_Sphere"
_blend_shape_names = PackedStringArray("Left", "Right", "Up", "Down")
_surfaces = [{
"aabb": AABB(-0.797799, -0.497474, -0.797602, 1.59541, 0.995045, 1.59541),
"attribute_data": PackedByteArray(0, 0, 64, 63, 240, 255, 12
...
Abbreviated here since this seems to contain the full mesh data for the model, increasing the scene file size from 16KB to 725KB. There’s then an embedded packed scene, which I guess is supposed to be a replacement for the external resource:
[sub_resource type="PackedScene" id="PackedScene_b5yox"]
_bundled = {
"conn_count": 0,
"conns": PackedInt32Array(),
"editable_instances": [],
"names": PackedStringArray("Blob2", "Node3D", "Blob", "mesh", "skeleton", "blend_shapes/Down", "blend_shapes/Left", "blend_shapes/Right", "blend_shapes/Up", "MeshInstance3D"),
"node_count": 2,
"node_paths": [],
"nodes": PackedInt32Array(-1, -1, 1, 0, -1, 0, 0, 0, 0, 9, 2, -1, 6, 3, 0, 4, 1, 5, 2, 6, 2, 7, 2, 8, 2, 0),
"variants": [SubResource("ArrayMesh_g37c8"), NodePath(""), 0.0],
"version": 3
}
But this is then not referenced anywhere in the scene file that I can find. So if it’s intended as a fallback, it’s not used? Also interestingly, I see now that it contains a “Blob2” node name, that looks like the import name change issue from https://github.com/godotengine/godot/issues/83429 perhaps this could be what is causing the automatic importer to fail as well (but in a more hard to fix way)?
So, to sum it up, the converter seems to have failed in some way, resulting in the expected ext_resource type="PackedScene"
reference being left empty, instead of getting the new converted mesh reference. On top of that it seems to have instead embedded all the mesh and imported PackedScene data into the scene file instead, but then not used this embedded data.
It also appears that the process failed to convert or save the meshes, as running the scene (after restoring the scene file to its pre-broken state) still causes the warnings from the renderer about converting meshes from an old format at runtime.
Steps to reproduce
Unfortunately I’ve been unable to find a way to trigger the import tool again, as it seems to only run once. But perhaps there’s a way to do this? I noticed that it did output errors when it ran, but at the time I did not make note of them as I expected I would be able to try again if it failed and check the errors then if I would need to.
But I’ve supplied the complete scene file (before and after conversion-versions) along with the offending mesh files and their import file settings, in the hope that these will be helpful in tracking this issue down. The scene references a lot of other resources, but these I’m pretty sure are irrelevant to this issue. But in order not to remove anything that would actually be relevant to this bug I’ve left the files as is instead of trying to “clean them up”.
I’ve also tried just making a new project in 4.2beta3 and importing the mesh there, which worked fine. So it seems to be something related to the converting process somehow.
Minimal reproduction project
While I can’t share the complete project you can access the relevant files as described above here: MeshConverterIssueFiles.zip
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 34 (24 by maintainers)
I’m going to close this as resolved based on the discussion above.
@clayjohn Here’s a test project I just made. Just to be clear, I tested to create a new project in beta beta 2 and earlier in 4.2 but none of them showed my problem. The issue only shows with projects I made in 4.1.y (or I assume earlier versions too but I haven’t tested it).
I’m also uploading here the full test project including the .godot directory just in case it matters (I know usually I should delete it before uploading).
For me any time I open this project in 4.2 beta3 I get the pop up, I press the “do it and save it” button and then I can close the editor open the editor again, open the project and the pop up is back and it will reimport the exactly same meshes everytime (all of them).
Sometimes I get some permission error with one file for some reason (apparently it’s used but I don’t understand by what considering I don’t use it elsewhere and only godot uses it in that directory) - this error is pretty common too, is it possible that there’s some race condition messing this up because otherwise I don’t know what else could be holding it back. Especially considering it’s the same directory as all the other files and the other ones work just fine.
Is this ok?
TestBeta2Mesh.zip
Edit: I’m on win 11 btw.
Hmmm, that really shouldn’t be happening. If somehow a mesh was missed then it should re-open the popup. I have a theory about what might cause this to happen. Let me validate and make a quick PR
The popup will run each time the project is opened, the setting to disable warnings does not persist across runs.
edit: I can’t quite figure this out. The warning should not be printed if you click “Upgrade & Re-save” as it disables warnings for the rest of the time that the engine is running.