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.
This commit is contained in:
Bastien Montagne 2019-03-17 17:30:16 +01:00
parent 850dfa2aa0
commit 4ecd2f7a5f
Notes: blender-bot 2023-02-14 19:45:21 +01:00
Referenced by issue #49420, X3D Exporter generates duplicate edges and splits the mesh when exporting with Triangulate
2 changed files with 9 additions and 6 deletions

View File

@ -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",

View File

@ -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="')