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:
-rw-r--r--source/blender/blenkernel/BKE_bmesh.h59
-rw-r--r--source/blender/blenkernel/BKE_bmeshCustomData.h108
-rw-r--r--source/blender/blenkernel/intern/BME_Customdata.c197
-rw-r--r--source/blender/blenkernel/intern/BME_conversions.c22
-rw-r--r--source/blender/blenkernel/intern/BME_mesh.c92
-rw-r--r--source/blender/blenkernel/intern/BME_structure.c44
-rw-r--r--source/blender/blenkernel/intern/modifier.c4
-rw-r--r--source/blender/src/editmesh_tools.c8
8 files changed, 406 insertions, 128 deletions
diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h
index e44e9e02aaa..51a5d29dbb7 100644
--- a/source/blender/blenkernel/BKE_bmesh.h
+++ b/source/blender/blenkernel/BKE_bmesh.h
@@ -40,11 +40,11 @@
#include "DNA_listBase.h"
#include "BLI_ghash.h"
#include "BLI_memarena.h"
-#include "DNA_customdata_types.h"
#include "DNA_image_types.h"
#include "BLI_editVert.h"
#include "BKE_DerivedMesh.h"
#include "transform.h"
+#include "BKE_bmeshCustomData.h"
/*forward declerations*/
struct BME_Vert;
@@ -60,55 +60,6 @@ typedef struct BME_mempool{
struct BME_freenode *free; /*free element list. Interleaved into chunk datas.*/
}BME_mempool;
-/*Custom Data Types and defines
- Eventual plan is to move almost everything to custom data and let caller
- decide when making the mesh what layers they want to store in the mesh
-
- This stuff should probably go in a seperate file....
-*/
-typedef struct BME_CustomDataLayer {
- int type; /* type of data in layer */
- int offset; /* offset of layer in block */
- int active; /* offset of active layer*/
- char name[32]; /* layer name */
-} BME_CustomDataLayer;
-
-typedef struct BME_CustomData {
- BME_CustomDataLayer *layers; /*Custom Data Layers*/
- BME_mempool *pool; /*pool for alloc of blocks*/
- int totlayer, totsize; /*total layers and total size in bytes of each block*/
-} BME_CustomData;
-
-#define BME_CD_FACETEX 1 /*Image texture/texface*/
-#define BME_CD_LOOPTEX 2 /*UV coordinates*/
-#define BME_CD_LOOPCOL 3 /*Vcolors*/
-#define BME_CD_DEFORMVERT 4 /*Vertex Group/Weights*/
-#define BME_CD_NUMTYPES 5
-
-typedef struct BME_DeformWeight {
- int def_nr;
- float weight;
-} BME_DeformWeight;
-
-typedef struct BME_DeformVert {
- struct BME_DeformWeight *dw;
- int totweight;
-} BME_DeformVert;
-
-typedef struct BME_facetex{
- struct Image *tpage;
- char flag, transp;
- short mode, tile, unwrap;
-}BME_facetex;
-
-typedef struct BME_looptex{
- float u, v;
-}BME_looptex;
-
-typedef struct BME_loopcol{
- char r, g, b, a;
-}BME_loopcol;
-
/*Notes on further structure Cleanup:
-Remove the tflags, they belong in custom data layers
-Remove the eflags completely, they are mostly not used
@@ -196,7 +147,7 @@ typedef struct BME_Poly
unsigned short flag, h, mat_nr;
} BME_Poly;
-//*EDGE UTILITIES*/
+/*EDGE UTILITIES*/
int BME_verts_in_edge(struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge *e);
int BME_vert_in_edge(struct BME_Edge *e, BME_Vert *v);
struct BME_Vert *BME_edge_getothervert(struct BME_Edge *e, struct BME_Vert *v);
@@ -218,7 +169,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(int valloc, int ealloc, int lalloc, int palloc);
+struct BME_Mesh *BME_make_mesh(int allocsize[4], struct BME_CustomDataInit init[4]);
void BME_free_mesh(struct BME_Mesh *bm);
/*FULL MESH VALIDATION*/
int BME_validate_mesh(struct BME_Mesh *bm, int halt);
@@ -302,8 +253,8 @@ float *BME_bevel_calc_polynormal(struct BME_Poly *f, struct BME_TransData_Head *
struct BME_Mesh *BME_bevel(struct BME_Mesh *bm, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd);
/*CONVERSION FUNCTIONS*/
-struct BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, struct BME_Mesh *bm);
+struct BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em);
struct EditMesh *BME_bmesh_to_editmesh(struct BME_Mesh *bm, BME_TransData_Head *td);
-struct BME_Mesh *BME_derivedmesh_to_bmesh(struct DerivedMesh *dm, struct BME_Mesh *bm);
+struct BME_Mesh *BME_derivedmesh_to_bmesh(struct DerivedMesh *dm);
struct DerivedMesh *BME_bmesh_to_derivedmesh(struct BME_Mesh *bm, struct DerivedMesh *dm);
#endif
diff --git a/source/blender/blenkernel/BKE_bmeshCustomData.h b/source/blender/blenkernel/BKE_bmeshCustomData.h
new file mode 100644
index 00000000000..423f75e532d
--- /dev/null
+++ b/source/blender/blenkernel/BKE_bmeshCustomData.h
@@ -0,0 +1,108 @@
+/**
+ * BKE_bmesh.h jan 2007
+ *
+ * BMesh modeler structure and functions.
+ *
+ * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2004 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Geoffrey Bantle.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+#ifndef BKE_BMESHCUSTOMDATA_H
+#define BKE_BMESHCUSTOMDATA_H
+
+struct BME_mempool;
+
+/*Custom Data Types and defines
+ Eventual plan is to move almost everything to custom data and let caller
+ decide when making the mesh what layers they want to store in the mesh
+
+ This stuff should probably go in a seperate file....
+*/
+
+#define BME_CD_FACETEX 0 /*Image texture/texface*/
+#define BME_CD_LOOPTEX 1 /*UV coordinates*/
+#define BME_CD_LOOPCOL 2 /*Vcolors*/
+#define BME_CD_DEFORMVERT 3 /*Vertex Group/Weights*/
+#define BME_CD_NUMTYPES 4
+
+typedef struct BME_CustomDataLayer {
+ int type; /* type of data in layer */
+ int offset; /* offset of layer in block */
+ int active; /* offset of active layer*/
+ char name[32]; /* layer name */
+} BME_CustomDataLayer;
+
+typedef struct BME_CustomData {
+ struct BME_CustomDataLayer *layers; /*Custom Data Layers*/
+ struct BME_mempool *pool; /*pool for alloc of blocks*/
+ int totlayer, totsize; /*total layers and total size in bytes of each block*/
+} BME_CustomData;
+
+typedef struct BME_CustomDataInit{
+ int layout[BME_CD_NUMTYPES];
+ int active[BME_CD_NUMTYPES];
+ int totlayers;
+ char *nametemplate;
+} BME_CustomDataInit;
+
+/*Custom data types*/
+typedef struct BME_DeformWeight {
+ int def_nr;
+ float weight;
+} BME_DeformWeight;
+
+typedef struct BME_DeformVert {
+ struct BME_DeformWeight *dw;
+ int totweight;
+} BME_DeformVert;
+
+typedef struct BME_facetex{
+ struct Image *tpage;
+ char flag, transp;
+ short mode, tile, unwrap;
+}BME_facetex;
+
+typedef struct BME_looptex{
+ float u, v;
+}BME_looptex;
+
+typedef struct BME_loopcol{
+ char r, g, b, a;
+}BME_loopcol;
+
+/*CUSTOM DATA API*/
+void BME_CD_Create(struct BME_CustomData *data, struct BME_CustomDataInit *init, int initalloc);
+void BME_CD_Free(struct BME_CustomData *data);
+void BME_CD_free_block(struct BME_CustomData *data, void **block);
+void BME_CD_copy_data(const struct BME_CustomData *source, struct BME_CustomData *dest, void *src_block, void **dest_block);
+void BME_CD_set_default(struct BME_CustomData *data, void **block);
+
+#endif
diff --git a/source/blender/blenkernel/intern/BME_Customdata.c b/source/blender/blenkernel/intern/BME_Customdata.c
new file mode 100644
index 00000000000..68bc75327d9
--- /dev/null
+++ b/source/blender/blenkernel/intern/BME_Customdata.c
@@ -0,0 +1,197 @@
+/**
+ * BME_customdata.c jan 2007
+ *
+ * Custom Data functions for Bmesh
+ *
+ * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2004 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Geoffrey Bantle, Brecht Van Lommel, Ben Batt
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+#include "BKE_bmesh.h"
+#include "BKE_bmeshCustomData.h"
+#include "bmesh_private.h"
+#include <string.h>
+
+/********************* Layer type information **********************/
+typedef struct BME_LayerTypeInfo {
+ int size;
+ char *defaultname;
+ void (*copy)(const void *source, void *dest, int count);
+ void (*free)(void *data, int count, int size);
+ void (*interp)(void **sources, float *weights, float *sub_weights, int count, void *dest);
+ void (*set_default)(void *data, int count);
+} BME_LayerTypeInfo;
+const BME_LayerTypeInfo BMELAYERTYPEINFO[BME_CD_NUMTYPES] = {
+ {sizeof(BME_facetex), "TexFace", NULL, NULL, NULL, NULL},
+ {sizeof(BME_looptex), "UV", NULL, NULL, NULL, NULL},
+ {sizeof(BME_loopcol), "VCol", NULL, NULL, NULL, NULL},
+ {sizeof(BME_DeformVert), "Group", NULL, NULL, NULL, NULL}
+};
+static const BME_LayerTypeInfo *BME_layerType_getInfo(int type)
+{
+ if(type < 0 || type >= CD_NUMTYPES) return NULL;
+
+ return &BMELAYERTYPEINFO[type];
+}
+void BME_CD_Create(BME_CustomData *data, BME_CustomDataInit *init, int initalloc)
+{
+ int i, j, offset=0;
+ const BME_LayerTypeInfo *info;
+
+ /*initialize data members*/
+ data->layers = NULL;
+ data->pool = NULL;
+ data->totlayer = 0;
+ data->totsize = 0;
+
+ /*first count how many layers to alloc*/
+ for(i=0; i < BME_CD_NUMTYPES; i++){
+ info = BME_layerType_getInfo(i);
+ data->totlayer += init->layout[i];
+ data->totsize += (init->layout[i] * info->size);
+ }
+ /*alloc our layers*/
+ if(data->totlayer){
+ /*alloc memory*/
+ data->layers = MEM_callocN(sizeof(BME_CustomDataLayer)*data->totlayer, "BMesh Custom Data Layers");
+ data->pool = BME_mempool_create(data->totsize, initalloc, initalloc);
+ /*initialize layer data*/
+ for(i=0; i < BME_CD_NUMTYPES; i++){
+ if(init->layout[i]){
+ info = BME_layerType_getInfo(i);
+ for(j=0; j < init->layout[i]; j++){
+ if(j=0) data->layers[j+i].active = init->active[i];
+ data->layers[j+i].type = i;
+ data->layers[j+i].offset = offset;
+ strcpy(data->layers[j+i].name, &(init->nametemplate[j+i]));
+ offset += info->size;
+ }
+ }
+ }
+ }
+}
+
+void BME_CD_Free(BME_CustomData *data)
+{
+ if(data->pool) BME_mempool_destroy(data->pool);
+}
+
+/*Block level ops*/
+void BME_CD_free_block(BME_CustomData *data, void **block)
+{
+ const BME_LayerTypeInfo *typeInfo;
+ int i;
+
+ if(!*block) return;
+ for(i = 0; i < data->totlayer; ++i) {
+ typeInfo = BME_layerType_getInfo(data->layers[i].type);
+ if(typeInfo->free) {
+ int offset = data->layers[i].offset;
+ typeInfo->free((char*)*block + offset, 1, typeInfo->size);
+ }
+ }
+ BME_mempool_free(data->pool, *block);
+ *block = NULL;
+}
+
+
+static void BME_CD_alloc_block(BME_CustomData *data, void **block)
+{
+
+ if (*block) BME_CD_free_block(data, block); //if we copy layers that have their own free functions like deformverts
+
+ if (data->totsize > 0)
+ *block = BME_mempool_alloc(data->pool);
+ else
+ *block = NULL;
+}
+
+void BME_CD_copy_data(const BME_CustomData *source, BME_CustomData *dest,
+ void *src_block, void **dest_block)
+{
+ const BME_LayerTypeInfo *typeInfo;
+ int dest_i, src_i;
+
+ if (!*dest_block) /*for addXXXlist functions!*/
+ BME_CD_alloc_block(dest, dest_block);
+
+ /* copies a layer at a time */
+ dest_i = 0;
+ for(src_i = 0; src_i < source->totlayer; ++src_i) {
+
+ /* find the first dest layer with type >= the source type
+ * (this should work because layers are ordered by type)
+ */
+ while(dest_i < dest->totlayer
+ && dest->layers[dest_i].type < source->layers[src_i].type)
+ ++dest_i;
+
+ /* if there are no more dest layers, we're done */
+ if(dest_i >= dest->totlayer) return;
+
+ /* if we found a matching layer, copy the data */
+ if(dest->layers[dest_i].type == source->layers[src_i].type &&
+ strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
+ char *src_data = (char*)src_block + source->layers[src_i].offset;
+ char *dest_data = (char*)*dest_block + dest->layers[dest_i].offset;
+
+ typeInfo = BME_layerType_getInfo(source->layers[src_i].type);
+
+ if(typeInfo->copy)
+ typeInfo->copy(src_data, dest_data, 1);
+ else
+ memcpy(dest_data, src_data, typeInfo->size);
+
+ /* if there are multiple source & dest layers of the same type,
+ * we don't want to copy all source layers to the same dest, so
+ * increment dest_i
+ */
+ ++dest_i;
+ }
+ }
+}
+void BME_CD_set_default(BME_CustomData *data, void **block)
+{
+ const BME_LayerTypeInfo *typeInfo;
+ int i;
+
+ if (!*block)
+ BME_CD_alloc_block(data, block); //for addXXXlist functions...
+
+ for(i = 0; i < data->totlayer; ++i) {
+ int offset = data->layers[i].offset;
+
+ typeInfo = BME_layerType_getInfo(data->layers[i].type);
+
+ if(typeInfo->set_default)
+ typeInfo->set_default((char*)*block + offset, 1);
+ }
+}
diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c
index 369c19b16c8..08483711c45 100644
--- a/source/blender/blenkernel/intern/BME_conversions.c
+++ b/source/blender/blenkernel/intern/BME_conversions.c
@@ -55,7 +55,10 @@
#include "BSE_edit.h"
-BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
+BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
+ BME_Mesh *bm;
+ int allocsize[4] = {512,512,2048,512};
+ BME_CustomDataInit *init = MEM_callocN(sizeof(BME_CustomDataInit) * 4, "Bmesh custom data init");
BME_Vert *v1, *v2;
BME_Edge *e, *edar[4];
BME_Poly *f;
@@ -65,7 +68,7 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
EditFace *efa;
int len;
-
+ bm = BME_make_mesh(allocsize,init);
BME_model_begin(bm);
/*add verts*/
@@ -134,6 +137,7 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
efa = efa->next;
}
BME_model_end(bm);
+ MEM_freeN(init);
return bm;
}
@@ -224,21 +228,24 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
}
/* Adds the geometry found in dm to bm
- * NOTE: it does not allocate a new BME_Mesh!
- */
-BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm, BME_Mesh *bm)
+ */
+BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm)
{
+
+ BME_Mesh *bm;
+ int allocsize[4] = {512,512,2048,512};
+ BME_CustomDataInit *init = MEM_callocN(sizeof(BME_CustomDataInit) * 4, "Bmesh custom data init");
MVert *mvert, *mv;
MEdge *medge, *me;
MFace *mface, *mf;
int totface,totedge,totvert,i,len;
-
BME_Vert *v1=NULL,*v2=NULL, **vert_array;
BME_Edge *e=NULL;
BME_Poly *f=NULL;
EdgeHash *edge_hash = BLI_edgehash_new();
-
+
+ bm = BME_make_mesh(allocsize,init);
totvert = dm->getNumVerts(dm);
totedge = dm->getNumEdges(dm);
totface = dm->getNumFaces(dm);
@@ -293,6 +300,7 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm, BME_Mesh *bm)
BME_model_end(bm);
BLI_edgehash_free(edge_hash, NULL);
MEM_freeN(vert_array);
+ MEM_freeN(init);
return bm;
}
diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c
index 0423d9a0ac6..184ef2b8a0e 100644
--- a/source/blender/blenkernel/intern/BME_mesh.c
+++ b/source/blender/blenkernel/intern/BME_mesh.c
@@ -59,27 +59,37 @@
/*
* BME MAKE MESH
*
- * Allocates a new BME_Mesh structure
+ * Allocates a new BME_Mesh structure.
+ * The arguments are two arrays, one of type int
+ * and another of type BME_CustomDataInit. The first array
+ * contains the allocation size for each element pool in
+ * the mesh. For instance allocsize[0] contains the number
+ * of vertices to allocate at a time for the vertex pool.
+ *
+ * The second array contains structures describing the layout
+ * of custom data for each element type in the mesh. So init[0]
+ * contains the custom data layout information for vertices, init[1]
+ * the layout information for edges and so on.
+ *
+ * Returns -
+ * Pointer to a Bmesh
+ *
*/
-//BME_Mesh *BME_make_mesh(int valloc, int ealloc, int lalloc, int palloc, int vdata[BME_CD_NUMTYPES], int edata[BME_CD_NUMTYPES], int ldata[BME_CD_NUMTYPES], int pdata[BME_CD_NUMTYPES])
-BME_Mesh *BME_make_mesh(int valloc, int ealloc, int lalloc, int palloc){
+BME_Mesh *BME_make_mesh(int allocsize[4], BME_CustomDataInit init[4])
+{
/*allocate the structure*/
BME_Mesh *bm = MEM_callocN(sizeof(BME_Mesh),"BMesh");
/*allocate the memory pools for the mesh elements*/
- bm->vpool = BME_mempool_create(sizeof(BME_Vert), valloc, valloc);
- bm->epool = BME_mempool_create(sizeof(BME_Edge), ealloc, ealloc);
- bm->ppool = BME_mempool_create(sizeof(BME_Poly), palloc, palloc);
- bm->lpool = BME_mempool_create(sizeof(BME_Loop), lalloc, lalloc);
-
- /*Setup Custom data structs and layers*/
- /*
- BME_CD_Create(bm, &bm->vdata, vdata);
- BME_CD_Create(bm, &bm->edata, edata);
- BME_CD_Create(bm, &bm->ldata, ldata);
- BME_CD_Create(bm, &bm->pdata, pdata);
-
- */
+ bm->vpool = BME_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0]);
+ bm->epool = BME_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1]);
+ bm->lpool = BME_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2]);
+ bm->ppool = BME_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3]);
+ /*Setup custom data layers*/
+ BME_CD_Create(&bm->vdata, &init[0], allocsize[0]);
+ BME_CD_Create(&bm->edata, &init[1], allocsize[1]);
+ BME_CD_Create(&bm->ldata, &init[2], allocsize[2]);
+ BME_CD_Create(&bm->pdata, &init[3], allocsize[3]);
return bm;
}
/*
@@ -90,17 +100,31 @@ BME_Mesh *BME_make_mesh(int valloc, int ealloc, int lalloc, int palloc){
void BME_free_mesh(BME_Mesh *bm)
{
+ BME_Vert *v;
+ BME_Edge *e;
+ BME_Loop *l;
+ BME_Poly *f;
+
+ for(v=bm->verts.first; v; v=v->next) BME_CD_free_block(&bm->vdata, &v->data);
+ for(e=bm->edges.first; e; e=e->next) BME_CD_free_block(&bm->edata, &e->data);
+ for(f=bm->polys.first; f; f=f->next){
+ BME_CD_free_block(&bm->pdata, &f->data);
+ l = f->loopbase;
+ do{
+ BME_CD_free_block(&bm->ldata, &l->data);
+ l = l->next;
+ }while(l!=f->loopbase);
+ }
/*destroy element pools*/
BME_mempool_destroy(bm->vpool);
BME_mempool_destroy(bm->epool);
BME_mempool_destroy(bm->ppool);
BME_mempool_destroy(bm->lpool);
- /*
- BME_CD_Free(bm, &bm->vdata);
- BME_CD_Free(bm, &bm->edata);
- BME_CD_Free(bm, &bm->ldata);
- BME_CD_Free(bm, &bm->pdata);
- */
+ /*free custom data pools*/
+ BME_CD_Free(&bm->vdata);
+ BME_CD_Free(&bm->edata);
+ BME_CD_Free(&bm->ldata);
+ BME_CD_Free(&bm->pdata);
MEM_freeN(bm);
}
@@ -111,17 +135,12 @@ void BME_free_mesh(BME_Mesh *bm)
* must begin with a call to BME_model_end() and finish with a call to BME_model_end().
* No modification of mesh data is allowed except in between these two calls.
*
- * TODO
- * FOR BME_MODEL_BEGIN:
- * -integrate euler undo system.
- * -make full copy of structure to safely recover from errors.
- * -accept a toolname string.
- * -accept param to turn off full copy if just selection tool. (perhaps check for this in eulers...)
+ * The purpose of these calls is allow for housekeeping tasks to be performed,
+ * such as allocating/freeing scratch arrays or performing debug validation of
+ * the mesh structure.
*
- * BME_MODEL_END:
- * -full mesh validation if debugging turned on
- * -free structure copy or use it to restore.
- * -do euler undo push.
+ * Returns -
+ * Nothing
*
*/
@@ -165,13 +184,6 @@ void BME_model_end(BME_Mesh *bm){
}
}
-/*note, this needs to be turned on for debugging only.
- We need two levels of debugging,
- 1: Mesh level
- 2: Euler level
- Both need to be turned off in production builds (they really slow things down)
-*/
-
/*
* BME VALIDATE MESH
*
@@ -187,7 +199,7 @@ void BME_model_end(BME_Mesh *bm){
*
* TODO
*
- * -Write a full mesh validation function for debugging purposes.
+ * -Make this only part of debug builds
*/
#define VHALT(halt) {BME_error(); if(halt) return 0;}
diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c
index 8f885d6c2cb..cbf780c6467 100644
--- a/source/blender/blenkernel/intern/BME_structure.c
+++ b/source/blender/blenkernel/intern/BME_structure.c
@@ -193,12 +193,12 @@ BME_Vert *BME_addvertlist(BME_Mesh *bm, BME_Vert *example){
bm->nextv++;
bm->totvert++;
- if(example)
+ if(example){
VECCOPY(v->co,example->co);
- //if(example)
- // CustomData_em_copy_data(&bm->vdata, &bm->vdata, example->data, &v->data);
- //else
- // CustomData_em_set_default(&bm->vdata, &v->data);
+ BME_CD_copy_data(&bm->vdata, &bm->vdata, example->data, &v->data);
+ }
+ else
+ BME_CD_set_default(&bm->vdata, &v->data);
return v;
}
@@ -221,16 +221,15 @@ BME_Edge *BME_addedgelist(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge *ex
bm->totedge++;
BLI_addtail(&(bm->edges), e);
- //if(example)
- // CustomData_em_copy_data(&bm->edata, &bm->edata, example->data, &e->data);
- //else
- // CustomData_em_set_default(&bm->edata, &e->data);
+ if(example)
+ BME_CD_copy_data(&bm->edata, &bm->edata, example->data, &e->data);
+ else
+ BME_CD_set_default(&bm->edata, &e->data);
return e;
}
BME_Loop *BME_create_loop(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Poly *f, BME_Loop *example){
- /*allocate a BME_Loop and add it to the loophash*/
BME_Loop *l=NULL;
l = BME_mempool_alloc(bm->lpool);
l->next = l->prev = NULL;
@@ -246,12 +245,11 @@ BME_Loop *BME_create_loop(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Poly *f, B
bm->nextl++;
bm->totloop++;
-
-/* if(example)
- BME_CustomData_copy_data(&bm->ldata, &bm->ldata, example->data, &l->data);
+ if(example)
+ BME_CD_copy_data(&bm->ldata, &bm->ldata, example->data, &l->data);
else
- BME_CustomData_set_default(&bm->ldata, &l->data);
-*/
+ BME_CD_set_default(&bm->ldata, &l->data);
+
return l;
}
@@ -269,10 +267,10 @@ BME_Poly *BME_addpolylist(BME_Mesh *bm, BME_Poly *example){
bm->nextp++;
bm->totpoly++;
- //if(example)
- // CustomData_em_copy_data(&bm->pdata, &bm->pdata, example->data, &f->data);
- //else
- // CustomData_em_set_default(&bm->pdata, &f->data);
+ if(example)
+ BME_CD_copy_data(&bm->pdata, &bm->pdata, example->data, &f->data);
+ else
+ BME_CD_set_default(&bm->pdata, &f->data);
return f;
@@ -283,22 +281,22 @@ BME_Poly *BME_addpolylist(BME_Mesh *bm, BME_Poly *example){
*/
void BME_free_vert(BME_Mesh *bm, BME_Vert *v){
bm->totvert--;
- //CustomData_em_free_block(&bm->vdata, &v->data);
+ BME_CD_free_block(&bm->vdata, &v->data);
BME_mempool_free(bm->vpool, v);
}
void BME_free_edge(BME_Mesh *bm, BME_Edge *e){
bm->totedge--;
- //CustomData_em_free_block(&bm->edata, &e->data);
+ BME_CD_free_block(&bm->edata, &e->data);
BME_mempool_free(bm->epool, e);
}
void BME_free_poly(BME_Mesh *bm, BME_Poly *f){
bm->totpoly--;
- //CustomData_em_free_block(&bm->pdata, &f->data);
+ BME_CD_free_block(&bm->pdata, &f->data);
BME_mempool_free(bm->ppool, f);
}
void BME_free_loop(BME_Mesh *bm, BME_Loop *l){
bm->totloop--;
- //CustomData_em_free_block(&bm->ldata, &l->data);
+ BME_CD_free_block(&bm->ldata, &l->data);
BME_mempool_free(bm->lpool, l);
}
/**
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 6185e249b5a..efc250fdc0d 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -2736,6 +2736,7 @@ static DerivedMesh *bevelModifier_applyModifier(
{
DerivedMesh *result;
BME_Mesh *bm;
+
/*bDeformGroup *def;*/
int /*i,*/ options, defgrp_index = -1;
BevelModifierData *bmd = (BevelModifierData*) md;
@@ -2754,8 +2755,7 @@ static DerivedMesh *bevelModifier_applyModifier(
//~ }
//~ }
- bm = BME_make_mesh(512,512,2048,512);
- bm = BME_derivedmesh_to_bmesh(derivedData, bm);
+ bm = BME_derivedmesh_to_bmesh(derivedData);
BME_bevel(bm,bmd->value,bmd->res,options,defgrp_index,bmd->bevel_angle,NULL);
result = BME_bmesh_to_derivedmesh(bm,derivedData);
BME_free_mesh(bm);
diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c
index d90a7eb7c16..f85161c3e23 100644
--- a/source/blender/src/editmesh_tools.c
+++ b/source/blender/src/editmesh_tools.c
@@ -4480,6 +4480,11 @@ static void bevel_mesh_recurs(float bsize, short recurs, int allfaces)
}
void bevel_menu() {
+ int vlayers[BME_CD_NUMTYPES] = {0,0,0,0};
+ int elayers[BME_CD_NUMTYPES] = {0,0,0,0};
+ int llayers[BME_CD_NUMTYPES] = {0,0,0,0};
+ int players[BME_CD_NUMTYPES] = {0,0,0,0};
+
BME_Mesh *bm;
BME_TransData_Head *td;
TransInfo *t;
@@ -4497,8 +4502,7 @@ void bevel_menu() {
while(G.editBMesh->options & BME_BEVEL_RUNNING) {
options = G.editBMesh->options;
res = G.editBMesh->res;
- bm = BME_make_mesh(512,512,2048,512);
- bm = BME_editmesh_to_bmesh(G.editMesh, bm);
+ bm = BME_editmesh_to_bmesh(G.editMesh);
BIF_undo_push("Pre-Bevel");
free_editMesh(G.editMesh);
BME_bevel(bm,0.1f,res,options,0,0,&td);