[Bf-blender-cvs] [a9c881f] master: BMesh: store stackdepth as an index

Campbell Barton noreply at git.blender.org
Tue Dec 22 06:49:48 CET 2015


Commit: a9c881f6a3c15a636f398e9340d8daab290513f7
Author: Campbell Barton
Date:   Tue Dec 22 15:57:45 2015 +1100
Branches: master
https://developer.blender.org/rBa9c881f6a3c15a636f398e9340d8daab290513f7

BMesh: store stackdepth as an index

Avoids -1 all over.

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

M	source/blender/bmesh/bmesh_class.h
M	source/blender/bmesh/intern/bmesh_mesh.c
M	source/blender/bmesh/intern/bmesh_operator_api_inline.h
M	source/blender/bmesh/intern/bmesh_operators.c

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

diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 4ffa0bd..e3caeed 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -217,7 +217,7 @@ typedef struct BMesh {
 	/* operator api stuff (must be all NULL or all alloc'd) */
 	struct BLI_mempool *vtoolflagpool, *etoolflagpool, *ftoolflagpool;
 
-	int stackdepth;
+	int toolflag_index;
 	struct BMOperator *currentop;
 	
 	CustomData vdata, edata, ldata, pdata;
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 9036e88..ed1bd16 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -143,7 +143,7 @@ BMesh *BM_mesh_create(const BMAllocTemplate *allocsize)
 	bm_mempool_init(bm, allocsize);
 
 	/* allocate one flag pool that we don't get rid of. */
-	bm->stackdepth = 1;
+	bm->toolflag_index = 0;
 	bm->totflags = 0;
 
 	CustomData_reset(&bm->vdata);
@@ -246,7 +246,7 @@ void BM_mesh_clear(BMesh *bm)
 	/* allocate the memory pools for the mesh elements */
 	bm_mempool_init(bm, &bm_mesh_allocsize_default);
 
-	bm->stackdepth = 1;
+	bm->toolflag_index = 0;
 	bm->totflags = 0;
 
 	CustomData_reset(&bm->vdata);
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
index 4f995e0..95c4f71 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h
@@ -41,38 +41,38 @@
 ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2)
 BLI_INLINE short _bmo_elem_flag_test(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
-	return oflags[bm->stackdepth - 1].f & oflag;
+	return oflags[bm->toolflag_index].f & oflag;
 }
 
 ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2)
 BLI_INLINE bool _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
-	return (oflags[bm->stackdepth - 1].f & oflag) != 0;
+	return (oflags[bm->toolflag_index].f & oflag) != 0;
 }
 
 ATTR_NONNULL(1, 2)
 BLI_INLINE void _bmo_elem_flag_enable(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
-	oflags[bm->stackdepth - 1].f |= oflag;
+	oflags[bm->toolflag_index].f |= oflag;
 }
 
 ATTR_NONNULL(1, 2)
 BLI_INLINE void _bmo_elem_flag_disable(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
-	oflags[bm->stackdepth - 1].f &= (short)~oflag;
+	oflags[bm->toolflag_index].f &= (short)~oflag;
 }
 
 ATTR_NONNULL(1, 2)
 BLI_INLINE void _bmo_elem_flag_set(BMesh *bm, BMFlagLayer *oflags, const short oflag, int val)
 {
-	if (val) oflags[bm->stackdepth - 1].f |= oflag;
-	else     oflags[bm->stackdepth - 1].f &= (short)~oflag;
+	if (val) oflags[bm->toolflag_index].f |= oflag;
+	else     oflags[bm->toolflag_index].f &= (short)~oflag;
 }
 
 ATTR_NONNULL(1, 2)
 BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
-	oflags[bm->stackdepth - 1].f ^= oflag;
+	oflags[bm->toolflag_index].f ^= oflag;
 }
 
 ATTR_NONNULL(1, 2)
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 5f22481..960ff56 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -97,12 +97,12 @@ void BMO_op_flag_disable(BMesh *UNUSED(bm), BMOperator *op, const int op_flag)
  */
 void BMO_push(BMesh *bm, BMOperator *UNUSED(op))
 {
-	bm->stackdepth++;
+	bm->toolflag_index++;
 
 	BLI_assert(bm->totflags > 0);
 
 	/* add flag layer, if appropriate */
-	if (bm->stackdepth > 1)
+	if (bm->toolflag_index > 0)
 		bmo_flag_layer_alloc(bm);
 	else
 		bmo_flag_layer_clear(bm);
@@ -117,10 +117,10 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op))
  */
 void BMO_pop(BMesh *bm)
 {
-	if (bm->stackdepth > 1)
+	if (bm->toolflag_index > 0)
 		bmo_flag_layer_free(bm);
 
-	bm->stackdepth--;
+	bm->toolflag_index--;
 }
 
 
@@ -214,11 +214,11 @@ void BMO_op_exec(BMesh *bm, BMOperator *op)
 
 	BMO_push(bm, op);
 
-	if (bm->stackdepth == 2)
+	if (bm->toolflag_index == 1)
 		bmesh_edit_begin(bm, op->type_flag);
 	op->exec(bm, op);
 	
-	if (bm->stackdepth == 2)
+	if (bm->toolflag_index == 1)
 		bmesh_edit_end(bm, op->type_flag);
 	
 	BMO_pop(bm);




More information about the Bf-blender-cvs mailing list