[Bf-blender-cvs] [0d4cb03d1b9] soc-2021-knife-tools: Fix: Knife local angle snapping broken on rotated objects

Cian Jinks noreply at git.blender.org
Thu Aug 12 13:10:46 CEST 2021


Commit: 0d4cb03d1b950d41a45f2dcbf03568040a73878b
Author: Cian Jinks
Date:   Thu Aug 12 12:09:47 2021 +0100
Branches: soc-2021-knife-tools
https://developer.blender.org/rB0d4cb03d1b950d41a45f2dcbf03568040a73878b

Fix: Knife local angle snapping broken on rotated objects

World space calculations that were added for the Knife BVH support broke local angle snapping on rotated objects.

===================================================================

M	source/blender/editors/mesh/editmesh_knife.c

===================================================================

diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 4124c58704c..89a03dbe579 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1361,6 +1361,7 @@ static BMFace *knife_bvh_raycast(KnifeTool_OpData *kcd,
 
     face = kcd->bvh.looptris[hit.index][0]->f;
 
+    /* Hits returned in object space. */
     if (r_hitout) {
       ltri = kcd->bvh.looptris[hit.index];
       interp_v3_v3v3v3_uv(r_hitout, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co, kcd->bvh.uv);
@@ -1422,6 +1423,7 @@ static BMFace *knife_bvh_raycast_filter(
 
     face = kcd->bvh.looptris[hit.index][0]->f;
 
+    /* Hits returned in object space. */
     if (r_hitout) {
       ltri = kcd->bvh.looptris[hit.index];
       interp_v3_v3v3v3_uv(r_hitout, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co, kcd->bvh.uv);
@@ -3676,6 +3678,11 @@ static bool knife_snap_angle_local(KnifeTool_OpData *kcd)
     return false;
   }
 
+  /* Re-calculate current ray in object space. */
+  knife_input_ray_segment_object(kcd, kcd->curr.mval, 1.0f, curr_origin, curr_origin_ofs);
+  sub_v3_v3v3(curr_ray, curr_origin_ofs, curr_origin);
+  normalize_v3_v3(curr_ray_normal, curr_ray);
+
   plane_from_point_normal_v3(plane, kcd->prev.cage, fprev->no);
 
   if (isect_ray_plane_v3(curr_origin, curr_ray_normal, plane, &lambda, false)) {



More information about the Bf-blender-cvs mailing list