Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_paint_color.c21
3 files changed, 25 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 17acf8d884e..8df5b093560 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5388,7 +5388,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;
@@ -5397,6 +5397,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 86f89c3c2fa..6a10f7cad18 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -489,6 +489,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 cb178b23008..c494c71f1eb 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);