[Bf-extensions-cvs] [4ecd2f7a] master: Fix T49420: X3D Exporter generates duplicate edges and splits the mesh when exporting with Triangulate.

Bastien Montagne noreply at git.blender.org
Sun Mar 17 17:44:26 CET 2019


Commit: 4ecd2f7a5f13f170ff578e8e0e59f271dd8e5ccd
Author: Bastien Montagne
Date:   Sun Mar 17 17:30:16 2019 +0100
Branches: master
https://developer.blender.org/rBA4ecd2f7a5f13f170ff578e8e0e59f271dd8e5ccd

Fix T49420: X3D Exporter generates duplicate edges and splits the mesh when exporting with Triangulate.

No point in splitting vertices over small differences in UVs or Color
values.

Note that there will still be splits when those UVs or colors actually
do not match, but this seems to be part of 'triangulated' export design
(otherwise we could use indexed values as with regular polygons export).

Based on investigation by Sebastian Ullrich (@souljedi), thanks.

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

M	io_scene_x3d/__init__.py
M	io_scene_x3d/export_x3d.py

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

diff --git a/io_scene_x3d/__init__.py b/io_scene_x3d/__init__.py
index 54377704..94ed224a 100644
--- a/io_scene_x3d/__init__.py
+++ b/io_scene_x3d/__init__.py
@@ -21,7 +21,7 @@
 bl_info = {
     "name": "Web3D X3D/VRML2 format",
     "author": "Campbell Barton, Bart, Bastien Montagne, Seva Alekseyev",
-    "version": (2, 2, 0),
+    "version": (2, 2, 1),
     "blender": (2, 80, 0),
     "location": "File > Import-Export",
     "description": "Import-Export X3D, Import VRML2",
diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py
index 7ab832d6..ff5ec0a3 100644
--- a/io_scene_x3d/export_x3d.py
+++ b/io_scene_x3d/export_x3d.py
@@ -708,6 +708,8 @@ def export(file,
 
                         slot_uv = None
                         slot_col = None
+                        def _tuple_from_rounded_iter(it):
+                            return tuple(round(v, 5) for v in it)
 
                         if is_uv and is_col:
                             slot_uv = 0
@@ -715,22 +717,22 @@ def export(file,
 
                             def vertex_key(lidx):
                                 return (
-                                    mesh_loops_uv[lidx].uv[:],
-                                    mesh_loops_col[lidx].color[:],
+                                    _tuple_from_rounded_iter(mesh_loops_uv[lidx].uv),
+                                    _tuple_from_rounded_iter(mesh_loops_col[lidx].color),
                                 )
                         elif is_uv:
                             slot_uv = 0
 
                             def vertex_key(lidx):
                                 return (
-                                    mesh_loops_uv[lidx].uv[:],
+                                    _tuple_from_rounded_iter(mesh_loops_uv[lidx].uv),
                                 )
                         elif is_col:
                             slot_col = 0
 
                             def vertex_key(lidx):
                                 return (
-                                    mesh_loops_col[lidx].color[:],
+                                    _tuple_from_rounded_iter(mesh_loops_col[lidx].color),
                                 )
                         else:
                             # ack, not especially efficient in this case
@@ -739,7 +741,6 @@ def export(file,
 
                         # build a mesh mapping dict
                         vertex_hash = [{} for i in range(len(mesh.vertices))]
-                        # worst case every face is a quad
                         face_tri_list = [[None, None, None] for i in range(len(mesh.loop_triangles))]
                         vert_tri_list = []
                         totvert = 0
@@ -762,6 +763,8 @@ def export(file,
                                 face_tri_list[totface][:] = temp_tri[:]
                                 totface += 1
 
+                        del vertex_key
+                        del _tuple_from_rounded_iter
                         assert(len(face_tri_list) == len(mesh.loop_triangles))
 
                         fw(ident_step + 'index="')



More information about the Bf-extensions-cvs mailing list