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>2013-01-07 19:35:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-07 19:35:20 +0400
commit12d921eb5b438473cf1cbf287d3f7640cad32f40 (patch)
treece724d71ffc99a8523743cb1660fb62fccc147e1 /source/blender/blenkernel/intern/customdata.c
parent6f381db60e86ec17f4d84eb2b35d47dba3ed62e3 (diff)
minor improvement to CustomData_bmesh_merge(), allocate the correct size pool rather then always 512.
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.c')
-rw-r--r--source/blender/blenkernel/intern/customdata.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 0f352dede23..832c1979a51 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2298,34 +2298,45 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
BMIter iter;
CustomData destold;
void *tmp;
- int t;
+ int iter_type;
+ int totelem;
/* copy old layer description so that old data can be copied into
* the new allocation */
destold = *dest;
- if (destold.layers) destold.layers = MEM_dupallocN(destold.layers);
-
- CustomData_merge(source, dest, mask, alloctype, 0);
- dest->pool = NULL;
- CustomData_bmesh_init_pool(dest, 512, htype);
+ if (destold.layers) {
+ destold.layers = MEM_dupallocN(destold.layers);
+ }
switch (htype) {
case BM_VERT:
- t = BM_VERTS_OF_MESH; break;
+ iter_type = BM_VERTS_OF_MESH;
+ totelem = bm->totvert;
+ break;
case BM_EDGE:
- t = BM_EDGES_OF_MESH; break;
+ iter_type = BM_EDGES_OF_MESH;
+ totelem = bm->totedge;
+ break;
case BM_LOOP:
- t = BM_LOOPS_OF_FACE; break;
+ iter_type = BM_LOOPS_OF_FACE;
+ totelem = bm->totloop;
+ break;
case BM_FACE:
- t = BM_FACES_OF_MESH; break;
+ iter_type = BM_FACES_OF_MESH;
+ totelem = bm->totface;
+ break;
default: /* should never happen */
BLI_assert(!"invalid type given");
- t = BM_VERTS_OF_MESH;
+ iter_type = BM_VERTS_OF_MESH;
}
- if (t != BM_LOOPS_OF_FACE) {
+ CustomData_merge(source, dest, mask, alloctype, 0);
+ dest->pool = NULL;
+ CustomData_bmesh_init_pool(dest, totelem, htype);
+
+ if (iter_type != BM_LOOPS_OF_FACE) {
/*ensure all current elements follow new customdata layout*/
- BM_ITER_MESH (h, &iter, bm, t) {
+ BM_ITER_MESH (h, &iter, bm, iter_type) {
tmp = NULL;
CustomData_bmesh_copy_data(&destold, dest, h->data, &tmp);
CustomData_bmesh_free_block(&destold, &h->data);