Skip to content

Commit

Permalink
Fix obj's name set in wrong order when importing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjtxietian committed Jul 31, 2024
1 parent 3e0c10d commit eab49cf
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions editor/import/3d/resource_importer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit eab49cf

Please sign in to comment.