[Bf-blender-cvs] [ba31468] master: Fix T41849: Knife fails with small lens

Campbell Barton noreply at git.blender.org
Tue Sep 16 16:35:29 CEST 2014


Commit: ba314683fb81ac402d5e925b5770bd2060ba739c
Author: Campbell Barton
Date:   Tue Sep 16 22:59:02 2014 +1000
Branches: master
https://developer.blender.org/rBba314683fb81ac402d5e925b5770bd2060ba739c

Fix T41849: Knife fails with small lens

knife cursor depth could be projected behind the view with a wide angle lens.

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

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 30d8918..07dc1b0 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -183,6 +183,8 @@ typedef struct KnifeTool_OpData {
 
 	float projmat[4][4];
 	float projmat_inv[4][4];
+	/* vector along view z axis (object space, normalized) */
+	float proj_zaxis[3];
 
 	KnifeColors colors;
 
@@ -1921,8 +1923,12 @@ static int knife_update_active(KnifeTool_OpData *kcd)
 
 		knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs);
 
-		closest_to_line_v3(kcd->curr.cage, kcd->prev.cage, origin_ofs, origin);
-		copy_v3_v3(kcd->curr.co, kcd->curr.cage);
+		if (!isect_line_plane_v3(kcd->curr.cage, origin, origin_ofs, kcd->prev.cage, kcd->proj_zaxis)) {
+			copy_v3_v3(kcd->curr.cage, kcd->prev.cage);
+
+			/* should never fail! */
+			BLI_assert(0);
+		}
 	}
 
 	if (kcd->mode == MODE_DRAGGING) {
@@ -2621,6 +2627,10 @@ static void knife_recalc_projmat(KnifeTool_OpData *kcd)
 	ED_view3d_ob_project_mat_get(kcd->ar->regiondata, kcd->ob, kcd->projmat);
 	invert_m4_m4(kcd->projmat_inv, kcd->projmat);
 
+	copy_v3_v3(kcd->proj_zaxis, kcd->vc.rv3d->viewinv[2]);
+	mul_mat3_m4_v3(kcd->ob->imat, kcd->proj_zaxis);
+	normalize_v3(kcd->proj_zaxis);
+
 	kcd->is_ortho = ED_view3d_clip_range_get(kcd->vc.v3d, kcd->vc.rv3d,
 	                                         &kcd->clipsta, &kcd->clipend, true);
 }




More information about the Bf-blender-cvs mailing list