diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-02 02:17:04 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-02 02:17:04 +0400 |
commit | 921a7556fbc4c66267137b767ce93c85d9b4cbd8 (patch) | |
tree | 7d816ba9696338c219d18ac4d6f7e3b1f536ebf6 /source/blender/blenkernel/intern/customdata.c | |
parent | 2942eab57c9677e87d0830fe5e5da35abb869417 (diff) |
bmesh - changes to mempool allocations
* double default edge allocation size (double the number of verts/faces).
* CustomData_bmesh_init_pool was using allocsize & chunksize as the same variable. Now use type specific chunk size.
* bmesh copy and editmode conversion now allocate the BMesh mempool size needed for the entire vert/edge/loop/face arrays since its known already.
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.c')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 09525e23c6b..a3c4b943215 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2111,19 +2111,33 @@ void CustomData_bmesh_update_active_layers(CustomData *fdata, CustomData *pdata, } } -void CustomData_bmesh_init_pool(CustomData *data, int allocsize) +void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype) { + int chunksize; + /* Dispose old pools before calling here to avoid leaks */ BLI_assert(data->pool == NULL); + switch (htype) { + case BM_VERT: chunksize = 512; break; + case BM_EDGE: chunksize = 1024; break; + case BM_LOOP: chunksize = 2048; break; + case BM_FACE: chunksize = 512; break; + case BM_ALL: chunksize = 512; break; /* use this when its undefined */ + default: + BLI_assert(0); + chunksize = 512; + break; + } + /* If there are no layers, no pool is needed just yet */ if (data->totlayer) { - data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, TRUE, FALSE); + data->pool = BLI_mempool_create(data->totsize, totelem, chunksize, TRUE, FALSE); } } void CustomData_bmesh_merge(CustomData *source, CustomData *dest, - int mask, int alloctype, BMesh *bm, int type) + int mask, int alloctype, BMesh *bm, const char htype) { BMHeader *h; BMIter iter; @@ -2132,9 +2146,9 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest, int t; CustomData_merge(source, dest, mask, alloctype, 0); - CustomData_bmesh_init_pool(dest, 512); + CustomData_bmesh_init_pool(dest, 512, htype); - switch (type) { + switch (htype) { case BM_VERT: t = BM_VERTS_OF_MESH; break; case BM_EDGE: |