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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-05-26 01:24:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-26 01:24:09 +0400
commitb7c36b95116bfcf4501d786ca075c3f7941d998c (patch)
tree65768c2ea931e5c2f729d4a0a0b295abbc467f14 /source
parentb2f1720d41a897e76229305b98b9810670ef64a8 (diff)
bmesh: replace array reallocation with a single face array and use STACK macros.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/mesh/editmesh_select.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 8eee6bcf6da..e2fc91198a3 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -3108,32 +3108,31 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ BMesh *bm = em->bm;
+
+ BMFace **stack = MEM_mallocN(sizeof(BMFace *) * bm->totface, __func__);
+ STACK_DECLARE(stack);
+
BMIter iter, liter, liter2;
- BMFace *f, **stack = NULL;
- BLI_array_declare(stack);
+ BMFace *f;
BMLoop *l, *l2;
- const float sharp = RNA_float_get(op->ptr, "sharpness");
- int i;
+ const float angle_limit = RNA_float_get(op->ptr, "sharpness");
- BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- BM_elem_flag_disable(f, BM_ELEM_TAG);
- }
+ BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false);
- BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_HIDDEN) || !BM_elem_flag_test(f, BM_ELEM_SELECT) || BM_elem_flag_test(f, BM_ELEM_TAG))
- continue;
- BLI_array_empty(stack);
- i = 1;
-
- BLI_array_grow_one(stack);
- stack[i - 1] = f;
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if ((BM_elem_flag_test(f, BM_ELEM_HIDDEN) != 0) ||
+ (BM_elem_flag_test(f, BM_ELEM_TAG) != 0) ||
+ (BM_elem_flag_test(f, BM_ELEM_SELECT) == 0))
+ {
+ continue;
+ }
- while (i) {
- f = stack[i - 1];
- i--;
+ STACK_INIT(stack);
- BM_face_select_set(em->bm, f, true);
+ do {
+ BM_face_select_set(bm, f, true);
BM_elem_flag_enable(f, BM_ELEM_TAG);
@@ -3141,24 +3140,25 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
BM_ITER_ELEM (l2, &liter2, l, BM_LOOPS_OF_LOOP) {
float angle;
- if (BM_elem_flag_test(l2->f, BM_ELEM_TAG) || BM_elem_flag_test(l2->f, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(l2->f, BM_ELEM_TAG) ||
+ BM_elem_flag_test(l2->f, BM_ELEM_HIDDEN))
+ {
continue;
+ }
- /* edge has exactly two neighboring faces, check angle */
angle = angle_normalized_v3v3(f->no, l2->f->no);
- /* invalidate: edge too sharp */
- if (angle < sharp) {
- BLI_array_grow_one(stack);
- stack[i] = l2->f;
- i++;
+ if (angle < angle_limit) {
+ STACK_PUSH(stack, l2->f);
}
}
}
- }
+ } while ((f = STACK_POP(stack)));
}
- BLI_array_free(stack);
+ STACK_FREE(stack);
+
+ MEM_freeN(stack);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);