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:
Diffstat (limited to 'release/scripts/startup/bl_operators/vertexpaint_dirt.py')
-rw-r--r--release/scripts/startup/bl_operators/vertexpaint_dirt.py34
1 files changed, 11 insertions, 23 deletions
diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
index ecb1ecf7f47..892e1822d68 100644
--- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py
+++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
@@ -27,11 +27,9 @@
def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only):
from mathutils import Vector
from math import acos
+ import array
- vert_tone = [0.0] * len(me.vertices)
-
- min_tone = 180.0
- max_tone = 0.0
+ vert_tone = array.array("f", [0.0]) * len(me.vertices)
# create lookup table for each vertex's connected vertices (via edges)
con = []
@@ -74,7 +72,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
# blur tones
for i in range(blur_iterations):
# backup the original tones
- orig_vert_tone = list(vert_tone)
+ orig_vert_tone = vert_tone[:]
# use connected verts look up for blurring
for j, c in enumerate(con):
@@ -82,20 +80,18 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
vert_tone[j] += blur_strength * orig_vert_tone[v]
vert_tone[j] /= len(c) * blur_strength + 1
+ del orig_vert_tone
min_tone = min(vert_tone)
max_tone = max(vert_tone)
- # debug information
- # print(min_tone * 2 * math.pi)
- # print(max_tone * 2 * math.pi)
- # print(clamp_clean)
- # print(clamp_dirt)
-
tone_range = max_tone - min_tone
- if not tone_range:
- return {'CANCELLED'}
+ if tone_range < 0.0001:
+ # weak, don't cancel, see T43345
+ tone_range = 0.0
+ else:
+ tone_range = 1.0 / tone_range
active_col_layer = None
@@ -112,7 +108,6 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
return {'CANCELLED'}
use_paint_mask = me.use_paint_mask
-
for i, p in enumerate(me.polygons):
if not use_paint_mask or p.select:
for loop_index in p.loop_indices:
@@ -120,11 +115,10 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
v = loop.vertex_index
col = active_col_layer[loop_index].color
tone = vert_tone[v]
- tone = (tone - min_tone) / tone_range
+ tone = (tone - min_tone) * tone_range
if dirt_only:
- tone = min(tone, 0.5)
- tone *= 2.0
+ tone = min(tone, 0.5) * 2.0
col[0] = tone * col[0]
col[1] = tone * col[1]
@@ -182,15 +176,9 @@ class VertexPaintDirt(Operator):
return (obj and obj.type == 'MESH')
def execute(self, context):
- import time
-
obj = context.object
mesh = obj.data
- t = time.time()
-
ret = applyVertexDirt(mesh, self.blur_iterations, self.blur_strength, self.dirt_angle, self.clean_angle, self.dirt_only)
- print('Dirt calculated in %.6f' % (time.time() - t))
-
return ret