diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 24 |
2 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 99676e444f3..b414f36b8c8 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -110,7 +110,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, then goes through the mesh and makes sure all the customdata blocks are consistent with the new layout.*/ void CustomData_bmesh_merge(struct CustomData *source, struct CustomData *dest, - int mask, int alloctype, struct BMesh *bm, int type); + int mask, int alloctype, struct BMesh *bm, const char htype); /* frees data associated with a CustomData object (doesn't free the object * itself, though) @@ -319,7 +319,7 @@ void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int totloop, int totpoly); void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata, int total); void CustomData_bmesh_update_active_layers(struct CustomData *fdata, struct CustomData *pdata, struct CustomData *ldata); -void CustomData_bmesh_init_pool(struct CustomData *data, int allocsize); +void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, const char htype); /* External file storage */ 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: |