diff options
author | Geoffrey Bantle <hairbat@yahoo.com> | 2008-06-01 21:15:03 +0400 |
---|---|---|
committer | Geoffrey Bantle <hairbat@yahoo.com> | 2008-06-01 21:15:03 +0400 |
commit | 07b1608fbe52f729eae39c307060f92948aabf37 (patch) | |
tree | 96dcc1dde0038151362edfa437c843d042653e0d /source/blender/blenkernel/BKE_bmesh.h | |
parent | 652ee1e31baa52c8e504bfcf3759ea94c7f5ab66 (diff) |
-> New memory allocator for Bmesh
Added a new pooling allocator for Bmesh based upon
the pool allocator availible in the Boost C++ library
as described here:
http://www.boost.org/doc/libs/1_34_0/libs/pool/doc/concepts.html
Each pool allocates elements of a fixed size, so every
element type in a mesh gets its own pool. For instance
verts occupy a different pool than edges. Each pool
is comprised of multiple arrays of a fixed size and allocating
/freeing elements is simple as removing or adding a head
to a linked list. Since the list of free elements is interleaved
throughout the unused space in the arrays, the overhead
for storing the free list is only 1 pointer total per pool.
This makes building/destroying bmesh structures much faster
and saves quite a bit of memory as well.
Diffstat (limited to 'source/blender/blenkernel/BKE_bmesh.h')
-rw-r--r-- | source/blender/blenkernel/BKE_bmesh.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h index 08ad8192688..87202ce047a 100644 --- a/source/blender/blenkernel/BKE_bmesh.h +++ b/source/blender/blenkernel/BKE_bmesh.h @@ -50,6 +50,9 @@ struct BME_Edge; struct BME_Poly; struct BME_Loop; +struct BME_mempool; +typedef struct BME_mempool BME_mempool; + typedef struct BME_CycleNode{ struct BME_CycleNode *next, *prev; void *data; @@ -57,16 +60,21 @@ typedef struct BME_CycleNode{ typedef struct BME_Mesh { - ListBase verts, edges, polys, loops; - int totvert, totedge, totpoly, totloop; /*record keeping*/ - int nextv, nexte, nextp, nextl; /*Next element ID for verts/edges/faces/loops. Never reused*/ - struct CustomData vdata, edata, pdata, ldata; /*Custom Data Layer information*/ + ListBase verts, edges, polys; + /*memory pools used for storing mesh elements*/ + struct BME_mempool *vpool; + struct BME_mempool *epool; + struct BME_mempool *ppool; + struct BME_mempool *lpool; /*some scratch arrays used by eulers*/ struct BME_Vert **vtar; struct BME_Edge **edar; struct BME_Loop **lpar; struct BME_Poly **plar; int vtarlen, edarlen, lparlen, plarlen; + int totvert, totedge, totpoly, totloop; /*record keeping*/ + int nextv, nexte, nextp, nextl; /*Next element ID for verts/edges/faces/loops. Never reused*/ + //struct CustomData vdata, edata, pdata, ldata; /*Custom Data Layer information*/ } BME_Mesh; typedef struct BME_Vert @@ -102,7 +110,6 @@ typedef struct BME_Loop struct BME_Loop *next, *prev; /*circularly linked list around face*/ int EID; struct BME_CycleNode radial; /*circularly linked list used to find faces around an edge*/ - struct BME_CycleNode *gref; /*pointer to loop ref. Nasty.*/ struct BME_Vert *v; /*vertex that this loop starts at.*/ struct BME_Edge *e; /*edge this loop belongs to*/ struct BME_Poly *f; /*face this loop belongs to*/ @@ -146,7 +153,7 @@ int BME_radial_find_face(struct BME_Edge *e,struct BME_Poly *f); struct BME_Loop *BME_loop_find_loop(struct BME_Poly *f, struct BME_Vert *v); /*MESH CREATION/DESTRUCTION*/ -struct BME_Mesh *BME_make_mesh(void); +struct BME_Mesh *BME_make_mesh(int valloc, int ealloc, int lalloc, int palloc); void BME_free_mesh(struct BME_Mesh *bm); /*FULL MESH VALIDATION*/ int BME_validate_mesh(struct BME_Mesh *bm, int halt); |