diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_paint_color.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_paint_color.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index ac05652b058..7e813590e21 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -111,7 +111,7 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata, PBVHColorBufferNode *color_buffer; SculptOrigVertData orig_data; - SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]); + SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COLOR); color_buffer = BKE_pbvh_node_color_buffer_get(data->nodes[n]); @@ -380,6 +380,15 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata, ss, &test, data->brush->falloff_shape); const int thread_id = BLI_task_parallel_thread_id(tls); + float brush_delta[3]; + + if (brush->flag & BRUSH_ANCHORED) { + copy_v3_v3(brush_delta, ss->cache->grab_delta_symmetry); + } + else { + sub_v3_v3v3(brush_delta, ss->cache->location, ss->cache->last_location); + } + BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { if (!sculpt_brush_test_sq_fn(&test, vd.co)) { continue; @@ -404,7 +413,7 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata, switch (brush->smear_deform_type) { case BRUSH_SMEAR_DEFORM_DRAG: - sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location); + copy_v3_v3(current_disp, brush_delta); break; case BRUSH_SMEAR_DEFORM_PINCH: sub_v3_v3v3(current_disp, ss->cache->location, vd.co); @@ -418,7 +427,7 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata, madd_v3_v3fl(current_disp, no, -dot_v3v3(current_disp, no)); normalize_v3_v3(current_disp_norm, current_disp); - mul_v3_v3fl(current_disp, current_disp_norm, ss->cache->bstrength); + mul_v3_v3fl(current_disp, current_disp_norm, bstrength); float accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float totw = 0.0f; @@ -448,12 +457,12 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata, sub_v3_v3v3(vertex_disp, SCULPT_vertex_co_get(ss, ni.index), vd.co); /* Weight by how close we are to our target distance from vd.co. */ - float w = (1.0f + fabsf(len_v3(vertex_disp) / ss->cache->bstrength - 1.0f)); + float w = (1.0f + fabsf(len_v3(vertex_disp) / bstrength - 1.0f)); /* TODO: use cotangents (or at least face areas) here. */ float len = len_v3v3(SCULPT_vertex_co_get(ss, ni.index), nco); if (len > 0.0f) { - len = ss->cache->bstrength / len; + len = bstrength / len; } else { /* Coincident point. */ len = 1.0f; @@ -523,18 +532,16 @@ void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; - if (!SCULPT_has_colors(ss)) { + if (!SCULPT_has_colors(ss) || ss->cache->bstrength == 0.0f) { return; } const int totvert = SCULPT_vertex_count_get(ss); - if (SCULPT_stroke_is_first_brush_step(ss->cache)) { - if (!ss->cache->prev_colors) { - ss->cache->prev_colors = MEM_callocN(sizeof(float[4]) * totvert, "prev colors"); - for (int i = 0; i < totvert; i++) { - SCULPT_vertex_color_get(ss, i, ss->cache->prev_colors[i]); - } + if (!ss->cache->prev_colors) { + ss->cache->prev_colors = MEM_callocN(sizeof(float[4]) * totvert, "prev colors"); + for (int i = 0; i < totvert; i++) { + SCULPT_vertex_color_get(ss, i, ss->cache->prev_colors[i]); } } |