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
This commit is contained in:
Ramil Roosileht 2022-08-03 14:08:23 -07:00 committed by Joseph Eagar
parent 9d7aac6d66
commit a217e56575
Notes: blender-bot 2023-02-14 02:30:11 +01:00
Referenced by issue #99614, Sculpt Mode: Color Picker Gradient
3 changed files with 25 additions and 1 deletions

View File

@ -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);

View File

@ -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. */

View File

@ -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);