[Bf-blender-cvs] [f02d54440de] blender-v3.2-release: Fix T97820: new OBJ importer wrongly producing "sharp" edges in some cases

Aras Pranckevicius noreply at git.blender.org
Wed Jun 22 13:03:00 CEST 2022


Commit: f02d54440dea3716893962c6fcbe6e2f9173666f
Author: Aras Pranckevicius
Date:   Sun Jun 19 17:38:32 2022 +0300
Branches: blender-v3.2-release
https://developer.blender.org/rBf02d54440dea3716893962c6fcbe6e2f9173666f

Fix T97820: new OBJ importer wrongly producing "sharp" edges in some cases

The new OBJ importer is producing "sharp" edges on some meshes that
should be completely smooth. Only observed on UV-Sphere type meshes
so far (see T97820).

I'm not 100% sure what is the root cause, but my theory was that
maybe due to limited number of float digits that are printed for
vertex normals in the file, the normals that are read in are not
always exactly 1.0 length. And then the Blender's "set custom loop
normals" function (which expects normalized inputs) wrongly marks
some edges as sharp.

Adding explicit normalization for the normals that are read from the
file fixes the wrongly-sharp edges in test cases from T97820. I
have not observed measurable performance impact in importing large
models (e.g. 6-level subdivided Monkey) that contain vertex normals.

Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D15202

===================================================================

M	source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc

===================================================================

diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
index d14401224ed..c069093ac06 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
@@ -5,6 +5,7 @@
  */
 
 #include "BLI_map.hh"
+#include "BLI_math_vector.h"
 #include "BLI_string_ref.hh"
 #include "BLI_vector.hh"
 
@@ -82,6 +83,10 @@ static void geom_add_vertex_normal(Geometry *geom,
 {
   float3 normal;
   parse_floats(line, 0.0f, normal, 3);
+  /* Normals can be printed with only several digits in the file,
+   * making them ever-so-slightly non unit length. Make sure they are
+   * normalized. */
+  normalize_v3(normal);
   r_global_vertices.vertex_normals.append(normal);
   geom->has_vertex_normals_ = true;
 }



More information about the Bf-blender-cvs mailing list