diff options
author | Aras Pranckevicius <aras@nesnausk.org> | 2022-05-03 14:44:49 +0300 |
---|---|---|
committer | Aras Pranckevicius <aras@nesnausk.org> | 2022-05-03 14:44:49 +0300 |
commit | 5f5e7ac317ddef5fed1c85fc8568c3ce09141fc1 (patch) | |
tree | ea62e1e9d67c5f2da5d5814ff43c543510d1051e /source/blender/io/wavefront_obj/importer/obj_importer.cc | |
parent | a2e3005b422fe745ee2d53f1c00ca8c443e000c5 (diff) |
Fix T97757: Some MTL import correctness issues in the new OBJ importer
Fix several correctness issues where the new OBJ/MTL importer was not
producing the same results as the old one, mostly because the code for
some reason had slightly different logic. Fixes T97757:
- When .obj file tries to use a material that does not exist, the code
was continuing to use the previous material, instead of creating new
default one, as the previous importer did.
- Previous importer was always searching/parsing "foo.mtl" for a
"foo.obj" file, even if the file itself does not contain
"mtllib foo.mtl" statement. One file from T97757 repros happens to
depend on that, so resurrect that behavior.
- When IOR (Ni) or Alpha (d) are not specified in .mtl file, do not
wrongly set -1 values to the blender material.
- When base (Kd) or emissive (Ke) colors are not specified in the .mtl
file, do not set them on the blender material.
- Roughness and metallic values used by viewport shading were not set
onto blender material.
- The logic for when metallic was set to zero was incorrect; it should
be set to zero when "not using reflection", not when "mtl file does
not contain metallic".
- Do not produce a warning when illum value is not spelled out in .mtl
file, treat as default (1).
- Parse illum as a float just like python importer does, as to not
reintroduce part of T60135.
Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D14822
Diffstat (limited to 'source/blender/io/wavefront_obj/importer/obj_importer.cc')
-rw-r--r-- | source/blender/io/wavefront_obj/importer/obj_importer.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/source/blender/io/wavefront_obj/importer/obj_importer.cc b/source/blender/io/wavefront_obj/importer/obj_importer.cc index c21d2d9583c..d9c033e1f77 100644 --- a/source/blender/io/wavefront_obj/importer/obj_importer.cc +++ b/source/blender/io/wavefront_obj/importer/obj_importer.cc @@ -29,15 +29,14 @@ namespace blender::io::obj { /** * Make Blender Mesh, Curve etc from Geometry and add them to the import collection. */ -static void geometry_to_blender_objects( - Main *bmain, - Scene *scene, - ViewLayer *view_layer, - const OBJImportParams &import_params, - Vector<std::unique_ptr<Geometry>> &all_geometries, - const GlobalVertices &global_vertices, - const Map<std::string, std::unique_ptr<MTLMaterial>> &materials, - Map<std::string, Material *> &created_materials) +static void geometry_to_blender_objects(Main *bmain, + Scene *scene, + ViewLayer *view_layer, + const OBJImportParams &import_params, + Vector<std::unique_ptr<Geometry>> &all_geometries, + const GlobalVertices &global_vertices, + Map<std::string, std::unique_ptr<MTLMaterial>> &materials, + Map<std::string, Material *> &created_materials) { BKE_view_layer_base_deselect_all(view_layer); LayerCollection *lc = BKE_layer_collection_get_active(view_layer); |