diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-23 19:32:53 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-23 19:33:11 +0300 |
commit | 2eba15d3e862fdf112edda6b26b7e1535f0fdb07 (patch) | |
tree | b67e797668e14ea9c6a50bcca1aea41b7bdda730 /release | |
parent | 5c6ffd07e0de8f4917927da69a68db9af205973d (diff) |
Fix T98975: Broken vertex paint mode operators
All of the operators in vertex paint mode didn't work properly with
the new color attribute system. They only worked on byte color type
attributes on the face corner domain.
Since there are four possible combinations of domains and types now,
it mostly ended up being simpler to convert the code to C++ and use
the geometry component API for retrieving attributes, interpolating
between domains, etc. The code changes ended up being fairly large,
but the result should be simpler now.
Differential Revision: https://developer.blender.org/D15261
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_operators/vertexpaint_dirt.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index a3c0b73fc0e..fc14879cf18 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -2,15 +2,10 @@ # Copyright Campbell Barton. -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 ensure_active_color_attribute(me): + if me.attributes.active_color: + return me.attributes.active_color + return me.color_attributes.new("Color", 'BYTE_COLOR', 'FACE_CORNER') def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only, normalize): from mathutils import Vector @@ -99,17 +94,21 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, else: tone_range = 1.0 / tone_range - active_col_layer = get_vcolor_layer_data(me) - if not active_col_layer: + active_color_attribute = ensure_active_color_attribute(me) + if not active_color_attribute: return {'CANCELLED'} + point_domain = active_color_attribute.domain == 'POINT' + + attribute_data = active_color_attribute.data + 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: loop = me.loops[loop_index] v = loop.vertex_index - col = active_col_layer[loop_index].color + col = attribute_data[v if point_domain else loop_index].color tone = vert_tone[v] tone = (tone - min_tone) * tone_range |