Twist Brush: Fix bug in rotation

This commit is contained in:
Pablo Dobarro 2021-06-20 17:53:35 +02:00
parent 178c3a4064
commit 7a67cb2aeb
1 changed files with 11 additions and 4 deletions

View File

@ -5859,8 +5859,13 @@ static void do_twist_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3v3(stroke_line[1], stroke_line[0], stroke_direction);
SculptOrigVertData orig_data;
SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n]);
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
SCULPT_orig_vert_data_update(&orig_data, &vd);
if (!sculpt_brush_test_sq_fn(&test, vd.co)) {
continue;
}
@ -5889,18 +5894,18 @@ static void do_twist_brush_task_cb_ex(void *__restrict userdata,
copy_m4_m4(scaled_mat, mat);
invert_m4(scaled_mat);
mul_v3_fl(scaled_mat[2], 0.5f * fade);
mul_v3_fl(scaled_mat[2], 0.3f * fade);
invert_m4(scaled_mat);
invert_m4_m4(scaled_mat_inv, scaled_mat);
mul_v3_m4v3(local_vert_co, scaled_mat, vd.co);
closest_to_line_v3(vertex_in_line, vd.co, rotation_axis, origin);
closest_to_line_v3(vertex_in_line, local_vert_co, rotation_axis, origin);
float p_to_rotate[3];
sub_v3_v3v3(p_to_rotate, local_vert_co, vertex_in_line);
float p_rotated[3];
rotate_v3_v3v3fl(p_rotated, p_to_rotate, rotation_axis, bstrength * fade);
rotate_v3_v3v3fl(p_rotated, p_to_rotate, rotation_axis, 2.0f * bstrength * fade);
add_v3_v3(p_rotated, vertex_in_line);
mul_v3_m4v3(p_rotated, scaled_mat_inv, p_rotated);
@ -5974,9 +5979,11 @@ static void do_twist_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
return;
}
/*
mul_v3_v3v3(temp, area_no_sp, ss->cache->scale);
mul_v3_fl(temp, displace);
add_v3_v3(area_co, temp);
*/
/* Initialize brush local-space matrix. */
cross_v3_v3v3(mat[0], area_no, ss->cache->grab_delta_symmetry);
@ -5985,7 +5992,7 @@ static void do_twist_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
mat[1][3] = 0.0f;
copy_v3_v3(mat[2], area_no);
mat[2][3] = 0.0f;
copy_v3_v3(mat[3], ss->cache->location);
copy_v3_v3(mat[3], area_co);
mat[3][3] = 1.0f;
normalize_m4(mat);