From a7afce347d67da16aef1c05029fa7f64ec7c6c3d Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 14 Jun 2023 08:58:28 +0200 Subject: [PATCH] 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 --- source/blender/editors/mesh/editmesh_knife.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index b7a7067bc03..d668fd66fe3 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -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);