Skip to content

Commit 3232794

Browse files
committed
fix external material for invalid material
1 parent ef28da8 commit 3232794

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

editor/import/resource_importer_scene.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,11 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, HashMap<
986986
if (mat.is_valid()) {
987987
String mat_id = mat->get_meta("import_id", mat->get_name());
988988

989+
if (mat_id.is_empty() && mat->has_meta("unique_id")) {
990+
mat_id = mat->get_meta("unique_id");
991+
mat->remove_meta("unique_id");
992+
}
993+
989994
if (!mat_id.is_empty() && p_material_data.has(mat_id)) {
990995
Dictionary matdata = p_material_data[mat_id];
991996
{

editor/import/scene_import_settings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma
148148
} else if (!p_material->get_name().is_empty()) {
149149
import_id = p_material->get_name();
150150
has_import_id = true;
151+
} else if (p_material->has_meta("unique_id")) {
152+
import_id = p_material->get_meta("unique_id");
151153
} else {
152154
import_id = "@MATERIAL:" + itos(material_set.size() - 1);
153155
}

modules/gltf/gltf_document.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,6 +2948,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
29482948
} else {
29492949
Ref<StandardMaterial3D> mat3d;
29502950
mat3d.instantiate();
2951+
mat3d->set_meta("unique_id", vformat("%s@%s", import_mesh->get_name(), itos(j)));
29512952
if (has_vertex_color) {
29522953
mat3d->set_flag(BaseMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
29532954
}

0 commit comments

Comments
 (0)