diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-28 06:07:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-28 06:07:54 +0400 |
commit | 27df6a3b546bf4188b0f29bcb90df201a6730574 (patch) | |
tree | 2669a91593815f28dd15177ef6620778d5259909 /source/blender/blenkernel/intern/editmesh.c | |
parent | 4d2b50ad74f29a4a22eb8a3376552430b2c0666d (diff) |
scanfill curves, ngons, masks had their own memarena code and would allocate a new one for every fill.
now use BLI_memarena and support passing the arena into the fill function, so the arena is re-used, when scanfill is called in a loop.
Diffstat (limited to 'source/blender/blenkernel/intern/editmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/editmesh.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index 74cd8834d5d..6a89d16d7bf 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -36,6 +36,7 @@ #include "DNA_mesh_types.h" #include "BLI_math.h" +#include "BLI_memarena.h" #include "BLI_scanfill.h" #include "BKE_editmesh.h" @@ -123,6 +124,7 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em) int i = 0; ScanFillContext sf_ctx; + MemArena *sf_arena = NULL; #if 0 /* note, we could be clever and re-use this array but would need to ensure @@ -217,7 +219,11 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em) ScanFillFace *sf_tri; int totfilltri; - BLI_scanfill_begin(&sf_ctx); + if (UNLIKELY(sf_arena == NULL)) { + sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__); + } + + BLI_scanfill_begin_arena(&sf_ctx, sf_arena); /* scanfill time */ j = 0; @@ -262,10 +268,15 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em) l_ptr[2] = l3; } - BLI_scanfill_end(&sf_ctx); + BLI_scanfill_end_arena(&sf_ctx, sf_arena); } } + if (sf_arena) { + BLI_memarena_free(sf_arena); + sf_arena = NULL; + } + em->tottri = i; em->looptris = looptris; |