Fix error message being printed when importing an OBJ with no surfaces

An OBJ with no surfaces is valid, and typically happens when
you import an OBJ mesh with no associated MTL file.
This commit is contained in:
Hugo Locurcio 2024-07-08 23:14:52 +02:00
parent ec02d406ca
commit bbf68306c5
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C

View File

@ -425,9 +425,13 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
}
if (!current_material.is_empty()) {
mesh->set_surface_name(mesh->get_surface_count() - 1, current_material.get_basename());
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()) {
mesh->set_surface_name(mesh->get_surface_count() - 1, current_group);
if (mesh->get_surface_count() >= 1) {
mesh->set_surface_name(mesh->get_surface_count() - 1, current_group);
}
}
Array array = surf_tool->commit_to_arrays();