[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33362] trunk/blender/release/scripts/op/ uv.py: bugfix "Export UV Layout" stalls when saving file in 2.55b

Campbell Barton ideasman42 at gmail.com
Sun Nov 28 14:39:40 CET 2010


Revision: 33362
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33362
Author:   campbellbarton
Date:     2010-11-28 14:39:39 +0100 (Sun, 28 Nov 2010)

Log Message:
-----------
bugfix "Export UV Layout" stalls when saving file in 2.55b
remove duplicate UVs on export to avoid long ztransp filling times - common on faces which have no assigned UV coords.

Modified Paths:
--------------
    trunk/blender/release/scripts/op/uv.py

Modified: trunk/blender/release/scripts/op/uv.py
===================================================================
--- trunk/blender/release/scripts/op/uv.py	2010-11-28 12:38:29 UTC (rev 33361)
+++ trunk/blender/release/scripts/op/uv.py	2010-11-28 13:39:39 UTC (rev 33362)
@@ -126,27 +126,39 @@
     for f in mesh_source.faces:
         tot_verts += len(f.vertices)
 
+
+    faces_source = mesh_source.faces
+
+    # get unique UV's incase there are many overlapping which slow down filling.
+    face_hash_3 = set()
+    face_hash_4 = set()
+    for i, uv in face_iter:
+        material_index = faces_source[i].material_index
+        if len(uv) == 3:
+            face_hash_3.add((uv[0][0], uv[0][1], uv[1][0], uv[1][1], uv[2][0], uv[2][1], material_index))
+        else:
+            face_hash_4.add((uv[0][0], uv[0][1], uv[1][0], uv[1][1], uv[2][0], uv[2][1], uv[3][0], uv[3][1], material_index))
+
     # now set the faces coords and locations
     # build mesh data
     mesh_new_vertices = []
     mesh_new_materials = []
     mesh_new_face_vertices = []
-    
-    
+
+
     current_vert = 0
-    faces_source = mesh_source.faces
-    for i, uv in face_iter:
-        if len(uv) == 3:
-            mesh_new_vertices.extend([uv[0][0], uv[0][1], 0.0, uv[1][0], uv[1][1], 0.0, uv[2][0], uv[2][1], 0.0])
-            mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, 0])
-            current_vert += 3
-        else:
-            mesh_new_vertices.extend([uv[0][0], uv[0][1], 0.0, uv[1][0], uv[1][1], 0.0, uv[2][0], uv[2][1], 0.0, uv[3][0], uv[3][1], 0.0])
-            mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, current_vert + 3])
-            current_vert += 4
 
-        mesh_new_materials.append(faces_source[i].material_index)
-    
+    for face_data in face_hash_3:
+        mesh_new_vertices.extend([face_data[0], face_data[1], 0.0, face_data[2], face_data[3], 0.0, face_data[4], face_data[5], 0.0])
+        mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, 0])
+        mesh_new_materials.append(face_data[6])
+        current_vert += 3
+    for face_data in face_hash_4:
+        mesh_new_vertices.extend([face_data[0], face_data[1], 0.0, face_data[2], face_data[3], 0.0, face_data[4], face_data[5], 0.0, face_data[6], face_data[7], 0.0])
+        mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, current_vert + 3])
+        mesh_new_materials.append(face_data[8])
+        current_vert += 4
+
     mesh.vertices.add(len(mesh_new_vertices) // 3)
     mesh.faces.add(len(mesh_new_face_vertices) // 4)
 





More information about the Bf-blender-cvs mailing list