[Bf-extensions-cvs] [473d074b] master: Fix T51700: OBJ exporter would have inverted normals in some cases.

Bastien Montagne noreply at git.blender.org
Tue Jun 6 18:51:04 CEST 2017


Commit: 473d074b34b66d6f674bb2f06153533c9b636fd1
Author: Bastien Montagne
Date:   Tue Jun 6 18:49:02 2017 +0200
Branches: master
https://developer.blender.org/rBA473d074b34b66d6f674bb2f06153533c9b636fd1

Fix T51700: OBJ exporter would have inverted normals in some cases.

Applying a matrix with non-uniform negative scaling to a mesh requires
normals (face winfing) to be inverted back to their original orientation!

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

M	io_scene_obj/__init__.py
M	io_scene_obj/export_obj.py

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

diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 6d1312ec..6e854b9e 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -21,7 +21,7 @@
 bl_info = {
     "name": "Wavefront OBJ format",
     "author": "Campbell Barton, Bastien Montagne",
-    "version": (2, 3, 3),
+    "version": (2, 3, 4),
     "blender": (2, 77, 0),
     "location": "File > Import-Export",
     "description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py
index 89613368..e28d607d 100644
--- a/io_scene_obj/export_obj.py
+++ b/io_scene_obj/export_obj.py
@@ -397,6 +397,9 @@ def write_file(filepath, objects, scene,
                             continue
 
                         me.transform(EXPORT_GLOBAL_MATRIX * ob_mat)
+                        # If negative scaling, we have to invert the normals...
+                        if ob_mat.determinant() < 0.0:
+                            me.flip_normals()
 
                         if EXPORT_TRI:
                             # _must_ do this first since it re-allocs arrays



More information about the Bf-extensions-cvs mailing list