[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30356] branches/bmesh/blender/source/ blender/bmesh: [note: do not test quite yet]

Joseph Eagar joeedh at gmail.com
Thu Jul 15 02:55:31 CEST 2010


Revision: 30356
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30356
Author:   joeedh
Date:     2010-07-15 02:55:31 +0200 (Thu, 15 Jul 2010)

Log Message:
-----------
[note: do not test quite yet]

Phase 1 of restructuring done.  There are now two
distinct subclass systems within the bmesh API;
one is compile-time, and forms the backend of what will
eventually be a "lite" bmesh API for modifiers (the
ones that use bmesh are simply too slow right now). 
The other is dynamic, and will be used to implement
multires reprojection.

The idea was to solve as many serious problems with
memory, speed, etc, at once as possible and set up others 
to be solved more easily later.

I've also added holes into the data structure, but not
the api; I don't plan to finish implementing that until
after bmesh gets into trunk.  I simply wanted to lessen
how much code I'll have to rewrite, since I was doing a
fairly major restructuring anyway.

In addition, I've added iteration support to mempool, to
avoid having to store linked list pointers (though this
has caveats).

Next step: merge in trunk changes. . .oh, what fun :P

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_structure.c
    branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2010-07-15 00:52:26 UTC (rev 30355)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2010-07-15 00:55:31 UTC (rev 30356)
@@ -88,6 +88,53 @@
 	return 0;
 }
 
+/*
+ *	BMESH MAKE MESH
+ *
+ *  Allocates a new BMesh structure.
+ *  Returns -
+ *  Pointer to a BM
+ *
+*/
+
+BMesh *BM_Make_Mesh(int allocsize[4])
+{
+	/*allocate the structure*/
+	BMesh *bm = MEM_callocN(sizeof(BMesh),"BM");
+	int vsize, esize, lsize, fsize, lstsize;
+	int baselevel = LAYER_ADJ;
+
+	if (baselevel == LAYER_BASE) {
+		vsize = sizeof(BMBaseVert);
+		esize = sizeof(BMBaseEdge);
+		lsize = sizeof(BMBaseLoop);
+		fsize = sizeof(BMBaseFace);
+		lstsize = sizeof(BMBaseLoopList);
+	} else {
+		vsize = sizeof(BMVert);
+		esize = sizeof(BMEdge);
+		lsize = sizeof(BMLoop);
+		fsize = sizeof(BMFace);
+		lstsize = sizeof(BMLoopList);
+	}
+
+	bm->baselevel = baselevel;
+
+/*allocate the memory pools for the mesh elements*/
+	bm->vpool = BLI_mempool_create(vsize, allocsize[0], allocsize[0], 0, 1);
+	bm->epool = BLI_mempool_create(esize, allocsize[1], allocsize[1], 0, 1);
+	bm->lpool = BLI_mempool_create(lsize, allocsize[2], allocsize[2], 0, 0);
+	bm->looplistpool = BLI_mempool_create(lstsize, allocsize[3], allocsize[3], 0, 0);
+	bm->fpool = BLI_mempool_create(fsize, allocsize[3], allocsize[3], 0, 1);
+
+	/*allocate one flag pool that we dont get rid of.*/
+	bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, 0, 0);
+	bm->stackdepth = 0;
+	bm->totflags = 1;
+
+	return bm;
+}
+
 /*	
  *	BMESH FREE MESH
  *
@@ -129,11 +176,21 @@
 	/*destroy element pools*/
 	BLI_mempool_destroy(bm->vpool);
 	BLI_mempool_destroy(bm->epool);
+	BLI_mempool_destroy(bm->lpool);
 	BLI_mempool_destroy(bm->fpool);
-	BLI_mempool_destroy(bm->lpool);
 
+	if (bm->svpool)
+		BLI_mempool_destroy(bm->svpool);
+	if (bm->sepool)
+		BLI_mempool_destroy(bm->sepool);
+	if (bm->slpool)
+		BLI_mempool_destroy(bm->slpool);
+	if (bm->sfpool)
+		BLI_mempool_destroy(bm->sfpool);
+
 	/*destroy flag pool*/
 	BLI_mempool_destroy(bm->toolflagpool);
+	BLI_mempool_destroy(bm->looplistpool);
 
 	BLI_freelistN(&bm->selected);
 

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c	2010-07-15 00:52:26 UTC (rev 30355)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c	2010-07-15 00:55:31 UTC (rev 30356)
@@ -798,17 +798,17 @@
 	for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)){
 		oldflags = v->head.flags;
 		v->head.flags = BLI_mempool_calloc(bm->toolflagpool);
-		memcpy(v->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); /*dont know if this memcpy usage is correct*/
+		memcpy(v->head.flags, oldflags, sizeof(BMFlagLayer)*(bm->totflags-1)); /*dont know if this memcpy usage is correct*/
 	}
 	for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)){
 		oldflags = e->head.flags;
 		e->head.flags = BLI_mempool_calloc(bm->toolflagpool);
-		memcpy(e->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags);
+		memcpy(e->head.flags, oldflags, sizeof(BMFlagLayer)*(bm->totflags-1));
 	}
 	for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)){
 		oldflags = f->head.flags;
 		f->head.flags = BLI_mempool_calloc(bm->toolflagpool);
-		memcpy(f->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags);
+		memcpy(f->head.flags, oldflags, sizeof(BMFlagLayer)*(bm->totflags-1));
 	}
 
 	BLI_mempool_destroy(oldpool);

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_structure.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_structure.c	2010-07-15 00:52:26 UTC (rev 30355)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_structure.c	2010-07-15 00:55:31 UTC (rev 30356)
@@ -156,7 +156,7 @@
 int bmesh_disk_append_edge(struct BMEdge *e, struct BMVert *v)
 {
 	if (!v->e) {
-		Link *e1 = bm_get_edge_link(e, v);
+		Link *e1 = (Link*)bm_get_edge_link(e, v);
 
 		v->e = e;
 		e1->next = e1->prev = (Link*)e;
@@ -411,10 +411,9 @@
 		l->radial_prev = e->l;
 		l->radial_next = e->l->radial_next;
 
-		if (e->l == e->l->radial_next)
-			e->l->radial_prev = e->l->radial_next = l;
-		else
-			e->l->radial_next = l;
+		e->l->radial_next->radial_prev = l;
+		e->l->radial_next = l;
+
 		e->l = l;
 	}
 }

Modified: branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2010-07-15 00:52:26 UTC (rev 30355)
+++ branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2010-07-15 00:55:31 UTC (rev 30356)
@@ -392,7 +392,7 @@
 								BM_FACES_OF_EDGE, l->e);
 						for (; f2; f2=BMIter_Step(&fiter)) {
 							if (f2 != f) {
-								BM_Join_Faces(bm, f, f2, l->e);
+								BM_Join_TwoFaces(bm, f, f2, l->e);
 								found2 = 1;
 								break;
 							}





More information about the Bf-blender-cvs mailing list