[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15088] trunk/blender/source/blender: -> More Bmesh Custom Data stuff

Geoffrey Bantle hairbat at yahoo.com
Mon Jun 2 22:52:40 CEST 2008


Revision: 15088
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15088
Author:   briggs
Date:     2008-06-02 22:52:40 +0200 (Mon, 02 Jun 2008)

Log Message:
-----------
-> More Bmesh Custom Data stuff

Some more Bmesh custom data functions and
structures. This still does not do anything
yet because the various conversion functions
don't bother making use of the new custom data
functions. Hooking them up should be fairly
simple though.

Also note that the custom data code is mostly
copy/pasted from the existing custom data
functions for editmode with a few modifications.
Duplicating code like this isn't nice, but I
felt it was better to keep things for Bmesh
'standalone' for the moment and take only what is
immediatly needed instead of creating
a tangle of interdependant code.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_bmesh.h
    trunk/blender/source/blender/blenkernel/intern/BME_conversions.c
    trunk/blender/source/blender/blenkernel/intern/BME_mesh.c
    trunk/blender/source/blender/blenkernel/intern/BME_structure.c
    trunk/blender/source/blender/blenkernel/intern/modifier.c
    trunk/blender/source/blender/src/editmesh_tools.c

Added Paths:
-----------
    trunk/blender/source/blender/blenkernel/BKE_bmeshCustomData.h
    trunk/blender/source/blender/blenkernel/intern/BME_Customdata.c

Modified: trunk/blender/source/blender/blenkernel/BKE_bmesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_bmesh.h	2008-06-02 17:31:05 UTC (rev 15087)
+++ trunk/blender/source/blender/blenkernel/BKE_bmesh.h	2008-06-02 20:52:40 UTC (rev 15088)
@@ -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 @@
 	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 @@
 	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 @@
 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 @@
 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

Added: trunk/blender/source/blender/blenkernel/BKE_bmeshCustomData.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_bmeshCustomData.h	                        (rev 0)
+++ trunk/blender/source/blender/blenkernel/BKE_bmeshCustomData.h	2008-06-02 20:52:40 UTC (rev 15088)
@@ -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

Added: trunk/blender/source/blender/blenkernel/intern/BME_Customdata.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/BME_Customdata.c	                        (rev 0)
+++ trunk/blender/source/blender/blenkernel/intern/BME_Customdata.c	2008-06-02 20:52:40 UTC (rev 15088)
@@ -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;
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list