[Bf-extensions-cvs] [f0fe54f] master: Fix T47010: Blender OBJ UV's give issues with some apps

Campbell Barton noreply at git.blender.org
Mon Dec 21 15:22:41 CET 2015


Commit: f0fe54fcddf6fdcfe4709fa6513c09a216d2d466
Author: Campbell Barton
Date:   Tue Dec 22 01:11:41 2015 +1100
Branches: master
https://developer.blender.org/rBAf0fe54fcddf6fdcfe4709fa6513c09a216d2d466

Fix T47010: Blender OBJ UV's give issues with some apps

Blender was sharing UV's for all vertices,
while this is correct it was causing issues for Maya, 3ds Max & Unfold3D.

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

M	io_scene_obj/export_obj.py

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

diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py
index 6a9b292..ad50621 100644
--- a/io_scene_obj/export_obj.py
+++ b/io_scene_obj/export_obj.py
@@ -424,9 +424,8 @@ def write_file(filepath, objects, scene,
                         if EXPORT_NORMALS and face_index_pairs:
                             me.calc_normals_split()
                             # No need to call me.free_normals_split later, as this mesh is deleted anyway!
-                            loops = me.loops
-                        else:
-                            loops = []
+
+                        loops = me.loops
 
                         if (EXPORT_SMOOTH_GROUPS or EXPORT_SMOOTH_GROUPS_BITFLAGS) and face_index_pairs:
                             smooth_groups, smooth_groups_tot = me.calc_smooth_groups(EXPORT_SMOOTH_GROUPS_BITFLAGS)
@@ -513,7 +512,13 @@ def write_file(filepath, objects, scene,
                                 uv_ls = uv_face_mapping[f_index] = []
                                 for uv_index, l_index in enumerate(f.loop_indices):
                                     uv = uv_layer[l_index].uv
-                                    uv_key = veckey2d(uv)
+                                    # include the vertex index in the key so we don't share UV's between vertices,
+                                    # allowed by the OBJ spec but can cause issues for other importers, see: T47010.
+
+                                    # this works too, shared UV's for all verts
+                                    #~ uv_key = veckey2d(uv)
+                                    uv_key = loops[l_index].vertex_index, veckey2d(uv)
+
                                     uv_val = uv_get(uv_key)
                                     if uv_val is None:
                                         uv_val = uv_dict[uv_key] = uv_unique_count



More information about the Bf-extensions-cvs mailing list