From 3c09077e3b88a33d103875a7e0fd0f7ca0736046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 8 Feb 2018 12:33:46 +0100 Subject: Paint Dirt: some small fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - normalize → average the vector: the vector isn't normalized here, because it doesn't necessarily becomes unit length. Instead, the sum is converted to an average vector. - angle is the acos()…: the dot product between the vertex normal and the average direction of the connected vertices is computed, and not the opposite. - The initial `con` list was discarded immediately and replaced by a new list. - File didn't end with a newline. --- release/scripts/startup/bl_operators/vertexpaint_dirt.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'release') diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index c006e8e6e92..7042f42744c 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -32,8 +32,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 +48,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 +56,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 @@ -186,4 +186,4 @@ class VertexPaintDirt(Operator): classes = ( VertexPaintDirt, -) \ No newline at end of file +) -- cgit v1.2.3