[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10760] branches: Creation of BMesh branch .

Joseph Eagar joeedh at gmail.com
Tue May 22 21:57:11 CEST 2007


Revision: 10760
          https://svn.blender.org//revision/?rev=10760&view=rev
Author:   joeedh
Date:     2007-05-22 21:57:11 +0200 (Tue, 22 May 2007)

Log Message:
-----------
Creation of BMesh branch.  Note: this is NOT usable.  It does compile, but the massive derivedmesh/mesh DNA changes have just begun, and wacky things may befall the uninitiated :) .

Current status: Editmesh code is now completely gone.  All references to editmesh functions have either been rewritten or commented out with //EDITBMESHGREP to enable easy grepping of things left to do.

Mesh DNA has been changed to handle ngons with two new structures, MLoop and MPoly (MFace is deprecated).  Old files are converted on load in do_versions(), however this is a little buggy.

Changes to DerivedMesh have also been made; all the MFace functions are still there, but in addition functions for dealing with MPolys and MLoops has been added.

No functionality for bmesh have been made other then the bare basic derivedmesh/conversion stuff, and even those are still incomplete/buggy.

Modified Paths:
--------------
    branches/bmesh/extern/verse/dist/v_network.c
    branches/bmesh/intern/guardedalloc/MEM_guardedalloc.h
    branches/bmesh/intern/guardedalloc/intern/mallocn.c
    branches/bmesh/source/blender/SConscript
    branches/bmesh/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/bmesh/source/blender/blenkernel/BKE_cdderivedmesh.h
    branches/bmesh/source/blender/blenkernel/BKE_global.h
    branches/bmesh/source/blender/blenkernel/intern/DerivedMesh.c
    branches/bmesh/source/blender/blenkernel/intern/blender.c
    branches/bmesh/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/bmesh/source/blender/blenkernel/intern/customdata.c
    branches/bmesh/source/blender/blenkernel/intern/mesh.c
    branches/bmesh/source/blender/blenkernel/intern/modifier.c
    branches/bmesh/source/blender/blenkernel/intern/object.c
    branches/bmesh/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/bmesh/source/blender/blenlib/intern/BLI_memarena.c
    branches/bmesh/source/blender/blenlib/intern/storage.c
    branches/bmesh/source/blender/blenloader/intern/readfile.c
    branches/bmesh/source/blender/blenloader/intern/writefile.c
    branches/bmesh/source/blender/include/BIF_meshtools.h
    branches/bmesh/source/blender/makesdna/DNA_customdata_types.h
    branches/bmesh/source/blender/makesdna/DNA_mesh_types.h
    branches/bmesh/source/blender/makesdna/DNA_meshdata_types.h
    branches/bmesh/source/blender/python/api2_2x/Blender.c
    branches/bmesh/source/blender/python/api2_2x/Mesh.c
    branches/bmesh/source/blender/python/api2_2x/Object.c
    branches/bmesh/source/blender/python/api2_2x/Scene.c
    branches/bmesh/source/blender/python/api2_2x/Types.c
    branches/bmesh/source/blender/python/api2_2x/gen_library.c
    branches/bmesh/source/blender/render/intern/source/convertblender.c
    branches/bmesh/source/blender/render/intern/source/pipeline.c
    branches/bmesh/source/blender/src/SConscript
    branches/bmesh/source/blender/src/booleanops.c
    branches/bmesh/source/blender/src/buttons_editing.c
    branches/bmesh/source/blender/src/drawobject.c
    branches/bmesh/source/blender/src/drawview.c
    branches/bmesh/source/blender/src/edit.c
    branches/bmesh/source/blender/src/editdeform.c
    branches/bmesh/source/blender/src/editmode_undo.c
    branches/bmesh/source/blender/src/editobject.c
    branches/bmesh/source/blender/src/editview.c
    branches/bmesh/source/blender/src/header_view3d.c
    branches/bmesh/source/blender/src/meshtools.c
    branches/bmesh/source/blender/src/multires-firstlevel.c
    branches/bmesh/source/blender/src/multires.c
    branches/bmesh/source/blender/src/retopo.c
    branches/bmesh/source/blender/src/space.c
    branches/bmesh/source/blender/src/toets.c
    branches/bmesh/source/blender/src/transform_conversions.c
    branches/bmesh/source/blender/src/transform_generics.c
    branches/bmesh/source/blender/src/transform_manipulator.c
    branches/bmesh/source/blender/src/transform_snap.c
    branches/bmesh/source/blender/src/usiblender.c

Added Paths:
-----------
    branches/bmesh/

Copied: branches/bmesh (from rev 10734, trunk/blender)

Modified: branches/bmesh/extern/verse/dist/v_network.c
===================================================================
--- trunk/blender/extern/verse/dist/v_network.c	2007-05-19 16:13:20 UTC (rev 10734)
+++ branches/bmesh/extern/verse/dist/v_network.c	2007-05-22 19:57:11 UTC (rev 10760)
@@ -32,7 +32,7 @@
 typedef short int16;
 typedef unsigned char uint8;
 typedef char int8;
-typedef char boolean;
+//typedef char boolean;
 
 #include "v_cmd_gen.h"
 #include "v_network.h"

Modified: branches/bmesh/intern/guardedalloc/MEM_guardedalloc.h
===================================================================
--- trunk/blender/intern/guardedalloc/MEM_guardedalloc.h	2007-05-19 16:13:20 UTC (rev 10734)
+++ branches/bmesh/intern/guardedalloc/MEM_guardedalloc.h	2007-05-22 19:57:11 UTC (rev 10760)
@@ -76,8 +76,9 @@
 	/**
 	 * Release memory previously allocatred by this module. 
 	 */
-	short MEM_freeN(void *vmemh);
-
+	short WMEM_freeN(void *vmemh);
+	short _MEM_freeN(void *vmemh, char *file, int line);
+	#define MEM_freeN(vmemh)	_MEM_freeN(vmemh, __FILE__, __LINE__)
 	/**
 	 * Duplicates a block of memory, and returns a pointer to the
 	 * newly allocated block.  */

Modified: branches/bmesh/intern/guardedalloc/intern/mallocn.c
===================================================================
--- trunk/blender/intern/guardedalloc/intern/mallocn.c	2007-05-19 16:13:20 UTC (rev 10734)
+++ branches/bmesh/intern/guardedalloc/intern/mallocn.c	2007-05-22 19:57:11 UTC (rev 10760)
@@ -351,35 +351,46 @@
 	mem_unlock_thread();
 }
 
-short MEM_freeN(void *vmemh)		/* anders compileertie niet meer */
+short WMEM_freeN(void *vmemh)
 {
+	return _MEM_freeN(vmemh, "(called through C stub function)", -1);
+}
+
+/*special macro-wrapped MEM_freeN that keeps track of where MEM_freeN is called.*/
+short _MEM_freeN(void *vmemh, char *file, int line)		/* anders compileertie niet meer */
+{
 	short error = 0;
 	MemTail *memt;
 	MemHead *memh= vmemh;
 	const char *name;
-
+	char str1[90];
+	
 	if (memh == NULL){
-		MemorY_ErroR("free","attempt to free NULL pointer");
+		sprintf(str1, "Error in %s on line %d: attempt to free NULL pointer", file, line);
+		MemorY_ErroR("free", str1);
 		/* print_error(err_stream, "%d\n", (memh+4000)->tag1); */
 		return(-1);
 	}
 
 	if(sizeof(long)==8) {
 		if (((long) memh) & 0x7) {
-			MemorY_ErroR("free","attempt to free illegal pointer");
+			sprintf(str1, "Error in %s on line %d: attempt to free illegal pointer", file, line);
+			MemorY_ErroR("free", str1);
 			return(-1);
 		}
 	}
 	else {
 		if (((long) memh) & 0x3) {
-			MemorY_ErroR("free","attempt to free illegal pointer");
+			sprintf(str1, "Error in %s on line %d: attempt to free illegal pointer", file, line);
+			MemorY_ErroR("free", str1);
 			return(-1);
 		}
 	}
 	
 	memh--;
 	if(memh->tag1 == MEMFREE && memh->tag2 == MEMFREE) {
-		MemorY_ErroR(memh->name,"double free");
+		sprintf(str1, "Error in %s on line %d: double free", file, line);
+		MemorY_ErroR(memh->name, str1);
 		return(-1);
 	}
 
@@ -403,13 +414,19 @@
 		MemorY_ErroR(memh->name,"end corrupt");
 		name = check_memlist(memh);
 		if (name != 0){
-			if (name != memh->name) MemorY_ErroR(name,"is also corrupt");
+			sprintf(str1, "Error in %s on line %d: %s is also corrupt", file, line, name);
+			if (name != memh->name) MemorY_ErroR(name, str1);
 		}
 	} else{
 		error = -1;
 		name = check_memlist(memh);
-		if (name == 0) MemorY_ErroR("free","pointer not in memlist");
-		else MemorY_ErroR(name,"error in header");
+		if (name == 0) {
+			sprintf(str1, "Error in %s on line %d: pointer not in memlist", file, line);
+			MemorY_ErroR("free", str1);
+		} else {
+			sprintf(str1, "Error in %s on line %d: error in header", file, line);
+			MemorY_ErroR(name, str1);
+		}
 	}
 
 	totblock--;

Modified: branches/bmesh/source/blender/SConscript
===================================================================
--- trunk/blender/source/blender/SConscript	2007-05-19 16:13:20 UTC (rev 10734)
+++ branches/bmesh/source/blender/SConscript	2007-05-22 19:57:11 UTC (rev 10760)
@@ -15,7 +15,8 @@
             'readblenfile/SConscript',
             'render/SConscript',
             'src/SConscript',
-            'nodes/SConscript'])
+            'nodes/SConscript',
+            'bmesh/SConscript'])
 
 if env['WITH_BF_YAFRAY'] == 1:
     SConscript(['yafray/SConscript'])

Modified: branches/bmesh/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2007-05-19 16:13:20 UTC (rev 10734)
+++ branches/bmesh/source/blender/blenkernel/BKE_DerivedMesh.h	2007-05-22 19:57:11 UTC (rev 10760)
@@ -45,41 +45,107 @@
  *    conversion to DLM.
  */
 
+#include "DNA_listBase.h"
 #include "DNA_customdata_types.h"
 #include "BKE_customdata.h"
 
 struct MVert;
 struct MEdge;
-struct MFace;
-struct MTFace;
+struct MFace; /* EVIL! */
+struct MTFace; /* EVIL! */
+struct MPoly;
+struct MLoop;
 struct Object;
 struct Mesh;
 struct EditMesh;
 struct ModifierData;
 struct MCol;
+struct Material;
 
 /* number of sub-elements each mesh element has (for interpolation) */
 #define SUB_ELEMS_VERT 0
 #define SUB_ELEMS_EDGE 2
 #define SUB_ELEMS_FACE 4
 
+
+typedef struct bglTriangle {
+	struct bglTriangle *next, *prev;
+	float uv[3][2];
+	float vert_colors[3][3];
+	float vert_cos[3][3];
+	float vert_nos[3][3];	
+} bglTriangle;
+
+typedef struct bglMesh {
+	float *gl_array; //is interleaved
+	ListBase triangles;
+} bglMesh;
+
+/*ONLY ACCEPTS TRIANGLES!*/
+typedef struct bglCacheDrawInterface {
+	void (*beginCache)(void *vself);
+	void (*setMaterials)(void *vself, int totmat, struct Material **materials);
+	
+	/*if v4 == NULL, then the face is assumed to be a triangle.  Will do quads, or triangles,
+      but will NOT automatically tesselate ngons!*/
+	void (*addFace)(void *vself, float *verts, float *normals, char *cols,
+	                              int mat, int sel, int smooth);
+	                              
+	void (*addEdgeWire)(void *vself, float *v1, float *v2, int sel, int seam);
+	void (*addVertPoint)(void *vself, float *v, int sel, int seam);
+	void (*endCache)(void *vself);
+	void (*drawCache)(void *vself, int drawlevel);
+	/* char *colors is an array of per-face colors.*/
+	void (*drawCacheOverloadColors)(void *vself, char *colors, int drawlevel, int flags);
+} bglCacheDrawInterface;
+
+#define BGLC_EnableLighting		1
+#define BGLC_EnableMaterial		2
+#define BGLC_EnableSmooth		4
+#define BGLC_EnableFaces		8
+#define BGLC_EnableWires		16
+#define BGLC_EnablePoints		32
+
+/*theres always one group per material, that is
+  entirely triangles.*/
+
+typedef struct bglCacheFaceGroup {
+	float *faceverts;
+	float *facecolors;
+	float *facenormals;
+} bglCacheFaceGroup;	
+
+typedef struct bglCacheDrawer {
+	bglCacheDrawInterface *interface;
+	bglCacheFaceGroup facegroups[16];
+	float *edgeverts;
+	float *edgecols;
+	float *pointverts;
+	float *pointcols;
+} bglCacheDrawer;
+
 typedef struct DerivedMesh DerivedMesh;
 struct DerivedMesh {
 	/* Private DerivedMesh data, only for internal DerivedMesh use */
-	CustomData vertData, edgeData, faceData;
-	int numVertData, numEdgeData, numFaceData;
+	
+	/*faceData is stored tesselated faces only for updated DerivedMeshes.*/
+	CustomData vertData, edgeData, faceData, loopData, polyData;
+	int numVertData, numEdgeData, numFaceData, numLoopData, numPolyData;
 	int needsFree; /* checked on ->release, is set to 0 for cached results */
-
+	int needsDrawCacheUpdate;
+	bglCacheDrawInterface *drawer;
+	
 	/* Misc. Queries */
 
 	/* Also called in Editmode */
 	int (*getNumVerts)(DerivedMesh *dm);
 	/* Also called in Editmode */
+	int (*getNumEdges)(DerivedMesh *dm);
 	int (*getNumFaces)(DerivedMesh *dm);
-
-	int (*getNumEdges)(DerivedMesh *dm);
-
-	/* copy a single vert/edge/face from the derived mesh into
+	int (*getNumLoops)(DerivedMesh *dm);
+	int (*getNumPolys)(DerivedMesh *dm);
+	
+	/* copy a single vert/edge/tesselated face/face ngon from the derived mesh into
 	 * *{vert/edge/face}_r. note that the current implementation
 	 * of this function can be quite slow, iterating over all
 	 * elements (editmesh, verse mesh)
@@ -87,7 +153,9 @@
 	void (*getVert)(DerivedMesh *dm, int index, struct MVert *vert_r);
 	void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *edge_r);
 	void (*getFace)(DerivedMesh *dm, int index, struct MFace *face_r);
-
+	void (*getLoop)(DerivedMesh *dm, int index, struct MFace *face_r);
+	void (*getPoly)(DerivedMesh *dm, int index, struct MPoly *face_r);
+	
 	/* return a pointer to the entire array of verts/edges/face from the
 	 * derived mesh. if such an array does not exist yet, it will be created,
 	 * and freed on the next ->release(). consider using getVert/Edge/Face if
@@ -96,38 +164,48 @@
 	struct MVert *(*getVertArray)(DerivedMesh *dm);
 	struct MEdge *(*getEdgeArray)(DerivedMesh *dm);
 	struct MFace *(*getFaceArray)(DerivedMesh *dm);
-
-	/* copy all verts/edges/faces from the derived mesh into
+	struct MLoop *(*getLoopArray)(DerivedMesh *dm);
+	struct MPoly *(*getPolyArray)(DerivedMesh *dm);
+	
+	/* copy all verts/edges/tesselated faces/polys from the derived mesh into
 	 * *{vert/edge/face}_r (must point to a buffer large enough)
 	 */
 	void (*copyVertArray)(DerivedMesh *dm, struct MVert *vert_r);
 	void (*copyEdgeArray)(DerivedMesh *dm, struct MEdge *edge_r);
 	void (*copyFaceArray)(DerivedMesh *dm, struct MFace *face_r);
-
-	/* return a copy of all verts/edges/faces from the derived mesh
-	 * it is the caller's responsibility to free the returned pointer
+	void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *loop_r);
+	void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *poly_r);
+	
+	/* return a copy of all verts/edges/tesselated faces/polys from the derived mesh
+	 * it is the caller's responsibility to free the returned pointer with MEM_freeN(pointer).
 	 */
 	struct MVert *(*dupVertArray)(DerivedMesh *dm);
 	struct MEdge *(*dupEdgeArray)(DerivedMesh *dm);
 	struct MFace *(*dupFaceArray)(DerivedMesh *dm);
-
-	/* return a pointer to a single element of vert/edge/face custom data
+	struct MLoop *(*dupLoopArray)(DerivedMesh *dm);
+	struct MPoly *(*dupPolyArray)(DerivedMesh *dm);
+	
+	/* return a pointer to a single element of vert/edge/tesselated faces/polys custom data
 	 * from the derived mesh (this gives a pointer to the actual data, not
 	 * a copy)
 	 */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list