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 00:09:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-02 00:09:17 +0400
commit9aafe32147064a41aa653a95c89b50d9585ab3c1 (patch)
tree8d3f000b54f9adf3245548cb4586973ea5f3ec22 /source/blender/bmesh/intern
parentd534f0e16dfdf3ed2a3360ad9f317a258cd8cc8e (diff)
bmmesh api - use struct rather than int[4] to initialize mesh sizes.
also correct bad assert() in previous commit.
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c10
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c16
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.h10
-rw-r--r--source/blender/bmesh/intern/bmesh_operator_api_inline.c22
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers.c3
5 files changed, 29 insertions, 32 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 7ff8fd0b7f4..a0fd3ec9250 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -589,17 +589,17 @@ BMesh *BM_mesh_copy(BMesh *bmold)
int i, j;
/* allocate a bmesh */
- bm = BM_mesh_create(bmold->ob, bm_mesh_allocsize_default);
+ bm = BM_mesh_create(bmold->ob, &bm_mesh_allocsize_default);
CustomData_copy(&bmold->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bmold->edata, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bmold->ldata, &bm->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
CustomData_copy(&bmold->pdata, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_bmesh_init_pool(&bm->vdata, bm_mesh_allocsize_default[0]);
- CustomData_bmesh_init_pool(&bm->edata, bm_mesh_allocsize_default[1]);
- CustomData_bmesh_init_pool(&bm->ldata, bm_mesh_allocsize_default[2]);
- CustomData_bmesh_init_pool(&bm->pdata, bm_mesh_allocsize_default[3]);
+ CustomData_bmesh_init_pool(&bm->vdata, bm_mesh_allocsize_default.totvert);
+ CustomData_bmesh_init_pool(&bm->edata, bm_mesh_allocsize_default.totedge);
+ CustomData_bmesh_init_pool(&bm->ldata, bm_mesh_allocsize_default.totloop);
+ CustomData_bmesh_init_pool(&bm->pdata, bm_mesh_allocsize_default.totface);
vtable = MEM_mallocN(sizeof(BMVert *) * bmold->totvert, "BM_mesh_copy vtable");
etable = MEM_mallocN(sizeof(BMEdge *) * bmold->totedge, "BM_mesh_copy etable");
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 98436640b11..8778dad421f 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -44,14 +44,14 @@
#include "bmesh_private.h"
/* used as an extern, defined in bmesh.h */
-int bm_mesh_allocsize_default[4] = {512, 512, 2048, 512};
+BMAllocTemplate bm_mesh_allocsize_default = {512, 512, 2048, 512};
-static void bm_mempool_init(BMesh *bm, const int allocsize[4])
+static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize)
{
- bm->vpool = BLI_mempool_create(sizeof(BMVert), allocsize[0], allocsize[0], FALSE, TRUE);
- bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize[1], allocsize[1], FALSE, TRUE);
- bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize[2], allocsize[2], FALSE, FALSE);
- bm->fpool = BLI_mempool_create(sizeof(BMFace), allocsize[3], allocsize[3], FALSE, TRUE);
+ bm->vpool = BLI_mempool_create(sizeof(BMVert), allocsize->totvert, allocsize->totvert, FALSE, TRUE);
+ bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize->totedge, allocsize->totedge, FALSE, TRUE);
+ bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize->totloop, allocsize->totloop, FALSE, FALSE);
+ bm->fpool = BLI_mempool_create(sizeof(BMFace), allocsize->totface, allocsize->totface, FALSE, TRUE);
#ifdef USE_BMESH_HOLES
bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), allocsize[3], allocsize[3], FALSE, FALSE);
@@ -70,7 +70,7 @@ static void bm_mempool_init(BMesh *bm, const int allocsize[4])
*
* \note ob is needed by multires
*/
-BMesh *BM_mesh_create(struct Object *ob, const int allocsize[4])
+BMesh *BM_mesh_create(struct Object *ob, BMAllocTemplate *allocsize)
{
/* allocate the structure */
BMesh *bm = MEM_callocN(sizeof(BMesh), __func__);
@@ -173,7 +173,7 @@ void BM_mesh_clear(BMesh *bm)
bm->ob = ob;
/* allocate the memory pools for the mesh elements */
- bm_mempool_init(bm, bm_mesh_allocsize_default);
+ bm_mempool_init(bm, &bm_mesh_allocsize_default);
bm->stackdepth = 1;
bm->totflags = 1;
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index 373b530894a..ea80696a855 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -27,7 +27,9 @@
* \ingroup bmesh
*/
-BMesh *BM_mesh_create(struct Object *ob, const int allocsize[4]);
+struct BMAllocTemplate;
+
+BMesh *BM_mesh_create(struct Object *ob, struct BMAllocTemplate *allocsize);
void BM_mesh_free(BMesh *bm);
void BM_mesh_data_free(BMesh *bm);
@@ -46,4 +48,10 @@ BMVert *BM_vert_at_index(BMesh *bm, const int index);
BMEdge *BM_edge_at_index(BMesh *bm, const int index);
BMFace *BM_face_at_index(BMesh *bm, const int index);
+typedef struct BMAllocTemplate {
+ int totvert, totedge, totloop, totface;
+} BMAllocTemplate;
+
+extern BMAllocTemplate bm_mesh_allocsize_default;
+
#endif /* __BMESH_MESH_H__ */
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.c b/source/blender/bmesh/intern/bmesh_operator_api_inline.c
index a7c8f1612eb..5b88d9f1b96 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api_inline.c
+++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.c
@@ -94,14 +94,9 @@ BM_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *sl
BM_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element)
{
BMOpSlot *slot = BMO_slot_get(op, slotname);
+ BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
- /*sanity check*/
- if (slot->slottype != BMO_OP_SLOT_MAPPING) {
-#ifdef DEBUG
- printf("%s: invalid type %d\n", __func__, slot->slottype);
-#endif
- return 0;
- }
+ /* sanity check */
if (!slot->data.ghash) return 0;
return BLI_ghash_haskey(slot->data.ghash, element);
@@ -112,14 +107,9 @@ BM_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const c
{
BMOElemMapping *mapping;
BMOpSlot *slot = BMO_slot_get(op, slotname);
+ BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING);
- /*sanity check*/
- if (slot->slottype != BMO_OP_SLOT_MAPPING) {
-#ifdef DEBUG
- printf("%s: invalid type %d\n", __func__, slot->slottype);
-#endif
- return NULL;
- }
+ /* sanity check */
if (!slot->data.ghash) return NULL;
mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
@@ -132,7 +122,7 @@ BM_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const c
BM_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname,
void *element)
{
- float *val = (float*) BMO_slot_map_data_get(bm, op, slotname, element);
+ float *val = (float *) BMO_slot_map_data_get(bm, op, slotname, element);
if (val) return *val;
return 0.0f;
@@ -141,7 +131,7 @@ BM_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *sl
BM_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname,
void *element)
{
- int *val = (int*) BMO_slot_map_data_get(bm, op, slotname, element);
+ int *val = (int *) BMO_slot_map_data_get(bm, op, slotname, element);
if (val) return *val;
return 0;
diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c
index 3116de3922b..f18a0835e5e 100644
--- a/source/blender/bmesh/intern/bmesh_walkers.c
+++ b/source/blender/bmesh/intern/bmesh_walkers.c
@@ -27,8 +27,7 @@
*/
#include <stdlib.h>
-
-
+#include <string.h> /* for memcpy */
#include "BLI_listbase.h"