Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-12-22 07:57:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-22 08:41:01 +0300
commita9c881f6a3c15a636f398e9340d8daab290513f7 (patch)
treebf177be1ab98d9d1108b24bc366564034917d60a /source/blender/bmesh
parentee2b583a059777162ce68eaa705481c210805513 (diff)
BMesh: store stackdepth as an index
Avoids -1 all over.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/bmesh_class.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.h14
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c12
4 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 4ffa0bda71a..e3caeedd2c9 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 9036e882b0b..ed1bd16b2e4 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 4f995e08b9c..95c4f710c38 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 5f224813d8d..960ff568e93 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);