[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18569] branches/bmesh/blender/source/ blender: added bmesh test op and made the dupeop.c stuff work, hopefully correctly.

Joseph Eagar joeedh at gmail.com
Mon Jan 19 03:35:27 CET 2009


Revision: 18569
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18569
Author:   joeedh
Date:     2009-01-19 03:35:26 +0100 (Mon, 19 Jan 2009)

Log Message:
-----------
added bmesh test op and made the dupeop.c stuff work, hopefully correctly.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/bmesh.h
    branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
    branches/bmesh/blender/source/blender/bmesh/editmesh_tools.c
    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_to_editmesh.c
    branches/bmesh/blender/source/blender/bmesh/intern/editmesh_to_bmesh.c
    branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c
    branches/bmesh/blender/source/blender/editors/mesh/editmesh_mods.c
    branches/bmesh/blender/source/blender/editors/mesh/mesh_intern.h
    branches/bmesh/blender/source/blender/editors/mesh/mesh_ops.c

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh.h	2009-01-19 02:26:46 UTC (rev 18568)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh.h	2009-01-19 02:35:26 UTC (rev 18569)
@@ -107,7 +107,7 @@
 	void *data;
 } BMNode;
 
-
+struct Scene;
 typedef struct BMesh {
 	ListBase verts, edges, polys;
 	struct BLI_mempool *vpool;
@@ -118,6 +118,7 @@
 	struct BMEdge **edar;
 	struct BMLoop **lpar;
 	struct BMFace **plar;
+	struct Scene *scene;
 	int vtarlen, edarlen, lparlen, plarlen;
 	int totvert, totedge, totface, totloop;	
 	int nextv, nexte, nextp, nextl;
@@ -169,7 +170,7 @@
 void bmesh_error(void);
 
 /*Mesh Level Ops */
-struct BMesh *BM_Make_Mesh(int allocsize[4]);
+struct BMesh *BM_Make_Mesh(int allocsize[4], struct Scene *scene);
 void BM_Free_Mesh(struct BMesh *bm);
 void BM_Compute_Normals(struct BMesh *bm);
 
@@ -198,7 +199,7 @@
 //void bmesh_data_interp_from_face(struct BMesh *bm, struct BMFace *source, struct BMFace *target);
 
 struct EditMesh;
-BMesh *editmesh_to_bmesh(struct EditMesh *em);
+BMesh *editmesh_to_bmesh(struct EditMesh *em, struct Scene *scene);
 struct EditMesh *bmesh_to_editmesh(BMesh *bm);
 
 /*include the rest of the API*/

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h	2009-01-19 02:26:46 UTC (rev 18568)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_operators.h	2009-01-19 02:35:26 UTC (rev 18569)
@@ -6,14 +6,16 @@
 #define BMOP_OPSLOT_INT			0
 #define BMOP_OPSLOT_FLT			1
 #define BMOP_OPSLOT_PNT			2
-#define BMOP_OPSLOT_VEC			3
+#define BMOP_OPSLOT_VEC			6
 
 /*after BMOP_OPSLOT_VEC, everything is 
-  dynamically allocated arrays*/
-#define BMOP_OPSLOT_INT_BUF		10	
-#define BMOP_OPSLOT_FLT_BUF		11		
-#define BMOP_OPSLOT_PNT_BUF		12
-#define BMOP_OPSLOT_TYPES		13
+  dynamically allocated arrays.  we
+  leave a space in the identifiers
+  for future growth.*/
+#define BMOP_OPSLOT_INT_BUF		7
+#define BMOP_OPSLOT_FLT_BUF		8		
+#define BMOP_OPSLOT_PNT_BUF		9
+#define BMOP_OPSLOT_TYPES		10
 
 typedef struct BMOpSlot{
 	int slottype;
@@ -69,8 +71,9 @@
 int BMO_CountFlag(struct BMesh *bm, int flag, int type);
 void BMO_Flag_To_Slot(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag, int type);
 void BMO_Flag_Buffer(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag);
+void BMO_HeaderFlag_To_Slot(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag, int type);
 
-/*--------------------begin operator defines------------------------*/
+/*------------begin operator defines (see bmesh_opdefines.c too)------------*/
 /*split op*/
 #define BMOP_SPLIT				0
 
@@ -99,6 +102,13 @@
 	BMOP_DEL_TOTSLOT,
 };
 
+#define DEL_VERTS		1
+#define DEL_EDGES		2
+#define DEL_ONLYFACES	3
+#define DEL_EDGESFACES	4
+#define DEL_FACES		5
+#define DEL_ALL			6
+
 /*BMOP_DEL_CONTEXT*/
 enum {
 	BMOP_DEL_VERTS = 1,
@@ -134,4 +144,12 @@
 extern BMOpDefine *opdefines[];
 extern int bmesh_total_ops;
 
+/*------specific operator helper functions-------*/
+
+/*executes the duplicate operation, feeding elements of 
+  type flag etypeflag and header flag flag to it.  note,
+  to get more useful information (such as the mapping from
+  original to new elements) you should run the dupe op manually.*/
+void BMOP_DupeFromFlag(struct BMesh *bm, int etypeflag, int flag);
+
 #endif

Modified: branches/bmesh/blender/source/blender/bmesh/editmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/editmesh_tools.c	2009-01-19 02:26:46 UTC (rev 18568)
+++ branches/bmesh/blender/source/blender/bmesh/editmesh_tools.c	2009-01-19 02:35:26 UTC (rev 18569)
@@ -2446,7 +2446,8 @@
 	
 	BMO_Set_PntBuf(&subdop, BMOP_ESUBDIVIDE_EDGES, list, tot);
 	BMO_Exec_Op(bm, &subdop);
-	
+	BMO_Finish_Op(bm, &subdop);
+
 	free_editMesh(G.editMesh);
 	bmesh_to_editmesh(bm);
 	BM_Free_Mesh(bm);

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2009-01-19 02:26:46 UTC (rev 18568)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c	2009-01-19 02:35:26 UTC (rev 18569)
@@ -97,7 +97,7 @@
  *
 */
 
-BMesh *BM_Make_Mesh(int allocsize[4])
+BMesh *BM_Make_Mesh(int allocsize[4], struct Scene *scene)
 {
 	/*allocate the structure*/
 	BMesh *bm = MEM_callocN(sizeof(BMesh),"BM");
@@ -106,6 +106,7 @@
 	bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize[1], allocsize[1]);
 	bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize[2], allocsize[2]);
 	bm->ppool = BLI_mempool_create(sizeof(BMFace), allocsize[3], allocsize[3]);
+	bm->scene = scene;
 
 	/*allocate one flag pool that we dont get rid of.*/
 	bm->flagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512);

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c	2009-01-19 02:26:46 UTC (rev 18568)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c	2009-01-19 02:35:26 UTC (rev 18569)
@@ -22,10 +22,13 @@
 	sizeof(int),
 	sizeof(float),
 	sizeof(void*),
+	0, /* unused */
+	0, /* unused */
+	0, /* unused */
 	sizeof(float)*3,
-	sizeof(int),
-	sizeof(float),
-	sizeof(void*)
+	sizeof(int),	/* int buffer */
+	sizeof(float),	/* float buffer */
+	sizeof(void*)	/* pointer buffer */
 };
 
 /*
@@ -455,17 +458,17 @@
 	/*now go through and memcpy all the flags. Loops don't get a flag layer at this time...*/
 	for(v = BMIter_New(&verts, bm, BM_VERTS, bm); v; v = BMIter_Step(&verts)){
 		oldflags = v->head.flags;
-		v->head.flags = BLI_mempool_alloc(bm->flagpool);
+		v->head.flags = BLI_mempool_calloc(bm->flagpool);
 		memcpy(v->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); /*dont know if this memcpy usage is correct*/
 	}
 	for(e = BMIter_New(&edges, bm, BM_EDGES, bm); e; e = BMIter_Step(&edges)){
 		oldflags = e->head.flags;
-		e->head.flags = BLI_mempool_alloc(bm->flagpool);
+		e->head.flags = BLI_mempool_calloc(bm->flagpool);
 		memcpy(e->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags);
 	}
 	for(f = BMIter_New(&faces, bm, BM_FACES, bm); f; f = BMIter_Step(&faces)){
 		oldflags = f->head.flags;
-		f->head.flags = BLI_mempool_alloc(bm->flagpool);
+		f->head.flags = BLI_mempool_calloc(bm->flagpool);
 		memcpy(f->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags);
 	}
 	bm->totflags++;

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_to_editmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_to_editmesh.c	2009-01-19 02:26:46 UTC (rev 18568)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_to_editmesh.c	2009-01-19 02:35:26 UTC (rev 18569)
@@ -1,243 +1,248 @@
-#include "MEM_guardedalloc.h"
-#include "BKE_customdata.h" 
-#include "DNA_listBase.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include <string.h>
-#include "BKE_utildefines.h"
-#include "BKE_mesh.h"
-#include "BKE_global.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_cdderivedmesh.h"
+#include "MEM_guardedalloc.h"
+#include "BKE_customdata.h" 
+#include "DNA_listBase.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include <string.h>
+#include "BKE_utildefines.h"
+#include "BKE_mesh.h"
+#include "BKE_global.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_cdderivedmesh.h"
+
+#include "BLI_editVert.h"
+#include "mesh_intern.h"
+#include "ED_mesh.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_edgehash.h"
+
+#include "bmesh.h"
+
+/*
+ * BMESH TO EDITMESH
+ *
+ * This file contains functions for converting 
+ * from a bmesh to an editmesh
+ *
+*/
+
+/*
+ * LOOPS TO EDITMESH CORNERS
+ *
+ * Converts N-Gon loop (face-edge)
+ * data (UVs, Verts Colors, ect) to
+ * face corner data.
+ *
+*/
+
+static void loops_to_editmesh_corners(BMesh *bm, CustomData *facedata, void *face_block, BMFace *f,int numCol, int numTex){
+	int i, j;
+	BMLoop *l;
+	MTFace *texface;
+	MTexPoly *texpoly;
+	MCol *mcol;
+	MLoopCol *mloopcol;
+	MLoopUV *mloopuv;
+
+	for(i=0; i < numTex; i++){
+		texface = CustomData_em_get_n(facedata, face_block, CD_MTFACE, i);
+		texpoly = CustomData_bmesh_get_n(&bm->pdata, f->data, CD_MTEXPOLY, i);
+		
+		texface->tpage = texpoly->tpage;
+		texface->flag = texpoly->flag;
+		texface->transp = texpoly->transp;
+		texface->mode = texpoly->mode;
+		texface->tile = texpoly->tile;
+		texface->unwrap = texpoly->unwrap;
+
+		j = 0;
+		l = f->loopbase;
+		do {
+			mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPUV, i);
+			texface->uv[j][0] = mloopuv->uv[0];
+			texface->uv[j][1] = mloopuv->uv[1];
+			j++;
+			l = ((BMLoop*)(l->head.next));
+		} while(l!=f->loopbase);
+
+	}
+
+	for(i=0; i < numCol; i++){
+		mcol = CustomData_em_get_n(facedata, face_block, CD_MCOL, i);
+		j = 0;
+		l = f->loopbase;
+		do {
+			mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->data, CD_MLOOPCOL, i);
+			mcol[j].r = mloopcol->r;
+			mcol[j].g = mloopcol->g;
+			mcol[j].b = mloopcol->b;
+			mcol[j].a = mloopcol->a;
+			j++;
+			l = ((BMLoop*)(l->head.next));
+		} while(l!=f->loopbase);
+	}
+}
+
+static EditVert *bmeshvert_to_editvert(BMesh *bm, EditMesh *em, BMVert *v, int index, EditVert **evlist)
+{
+	EditVert *eve = NULL;
+
+	v->head.eflag1 = index; /*abuse!*/
+	eve = addvertlist(em, v->co, NULL);
+	eve->keyindex = index;
+	evlist[index]= eve;
+	
+	/*copy flags*/
+	if(v->head.flag & BM_HIDDEN) eve->h = 1;
+	if (v->head.flag & BM_SELECT) eve->f |= SELECT;
+
+	eve->bweight = v->bweight;
+	CustomData_em_copy_data(&bm->vdata, &em->vdata, v->data, &eve->data);
+	/*copy normal*/
+	eve->no[0] = v->no[0];
+	eve->no[1] = v->no[1];
+	eve->no[2] = v->no[2];
+
+	return eve;
+}
+
+static void bmeshedge_to_editedge_internal(BMesh *bm, EditMesh *em, BMEdge *e, EditEdge *eed)
+{
+	eed->crease = e->crease;
+	eed->bweight = e->bweight;
+	
+	//copy relavent flags
+	if (e->head.flag & BM_SELECT) eed->f |= SELECT;
+	if (e->head.flag & BM_SEAM) eed->seam = 1;
+	if (e->head.flag & BM_SHARP) eed->sharp = 1;
+	if (e->head.flag & BM_HIDDEN) eed->h = 1;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list