Prevent obj importer from printing misleading error

This commit is contained in:
Brian Semrau 2021-11-06 22:12:36 -04:00
parent 4651b2ae5c
commit bd0d15c5be

View file

@ -405,11 +405,11 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
current_material_library = l.replace("mtllib", "").strip_edges(); current_material_library = l.replace("mtllib", "").strip_edges();
if (!material_map.has(current_material_library)) { if (!material_map.has(current_material_library)) {
Map<String, Ref<StandardMaterial3D>> lib; Map<String, Ref<StandardMaterial3D>> lib;
Error err = _parse_material_library(current_material_library, lib, r_missing_deps); String lib_path = current_material_library;
if (err == ERR_CANT_OPEN) { if (lib_path.is_relative_path()) {
String dir = p_path.get_base_dir(); lib_path = p_path.get_base_dir().plus_file(current_material_library);
err = _parse_material_library(dir.plus_file(current_material_library), lib, r_missing_deps);
} }
Error err = _parse_material_library(lib_path, lib, r_missing_deps);
if (err == OK) { if (err == OK) {
material_map[current_material_library] = lib; material_map[current_material_library] = lib;
} }