godotengine / godot

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

Preloaded .obj mesh fails to load in exported project #62067

Closed vfig closed 2 years ago

vfig commented 2 years ago

Godot version

v4.0.alpha9.official [fc18891db]

System information

Windows 10

Issue description

A script uses preload("res://icospher.obj") to preload a mesh, before later putting it on a MeshInstance3D. When running the game from the editor, this works as expected. But after exporting the project (to a .exe in this case), the mesh fails to load, and the console shows the following errors:

ERROR: Parser bug (please report): tried to assign unset node without an identifier.
   at: resolve_class_interface (modules/gdscript/gdscript_analyzer.cpp:656)
SCRIPT ERROR: Parse Error: Preload file "res://icospher.obj" does not exist.
          at: GDScript::reload (res://main.gd:3)
ERROR: Method/function failed. Returning: ERR_PARSE_ERROR
   at: reload (modules/gdscript/gdscript.cpp:885)

When writing the script, the autocomplete suggested the "res://icospher.obj", so I inferred that was the correct way to reference the resource, even though the actual file loaded is buried in the .godot/imported subdirectory.

Using a hex editor, I can see the converted mesh resource is present in the exported .pck, but under the name "res://.godot/imported/icospher.obj-ea174b856465bb90893e7d64ea383677.mesh".

Steps to reproduce

Run the MRP from the editor. You should see the icosphere in the viewport.

Export the sample project (or use the .pck file in the MRP), and run it. No icosphere.

Minimal reproduction project

bug_export_noobj.zip

Calinou commented 2 years ago

This is likely because the import remapping for the file isn't included in the exported project for some reason. Does this occur if you instance icospher.obj anywhere in your project before exporting it?

vfig commented 2 years ago

The export works correctly if I do one of:

But it does not work if I do one of:

Chaosus commented 2 years ago

Can confirm it's a very serious bug - also the textures seems to be affected too (and probably other resource types).

akien-mga commented 2 years ago

Duplicate of #56343, it's fixed in 4.0 beta 2.

Zireael07 commented 2 years ago

What beta 2? O_o