[Bf-blender-cvs] [6f62a388dfc] blender-v3.3-release: Sculpt: Support gradient color mode in sculpt paint brush
Ramil Roosileht
noreply at git.blender.org
Wed Aug 3 23:09:16 CEST 2022
Commit: 6f62a388dfcc6244535850f64e8b562d42dffe78
Author: Ramil Roosileht
Date: Wed Aug 3 14:08:23 2022 -0700
Branches: blender-v3.3-release
https://developer.blender.org/rB6f62a388dfcc6244535850f64e8b562d42dffe78
Sculpt: Support gradient color mode in sculpt paint brush
T99614
Support for gradient mode in sculpt paint brush
{F13316165}
Reviewed By: Joseph Eagar & Julian Kaspar
Differential Revision: https://developer.blender.org/D15502
Ref D15502
===================================================================
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_paint_color.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 4b902b7fca9..aa151b2e678 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5353,7 +5353,7 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
static void sculpt_stroke_update_step(bContext *C,
wmOperator *UNUSED(op),
- struct PaintStroke *UNUSED(stroke),
+ struct PaintStroke *stroke,
PointerRNA *itemptr)
{
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
@@ -5362,6 +5362,8 @@ static void sculpt_stroke_update_step(bContext *C,
SculptSession *ss = ob->sculpt;
const Brush *brush = BKE_paint_brush(&sd->paint);
ToolSettings *tool_settings = CTX_data_tool_settings(C);
+ StrokeCache *cache = ss->cache;
+ cache->stroke_distance = paint_stroke_distance_get(stroke);
SCULPT_stroke_modifiers_check(C, ob, brush);
sculpt_update_cache_variants(C, sd, ob, itemptr);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 179e07cc7fa..166504ca8a9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -485,6 +485,7 @@ typedef struct StrokeCache {
float true_last_location[3];
float location[3];
float last_location[3];
+ float stroke_distance;
/* Used for alternating between deformation in brushes that need to apply different ones to
* achieve certain effects. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
index 1a46c542b42..3b65124fe02 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
@@ -17,6 +17,7 @@
#include "DNA_meshdata_types.h"
#include "BKE_brush.h"
+#include "BKE_colorband.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_mesh.h"
@@ -117,11 +118,31 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata,
const int thread_id = BLI_task_parallel_thread_id(tls);
float brush_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+
copy_v3_v3(brush_color,
ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, brush) :
BKE_brush_color_get(ss->scene, brush));
+
IMB_colormanagement_srgb_to_scene_linear_v3(brush_color, brush_color);
+ if (brush->flag & BRUSH_USE_GRADIENT) {
+ switch (brush->gradient_stroke_mode) {
+ case BRUSH_GRADIENT_PRESSURE:
+ BKE_colorband_evaluate(brush->gradient, ss->cache->pressure, brush_color);
+ break;
+ case BRUSH_GRADIENT_SPACING_REPEAT: {
+ float coord = fmod(ss->cache->stroke_distance / brush->gradient_spacing, 1.0);
+ BKE_colorband_evaluate(brush->gradient, coord, brush_color);
+ break;
+ }
+ case BRUSH_GRADIENT_SPACING_CLAMP: {
+ BKE_colorband_evaluate(
+ brush->gradient, ss->cache->stroke_distance / brush->gradient_spacing, brush_color);
+ break;
+ }
+ }
+ }
+
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
SCULPT_orig_vert_data_update(&orig_data, &vd);
More information about the Bf-blender-cvs
mailing list