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

Corrupted scene when moving a GLB file and its animation files #95637

Open
Nodragem opened this issue Aug 16, 2024 · 2 comments
Open

Corrupted scene when moving a GLB file and its animation files #95637

Nodragem opened this issue Aug 16, 2024 · 2 comments

Comments

@Nodragem
Copy link
Contributor

Tested versions

4.3 stable

System information

Windows 11

Issue description

I have put all the files related to my character in a folder; that is a .tscn, a .glb and extracted animation.
After moving this folder to another folder, I get all the scenes that uses this character tagged as corrupted.

After some research, I can see that the .import did not update the save_to_file/path for extracted animation:

[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://duds002tisele"
valid=false

[deps]

source_file="res://characters/enemies/melee/minion/small_ennemy_animated.glb"

[params]

nodes/root_type=""
nodes/root_name="Skin"
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"animations": {
"Attack": {
"save_to_file/enabled": true,
"save_to_file/keep_custom_tracks": true,
"save_to_file/path": "res://enemies/melee/minion/Attack.res",

res://enemies/melee/minion/Attack.res should now be res://characters/enemies/melee/minion/Attack.res
To correct these paths fixed the issue.

Also, note that it might be good to give more details on why a scene is corrupted and tell the user that this is the glb import being corrupted.

Steps to reproduce

  • Import a GLB into a folder
  • Save an inherited scene
  • extract the animation using the Advanced Import, into the same folder or a child folder
  • move the parent folder to a new place

Minimal reproduction project (MRP)

NA

@Nodragem Nodragem changed the title Corrupted scene when moving a GLB/FBX file and its animation files Corrupted scene when moving a GLB file and its animation files Aug 16, 2024
@Nodragem
Copy link
Contributor Author

Note 1: I think the bug will also extend to FBX and other 3D files import.
Note 2: I experienced the same problem when moving a 3D file with an extracted material. Might need to open another issue, but it is probably a similar bug.

@Jordyfel
Copy link
Contributor

Jordyfel commented Aug 16, 2024

I've come across this as well and investigated a bit. All paths for extraction in the advanced import dialog do not work with moving/renaming, and do not use uids at all.

The solution would be to either:

  • Somehow remap paths in all .import files when moving/renaming. Not very realistic with the current state of the code.
  • Store uids only, instead of paths, in import settings and the .import file (and display the path in the dialog). The more sensible solution, but do all relevant resource types support uid?

The relevant code is across scene_import_settings for the settings write and filesystem_dock for moving/renaming files

void SceneImportSettingsDialog::_save_dir_confirm() {
for (int i = 0; i < save_path_items.size(); i++) {
TreeItem *item = save_path_items[i];
if (!item->is_checked(0)) {
continue; //ignore
}
String path = item->get_text(1);
if (!path.is_resource_file()) {
continue;
}
String id = item->get_metadata(0);
switch (current_action) {
case ACTION_EXTRACT_MATERIALS: {
ERR_CONTINUE(!material_map.has(id));
MaterialData &md = material_map[id];
Error err = ResourceSaver::save(md.material, path);
if (err != OK) {
EditorNode::get_singleton()->add_io_error(TTR("Can't make material external to file, write error:") + "\n\t" + path);
continue;
}
md.settings["use_external/enabled"] = true;
md.settings["use_external/path"] = path;
} break;
case ACTION_CHOOSE_MESH_SAVE_PATHS: {
ERR_CONTINUE(!mesh_map.has(id));
MeshData &md = mesh_map[id];
md.settings["save_to_file/enabled"] = true;
md.settings["save_to_file/path"] = path;
} break;
case ACTION_CHOOSE_ANIMATION_SAVE_PATHS: {
ERR_CONTINUE(!animation_map.has(id));
AnimationData &ad = animation_map[id];
ad.settings["save_to_file/enabled"] = true;
ad.settings["save_to_file/path"] = path;
} break;
}
}

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