Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-02-09 16:27:32 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-02-09 16:27:32 +0300
commitbe4ebb7fa6c4b0678803c75d20c080e0b1db4877 (patch)
tree9682998b2408e5b7021eae57be8089460103523f /release
parent5db950e860b2f64078cfc8cf00cb4f430b8a1baf (diff)
parent97597ed6002211d55565d2a281da3c3fc1098ebb (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_operators/vertexpaint_dirt.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
index c006e8e6e92..f12b76a76ba 100644
--- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py
+++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
@@ -21,7 +21,17 @@
# <pep8 compliant>
-# Contributor(s): Keith "Wahooney" Boshoff, Campbell Barton
+# Contributor(s): Keith "Wahooney" Boshoff, Campbell Barton, Sybren A. Stüvel
+
+
+def get_vcolor_layer_data(me):
+ for lay in me.vertex_colors:
+ if lay.active:
+ return lay.data
+
+ lay = me.vertex_colors.new()
+ lay.active = True
+ return lay.data
def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only):
@@ -32,8 +42,6 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
vert_tone = array.array("f", [0.0]) * len(me.vertices)
# create lookup table for each vertex's connected vertices (via edges)
- con = []
-
con = [[] for i in range(len(me.vertices))]
# add connected verts
@@ -50,7 +58,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
for c in con[i]:
vec += (me.vertices[c].co - co).normalized()
- # normalize the vector by dividing by the number of connected verts
+ # average the vector by dividing by the number of connected verts
tot_con = len(con[i])
if tot_con == 0:
@@ -58,7 +66,9 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
vec /= tot_con
- # angle is the acos() of the dot product between vert and connected verts normals
+ # angle is the acos() of the dot product between normal and connected verts.
+ # > 90 degrees: convex
+ # < 90 degrees: concave
ang = acos(no.dot(vec))
# enforce min/max
@@ -93,17 +103,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
else:
tone_range = 1.0 / tone_range
- active_col_layer = None
-
- if me.vertex_colors:
- for lay in me.vertex_colors:
- if lay.active:
- active_col_layer = lay.data
- else:
- bpy.ops.mesh.vertex_color_add()
- me.vertex_colors[0].active = True
- active_col_layer = me.vertex_colors[0].data
-
+ active_col_layer = get_vcolor_layer_data(me)
if not active_col_layer:
return {'CANCELLED'}
@@ -186,4 +186,4 @@ class VertexPaintDirt(Operator):
classes = (
VertexPaintDirt,
-) \ No newline at end of file
+)