[Bf-blender-cvs] [9773709cf1f] soc-2017-normal-tools: Optimised split to faces and fixed preserve_clnor not keeping clnors

Rohan Rathi noreply at git.blender.org
Wed Jul 12 18:04:47 CEST 2017


Commit: 9773709cf1fc53476ddc63abe1756e0584d24fee
Author: Rohan Rathi
Date:   Wed Jul 12 21:34:15 2017 +0530
Branches: soc-2017-normal-tools
https://developer.blender.org/rB9773709cf1fc53476ddc63abe1756e0584d24fee

Optimised split to faces and fixed preserve_clnor not keeping clnors

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

M	source/blender/bmesh/intern/bmesh_mesh.c
M	source/blender/editors/mesh/editmesh_tools.c

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

diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 49b2cec754c..d9f6352d4ad 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -1082,7 +1082,7 @@ void BM_lnorspace_rebuild(BMesh *bm, bool preserve_clnor)
 
 		BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
 			BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
-				if (BM_elem_flag_test(l, BM_ELEM_LNORSPACE))
+				if (BM_elem_flag_test(l, BM_ELEM_LNORSPACE) || bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL)
 				{
 					short(*clnor)[2] = BM_ELEM_CD_GET_VOID_P(l, cd_loop_clnors_offset);
 					int l_index = BM_elem_index_get(l);
@@ -1099,7 +1099,7 @@ void BM_lnorspace_rebuild(BMesh *bm, bool preserve_clnor)
 	BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
 		BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
 
-			if (BM_elem_flag_test(l, BM_ELEM_LNORSPACE)) {
+			if (BM_elem_flag_test(l, BM_ELEM_LNORSPACE) || bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL) {
 
 #if 0
 				short(*clnor)[2] = BM_ELEM_CD_GET_VOID_P(l, cd_loop_clnors_offset);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index d1685f2fe73..780b00441c9 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -6266,6 +6266,7 @@ static int edbm_point_normals_invoke(bContext *C, wmOperator *op, const wmEvent
 
 	ED_area_headerprint(CTX_wm_area(C), header);
 
+	op->flag |= OP_IS_MODAL_GRAB_CURSOR;
 	return OPERATOR_RUNNING_MODAL;
 }
 
@@ -6425,25 +6426,31 @@ static bool split_loop(bContext *C, wmOperator *op, LoopNormalData *ld)
 	BMIter fiter, liter;
 
 	TransDataLoopNormal *tld = ld->normal;
+	void **loops;
 
 	const int type = RNA_enum_get(op->ptr, "split_type");
 
+	if (type == SPLIT_LOOP_TO_FACE) {
+		loops = MEM_mallocN(sizeof(void *) * bm->totloop, "__func__");		/* temp loop index table */
+		BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
+			BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
+				loops[BM_elem_index_get(l)] = l;
+			}
+		}
+	}
+
 	for (int i = 0; i < ld->totloop; i++, tld++) {
 		if (type == SPLIT_LOOP_TO_FACE) {						/* set loop to face normal if split to faces */
-			BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) {
-				if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
-					BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) {
-						if (tld->loop_index == BM_elem_index_get(l)) {
-							BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[tld->loop_index], f->no, tld->clnors_data);
-						}
-					}
-				}
-			}
+			BMLoop *loop_at_index = loops[tld->loop_index];
+			BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[tld->loop_index], loop_at_index->f->no, tld->clnors_data);
 		}
 		else if (type == SPLIT_LOOP_KEEP) {						/* else set to transdata normal computed */
 			BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[tld->loop_index], tld->nloc, tld->clnors_data);
 		}
 	}
+	if (type == SPLIT_LOOP_TO_FACE) {
+		MEM_freeN(loops);
+	}
 	return true;
 }




More information about the Bf-blender-cvs mailing list