Fix T98745: Anchored mode not working for sculpt smear brush

This commit is contained in:
Joseph Eagar 2022-06-12 12:30:46 -07:00
parent afe57c4001
commit c55dac9904
Notes: blender-bot 2023-02-14 00:09:06 +01:00
Referenced by issue #99231, Regression: Sculpt Mode Smear Brush broken
Referenced by issue #98745, Sculpt Paint - Crash when using Smear with Anchored stroke
Referenced by issue #98661, 3.2: Potential candidates for corrective releases
2 changed files with 17 additions and 8 deletions

View File

@ -4343,7 +4343,8 @@ static bool sculpt_needs_delta_from_anchored_origin(Brush *brush)
SCULPT_TOOL_POSE,
SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ELASTIC_DEFORM)) {
SCULPT_TOOL_ELASTIC_DEFORM,
SCULPT_TOOL_SMEAR)) {
return true;
}
if (brush->sculpt_tool == SCULPT_TOOL_CLOTH &&
@ -4392,6 +4393,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
SCULPT_TOOL_SNAKE_HOOK,
SCULPT_TOOL_POSE,
SCULPT_TOOL_BOUNDARY,
SCULPT_TOOL_SMEAR,
SCULPT_TOOL_THUMB) &&
!sculpt_brush_use_topology_rake(ss, brush)) {
return;

View File

@ -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);
@ -529,12 +538,10 @@ void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
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]);
}
}