diff options
author | jsjtxietian <jsjtxietian@outlook.com> | 2024-07-31 14:50:02 +0800 |
---|---|---|
committer | jsjtxietian <jsjtxietian@outlook.com> | 2024-07-31 14:50:02 +0800 |
commit | eab49cf256a7d2a95f9fda22a63b4731c9ce6bc4 (patch) | |
tree | 65ff0763279f3da4e91dd8fec623a31e4b5ee170 /editor | |
parent | 3e0c10d3931afb62a30f26532a9f7709ee68bf2c (diff) | |
download | redot-engine-eab49cf256a7d2a95f9fda22a63b4731c9ce6bc4.tar.gz |
Fix obj's name set in wrong order when importing
Diffstat (limited to 'editor')
-rw-r--r-- | editor/import/3d/resource_importer_obj.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/editor/import/3d/resource_importer_obj.cpp b/editor/import/3d/resource_importer_obj.cpp index a0c05598a2..2fbf564ae8 100644 --- a/editor/import/3d/resource_importer_obj.cpp +++ b/editor/import/3d/resource_importer_obj.cpp @@ -424,15 +424,6 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes, surf_tool->set_material(material); } - if (!current_material.is_empty()) { - if (mesh->get_surface_count() >= 1) { - mesh->set_surface_name(mesh->get_surface_count() - 1, current_material.get_basename()); - } - } else if (!current_group.is_empty()) { - if (mesh->get_surface_count() >= 1) { - mesh->set_surface_name(mesh->get_surface_count() - 1, current_group); - } - } Array array = surf_tool->commit_to_arrays(); if (mesh_flags & RS::ARRAY_FLAG_COMPRESS_ATTRIBUTES && generate_tangents) { @@ -451,6 +442,16 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes, mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, array, TypedArray<Array>(), Dictionary(), material, name, mesh_flags); print_verbose("OBJ: Added surface :" + mesh->get_surface_name(mesh->get_surface_count() - 1)); + if (!current_material.is_empty()) { + if (mesh->get_surface_count() >= 1) { + mesh->set_surface_name(mesh->get_surface_count() - 1, current_material.get_basename()); + } + } else if (!current_group.is_empty()) { + if (mesh->get_surface_count() >= 1) { + mesh->set_surface_name(mesh->get_surface_count() - 1, current_group); + } + } + surf_tool->clear(); surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); } |