Fix #104597: Knife relative angle constaint wrong on rotated objects

The face normal was used in local space whereas it is needed as a global
direction (since other vectors here are in worldspace as well --
knife_input_ray_segment() returns worldspace).

Could go into 3.3 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/108938
This commit is contained in:
Philipp Oeser 2023-06-14 08:58:28 +02:00
parent c99dd96731
commit a7afce347d
1 changed files with 8 additions and 2 deletions

View File

@ -3728,7 +3728,13 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd)
return false;
}
plane_from_point_normal_v3(plane, kcd->prev.cage, fprev->no);
/* Use normal global direction. */
float no_global[3];
copy_v3_v3(no_global, fprev->no);
mul_transposed_mat3_m4_v3(kcd->curr.ob->world_to_object, no_global);
normalize_v3(no_global);
plane_from_point_normal_v3(plane, kcd->prev.cage, no_global);
if (isect_ray_plane_v3(curr_origin, curr_ray_normal, plane, &lambda, false)) {
madd_v3_v3v3fl(ray_hit, curr_origin, curr_ray_normal, lambda);
@ -3750,7 +3756,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd)
/* Maybe check for vectors being zero here? */
sub_v3_v3v3(v1, ray_hit, kcd->prev.cage);
copy_v3_v3(v2, refv);
kcd->angle = snap_v3_angle_plane(rotated_vec, v1, v2, fprev->no, snap_step);
kcd->angle = snap_v3_angle_plane(rotated_vec, v1, v2, no_global, snap_step);
add_v3_v3(rotated_vec, kcd->prev.cage);
knife_project_v2(kcd, rotated_vec, kcd->curr.mval);