From f8fc28bea914678ede7a0e524ffaa98dc5313041 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 3 Jul 2024 14:04:35 -0400 Subject: [PATCH] Refactor: Sculpt: Add API function for accessing original color data --- .../blender/editors/sculpt_paint/sculpt_filter_color.cc | 9 ++++----- source/blender/editors/sculpt_paint/sculpt_intern.hh | 3 +++ source/blender/editors/sculpt_paint/sculpt_undo.cc | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc index 7e015e69762..3c8c27e2123 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc @@ -89,7 +89,7 @@ static void color_filter_task(Object &ob, { SculptSession &ss = *ob.sculpt; - SculptOrigVertData orig_data = SCULPT_orig_vert_data_init(ob, *node, undo::Type::Color); + const Span orig_colors = orig_color_data_get_mesh(ob, *node); auto_mask::NodeData automask_data = auto_mask::node_begin( ob, ss.filter_cache->automasking.get(), *node); @@ -101,7 +101,6 @@ static void color_filter_task(Object &ob, if (!hide_vert.is_empty() && hide_vert[vert]) { continue; } - SCULPT_orig_vert_data_update(orig_data, i); auto_mask::node_update(automask_data, i); float3 orig_color; @@ -117,8 +116,8 @@ static void color_filter_task(Object &ob, continue; } - copy_v3_v3(orig_color, orig_data.col); - final_color[3] = orig_data.col[3]; /* Copy alpha */ + copy_v3_v3(orig_color, orig_colors[i]); + final_color[3] = orig_colors[i][3]; /* Copy alpha */ switch (mode) { case COLOR_FILTER_FILL: { @@ -127,7 +126,7 @@ static void color_filter_task(Object &ob, fill_color_rgba[3] = 1.0f; fade = clamp_f(fade, 0.0f, 1.0f); mul_v4_fl(fill_color_rgba, fade); - blend_color_mix_float(final_color, orig_data.col, fill_color_rgba); + blend_color_mix_float(final_color, orig_colors[i], fill_color_rgba); break; } case COLOR_FILTER_HUE: diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.hh b/source/blender/editors/sculpt_paint/sculpt_intern.hh index 799ef0806ec..fd4bd01a11d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/sculpt_intern.hh @@ -1650,6 +1650,9 @@ void orig_position_data_gather_bmesh(const BMLog &bm_log, const Set &verts, MutableSpan positions, MutableSpan normals); + +Span orig_color_data_get_mesh(const Object &object, const PBVHNode &node); + } /** \} */ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index 1766193142a..4278ca2494d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -2146,4 +2146,10 @@ void orig_position_data_gather_bmesh(const BMLog &bm_log, } } +Span orig_color_data_get_mesh(const Object & /*object*/, const PBVHNode &node) +{ + const undo::Node *unode = undo::get_node(&node, undo::Type::Color); + return unode->col.as_span(); +} + } // namespace blender::ed::sculpt_paint