Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_operators/vertexpaint_dirt.py
| Context not available. | |||||
| return lay.data | return lay.data | ||||
| def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only): | def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only, normalize): | ||||
| from mathutils import Vector | from mathutils import Vector | ||||
| from math import acos | from math import acos | ||||
| import array | import array | ||||
| Context not available. | |||||
| tot_con = len(con[i]) | tot_con = len(con[i]) | ||||
| if tot_con == 0: | if tot_con == 0: | ||||
| continue | ang = pi / 2.0 # assume 90°, i. e. flat | ||||
| else: | |||||
| vec /= tot_con | |||||
| vec /= tot_con | # angle is the acos() of the dot product between normal and connected verts. | ||||
| # > 90 degrees: convex | |||||
| # angle is the acos() of the dot product between normal and connected verts. | # < 90 degrees: concave | ||||
| # > 90 degrees: convex | ang = acos(no.dot(vec)) | ||||
| # < 90 degrees: concave | |||||
| ang = acos(no.dot(vec)) | |||||
| # enforce min/max | # enforce min/max | ||||
| ang = max(clamp_dirt, ang) | ang = max(clamp_dirt, ang) | ||||
| Context not available. | |||||
| vert_tone[j] /= len(c) * blur_strength + 1 | vert_tone[j] /= len(c) * blur_strength + 1 | ||||
| del orig_vert_tone | del orig_vert_tone | ||||
| min_tone = min(vert_tone) | if normalize: | ||||
| max_tone = max(vert_tone) | min_tone = min(vert_tone) | ||||
| max_tone = max(vert_tone) | |||||
| else: | |||||
| min_tone = clamp_dirt | |||||
| max_tone = clamp_clean | |||||
| tone_range = max_tone - min_tone | tone_range = max_tone - min_tone | ||||
| Context not available. | |||||
| description="Don't calculate cleans for convex areas", | description="Don't calculate cleans for convex areas", | ||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| normalize: BoolProperty( | |||||
| name="Normalize", | |||||
| description="Normalize the colors, increasing the contrast", | |||||
| default=True, | |||||
| ) | |||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| Context not available. | |||||
| self.dirt_angle, | self.dirt_angle, | ||||
| self.clean_angle, | self.clean_angle, | ||||
| self.dirt_only, | self.dirt_only, | ||||
| self.normalize, | |||||
| ) | ) | ||||
| return ret | return ret | ||||
| Context not available. | |||||