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>2012-03-02 02:17:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-02 02:17:04 +0400
commit921a7556fbc4c66267137b767ce93c85d9b4cbd8 (patch)
tree7d816ba9696338c219d18ac4d6f7e3b1f536ebf6 /source/blender/blenkernel
parent2942eab57c9677e87d0830fe5e5da35abb869417 (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')
-rw-r--r--source/blender/blenkernel/BKE_customdata.h4
-rw-r--r--source/blender/blenkernel/intern/customdata.c24
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: