[Bf-blender-cvs] [171a6bb] master: Fix T42488: Knife (selected_only + occlude) failed

Campbell Barton noreply at git.blender.org
Tue Dec 9 15:53:49 CET 2014


Commit: 171a6bb5dc19655b3b7aee70496849890da1e4e4
Author: Campbell Barton
Date:   Tue Dec 9 15:51:58 2014 +0100
Branches: master
https://developer.blender.org/rB171a6bb5dc19655b3b7aee70496849890da1e4e4

Fix T42488: Knife (selected_only + occlude) failed

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

M	source/blender/blenlib/BLI_ghash.h
M	source/blender/editors/mesh/editmesh_knife.c

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

diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index af26058..8be19d0 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -41,6 +41,7 @@ extern "C" {
 #endif
 
 typedef unsigned int  (*GHashHashFP)     (const void *key);
+/** returns false when equal */
 typedef bool          (*GHashCmpFP)      (const void *a, const void *b);
 typedef void          (*GHashKeyFreeFP)  (void *key);
 typedef void          (*GHashValFreeFP)  (void *val);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 5d60fcc..15ae461 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1383,6 +1383,11 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
 		ls = (BMLoop **)kcd->em->looptris[result->indexA];
 		f = ls[0]->f;
 		set_lowest_face_tri(kcd, f, result->indexA);
+
+		/* occlude but never cut unselected faces (when only_select is used) */
+		if (kcd->only_select && !BM_elem_flag_test(f, BM_ELEM_SELECT)) {
+			continue;
+		}
 		/* for faces, store index of lowest hit looptri in hash */
 		if (BLI_smallhash_haskey(&faces, (uintptr_t)f)) {
 			continue;
@@ -1590,6 +1595,10 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, float co[3], float
 
 	f = BKE_bmbvh_ray_cast(kcd->bmbvh, origin, ray, 0.0f, NULL, co, cageco);
 
+	if (f && kcd->only_select && BM_elem_flag_test(f, BM_ELEM_SELECT) == 0) {
+		f = NULL;
+	}
+
 	if (is_space)
 		*is_space = !f;
 
@@ -2760,10 +2769,11 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
 
 	kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(kcd->em, scene, NULL);
 
-	kcd->bmbvh = BKE_bmbvh_new_from_editmesh(kcd->em,
-	                                         BMBVH_RETURN_ORIG |
-	                                         (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN),
-	                                         kcd->cagecos, false);
+	kcd->bmbvh = BKE_bmbvh_new_from_editmesh(
+	        kcd->em,
+	        BMBVH_RETURN_ORIG |
+	        ((only_select && cut_through) ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN),
+	        kcd->cagecos, false);
 
 	kcd->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), "knife");
 	kcd->vthresh = KMAXDIST - 1;




More information about the Bf-blender-cvs mailing list