From fd108689f3b40d65a062a97b0414d43c3c95edab Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 5 Nov 2024 19:11:05 -0800 Subject: [PATCH] [4.1] GLTF: Preserve node visibility on import --- editor/import/resource_importer_scene.cpp | 1 + editor/import/scene_import_settings.cpp | 1 + ...ltf_document_extension_convert_importer_mesh.cpp | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 677b2e78bd00..e0dfc217f9e9 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -2101,6 +2101,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m } break; } + mesh_node->set_visible(src_mesh_node->is_visible()); p_node->replace_by(mesh_node); p_node->set_owner(nullptr); memdelete(p_node); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index f9f35445d020..5aa0a08b130f 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -306,6 +306,7 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { mesh_node->set_transform(src_mesh_node->get_transform()); mesh_node->set_skin(src_mesh_node->get_skin()); mesh_node->set_skeleton_path(src_mesh_node->get_skeleton_path()); + mesh_node->set_visible(src_mesh_node->is_visible()); if (src_mesh_node->get_mesh().is_valid()) { Ref editor_mesh = src_mesh_node->get_mesh(); mesh_node->set_mesh(editor_mesh->get_mesh()); diff --git a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp index 2af716b86771..75a61495507d 100644 --- a/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp +++ b/modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp @@ -46,17 +46,18 @@ Error GLTFDocumentExtensionConvertImporterMesh::import_post(Ref p_sta while (!queue.is_empty()) { List::Element *E = queue.front(); Node *node = E->get(); - ImporterMeshInstance3D *mesh_3d = cast_to(node); - if (mesh_3d) { + ImporterMeshInstance3D *importer_mesh_3d = Object::cast_to(node); + if (importer_mesh_3d) { MeshInstance3D *mesh_instance_node_3d = memnew(MeshInstance3D); - Ref mesh = mesh_3d->get_mesh(); + Ref mesh = importer_mesh_3d->get_mesh(); if (mesh.is_valid()) { Ref array_mesh = mesh->get_mesh(); mesh_instance_node_3d->set_name(node->get_name()); - mesh_instance_node_3d->set_transform(mesh_3d->get_transform()); + mesh_instance_node_3d->set_transform(importer_mesh_3d->get_transform()); mesh_instance_node_3d->set_mesh(array_mesh); - mesh_instance_node_3d->set_skin(mesh_3d->get_skin()); - mesh_instance_node_3d->set_skeleton_path(mesh_3d->get_skeleton_path()); + mesh_instance_node_3d->set_skin(importer_mesh_3d->get_skin()); + mesh_instance_node_3d->set_skeleton_path(importer_mesh_3d->get_skeleton_path()); + mesh_instance_node_3d->set_visible(importer_mesh_3d->is_visible()); node->replace_by(mesh_instance_node_3d); delete_queue.push_back(node); node = mesh_instance_node_3d;