diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-04-21 20:22:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-04-21 20:22:37 +0400 |
commit | bd1363a898aaaec21426b4ebb63bc7bb76cd08c1 (patch) | |
tree | cf66b6189c1655eb6ed307fd2fa052f4d1506ed5 /release | |
parent | ec9f2af65976bac519fcf52e0dfe596ddc170e5e (diff) |
fix for divide by zero on vertex dirt script, show from the vertex paint menu
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/op/vertexpaint_dirt.py | 17 | ||||
-rw-r--r-- | release/scripts/ui/space_view3d.py | 1 |
2 files changed, 12 insertions, 6 deletions
diff --git a/release/scripts/op/vertexpaint_dirt.py b/release/scripts/op/vertexpaint_dirt.py index 0b0d70c5e56..acbf7660e8c 100644 --- a/release/scripts/op/vertexpaint_dirt.py +++ b/release/scripts/op/vertexpaint_dirt.py @@ -58,17 +58,22 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, con[e.verts[0]].append(e.verts[1]) con[e.verts[1]].append(e.verts[0]) - for v in me.verts: + for i, v in enumerate(me.verts): vec = Vector() no = v.normal co = v.co # get the direction of the vectors between the vertex and it's connected vertices - for c in con[v.index]: + for c in con[i]: vec += Vector(me.verts[c].co - co).normalize() # normalize the vector by dividing by the number of connected verts - vec /= len(con[v.index]) + tot_con = len(con[i]) + + if tot_con == 0: + continue + + vec /= tot_con # angle is the acos of the dot product between vert and connected verts normals ang = math.acos(no.dot(vec)) @@ -79,7 +84,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, if not dirt_only: ang = min(clamp_clean, ang) - vert_tone[v.index] = ang + vert_tone[i] = ang # blur tones for i in range(blur_iterations): @@ -146,7 +151,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, class VertexPaintDirt(bpy.types.Operator): - bl_idname = "mesh.vertex_paint_dirt" + bl_idname = "paint.vertex_color_dirt" bl_label = "Dirty Vertex Colors" bl_options = {'REGISTER', 'UNDO'} @@ -171,7 +176,7 @@ class VertexPaintDirt(bpy.types.Operator): print('Dirt calculated in %.6f' % (time.time() - t)) - return('FINISHED',) + return {'FINISHED'} def register(): diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 85689e178eb..f775340c124 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -850,6 +850,7 @@ class VIEW3D_MT_paint_vertex(bpy.types.Menu): layout = self.layout layout.operator("paint.vertex_color_set") + layout.operator("paint.vertex_color_dirt") class VIEW3D_MT_hook(bpy.types.Menu): |