bmesh todo: vertex dirtmap now working again.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 13 Apr 2012 08:41:30 +0000 (08:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 13 Apr 2012 08:41:30 +0000 (08:41 +0000)
also renamed Polygon helper property from 'loops' to loop_indices

release/scripts/modules/bpy_types.py
release/scripts/startup/bl_operators/uvcalc_follow_active.py
release/scripts/startup/bl_operators/uvcalc_smart_project.py
release/scripts/startup/bl_operators/vertexpaint_dirt.py

index 131bb8ee77ea96a6188deb74e0ef860c76d672a4..91d8f1b3467fc170691a854172c3532b2543146d 100644 (file)
@@ -457,7 +457,7 @@ class MeshPolygon(StructRNA):
         return [ord_ind(verts[i], verts[(i + 1) % vlen]) for i in range(vlen)]
 
     @property
-    def loops(self):
+    def loop_indices(self):
         start = self.loop_start
         end = start + self.loop_total
         return range(start, end)
index 8d74af2986ef0d6ea1b8e3a2e3d400ad37edb78f..99ae5a3e436960a0bba9d6aa861e8596bc914e9b 100644 (file)
@@ -60,8 +60,8 @@ def extend(obj, operator, EXTEND_MODE):
         vidx_target = face_target.vertices
 
         uv_layer = me.uv_loop_layers.active.data
-        uvs_source = [uv_layer[i].uv for i in face_source.loops]
-        uvs_target = [uv_layer[i].uv for i in face_target.loops]
+        uvs_source = [uv_layer[i].uv for i in face_source.loop_indices]
+        uvs_target = [uv_layer[i].uv for i in face_target.loop_indices]
 
         # vertex index is the key, uv is the value
 
index c4a94e7f679670f15128d9988e444664c0665a65..bb3086f711be03d90580b898d072386eb755bba1 100644 (file)
@@ -759,7 +759,7 @@ class thickface(object):
     __slost__= "v", "uv", "no", "area", "edge_keys"
     def __init__(self, face, uv_layer, mesh_verts):
         self.v = [mesh_verts[i] for i in face.vertices]
-        self.uv = [uv_layer[i].uv for i in face.loops]
+        self.uv = [uv_layer[i].uv for i in face.loop_indices]
 
         self.no = face.normal
         self.area = face.area
index a5d361f206ace6243b37c82cb9c9e8072f41faab..bfbde2f4b07ca8324e2f3079c0df512aaaabb8d9 100644 (file)
@@ -26,8 +26,6 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
     from mathutils import Vector
     from math import acos
 
-    #BPyMesh.meshCalcNormals(me)
-
     vert_tone = [0.0] * len(me.vertices)
 
     min_tone = 180.0
@@ -95,7 +93,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
     tone_range = max_tone - min_tone
 
     if not tone_range:
-        return
+        return {'CANCELLED'}
 
     active_col_layer = None
 
@@ -109,18 +107,17 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
         active_col_layer = me.vertex_colors[0].data
 
     if not active_col_layer:
-        return('CANCELLED', )
-
-    for i, f in enumerate(me.faces):
-        if not me.use_paint_mask or f.select:
-
-            f_col = active_col_layer[i]
+        return
 
-            f_col = [f_col.color1, f_col.color2, f_col.color3, f_col.color4]
+    use_paint_mask = me.use_paint_mask
 
-            for j, v in enumerate(f.vertices):
-                col = f_col[j]
-                tone = vert_tone[me.vertices[v].index]
+    for i, p in enumerate(me.polygons):
+        if not use_paint_mask or p.select:
+            for loop_index in p.loop_indices:
+                loop = me.loops[loop_index]
+                v = loop.vertex_index
+                col = active_col_layer[loop_index].color
+                tone = vert_tone[v]
                 tone = (tone - min_tone) / tone_range
 
                 if dirt_only:
@@ -131,6 +128,8 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
                 col[1] = tone * col[1]
                 col[2] = tone * col[2]
 
+    return {'FINISHED'}
+
 
 import bpy
 from bpy.types import Operator
@@ -185,8 +184,8 @@ class VertexPaintDirt(Operator):
 
         t = time.time()
 
-        applyVertexDirt(mesh, self.blur_iterations, self.blur_strength, radians(self.dirt_angle), radians(self.clean_angle), self.dirt_only)
+        ret = applyVertexDirt(mesh, self.blur_iterations, self.blur_strength, radians(self.dirt_angle), radians(self.clean_angle), self.dirt_only)
 
         print('Dirt calculated in %.6f' % (time.time() - t))
 
-        return {'FINISHED'}
+        return ret