[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12304] branches/bmesh/source/blender: -> Post BConf Commit:

Geoffrey Bantle hairbat at yahoo.com
Sat Oct 20 16:57:17 CEST 2007


Revision: 12304
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12304
Author:   briggs
Date:     2007-10-20 16:57:16 +0200 (Sat, 20 Oct 2007)

Log Message:
-----------
-> Post BConf Commit:

Mostly work done while travelling to/from and during bconf:


-Remove doubles is back. Doesn't remove double faces yet though
-Edge collapse
-Edge Loop Select
-Edge Ring Select
-Select Linked/Select Linked All
-Face Select Mode
-Multiselect Mode
-PET Tool
-Ctrl-Tab selection mode switching


Also fixed small bug in Extrude code. Should behave better now.


Not that this also includes an initial commit of Levi Schooley's 
Bevel Tool. Don't try using it, it will crash 
(not his fault, I still have to bring transform code back in line
with trunk).

More stuff coming soon....

Modified Paths:
--------------
    branches/bmesh/source/blender/blenkernel/BKE_bmesh.h
    branches/bmesh/source/blender/blenkernel/intern/BME_structure.c
    branches/bmesh/source/blender/blenkernel/intern/BME_tools.c
    branches/bmesh/source/blender/include/BIF_editmesh.h
    branches/bmesh/source/blender/include/BIF_transform.h
    branches/bmesh/source/blender/include/editbmesh.h
    branches/bmesh/source/blender/include/transform.h
    branches/bmesh/source/blender/src/drawobject.c
    branches/bmesh/source/blender/src/editbmesh_interface.c
    branches/bmesh/source/blender/src/editbmesh_select.c
    branches/bmesh/source/blender/src/editbmesh_tools.c
    branches/bmesh/source/blender/src/editobject.c
    branches/bmesh/source/blender/src/space.c
    branches/bmesh/source/blender/src/toets.c
    branches/bmesh/source/blender/src/transform.c
    branches/bmesh/source/blender/src/transform_conversions.c

Added Paths:
-----------
    branches/bmesh/source/blender/blenkernel/intern/BME_bevel.c
    branches/bmesh/source/blender/blenkernel/intern/BME_traversals.c

Modified: branches/bmesh/source/blender/blenkernel/BKE_bmesh.h
===================================================================
--- branches/bmesh/source/blender/blenkernel/BKE_bmesh.h	2007-10-20 12:16:54 UTC (rev 12303)
+++ branches/bmesh/source/blender/blenkernel/BKE_bmesh.h	2007-10-20 14:57:16 UTC (rev 12304)
@@ -40,7 +40,11 @@
 #include "DNA_listBase.h"
 #include "BLI_ghash.h"
 #include "DNA_customdata_types.h"
+#include "BLI_memarena.h"
+#include "BLI_ghash.h"
 
+
+
 struct BME_Vert;
 struct BME_Edge;
 struct BME_Poly;
@@ -76,6 +80,9 @@
 	struct DerivedMesh 	*derivedFinal, *derivedCage;					/*Derived Meshes for this bmesh*/
 	struct RetopoPaintData *retopo_paint_data; 						/*here for temporary code compatibility only*/
 	int 				lastDataMask;
+	int options;										//bevel
+	int res;											//bevel
+	short imval[2];
 } BME_Mesh;
 
 /*Beginning of all mesh elements should share this layout!*/
@@ -99,6 +106,7 @@
 	float 			no[3];								/*vertex normal. Actually pointer to custom data block*/
 	struct BME_Edge		*edge;								/*first edge in the disk cycle for this vertex*/
 	void 				*data;								/*custom vertex data*/
+	float bweight;	//bevel remove me
 } BME_Vert;
 
 typedef struct BME_Edge
@@ -114,6 +122,7 @@
 	void 				*data;								/*custom edge data*/
 
 	float crease;
+	float bweight; //bevel remove me
 } BME_Edge;
 
 typedef struct BME_Loop 
@@ -147,9 +156,11 @@
 } BME_Poly;
 
 //*EDGE UTILITIES*/
+int BME_edge_shareface(struct BME_Edge *e1, struct BME_Edge *e2);
 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);
+int BME_vert_in_face(struct BME_Vert *v, struct BME_Poly *f);
 
 /*GENERAL CYCLE*/
 int BME_cycle_length(void *h);
@@ -230,12 +241,14 @@
 /*Vertex Tools*/
 void BME_connect_verts(struct BME_Mesh *bm);
 void BME_delete_verts(struct BME_Mesh *bm);
+int BME_remove_doubles(struct BME_Mesh *bm, float limit);
 /*Edge Tools*/
 struct BME_Vert  *BME_cut_edge(struct BME_Mesh *bm, BME_Edge *e, int numcuts);
 void BME_cut_edges(struct BME_Mesh *bm, int numcuts);
 void BME_dissolve_edges(struct BME_Mesh *bm);
 void BME_delete_edges(struct BME_Mesh *bm);
 void BME_connect_edges(struct  BME_Mesh *bm);
+void BME_collapse_edges(struct BME_Mesh *bm);
 /*Face Tools*/
 struct BME_Poly *BME_inset_poly(struct BME_Mesh *bm, struct BME_Poly *f);
 void BME_split_face(struct BME_Mesh *bm, struct BME_Poly *f);
@@ -244,4 +257,80 @@
 void BME_duplicate(struct BME_Mesh *bm);
 void BME_extrude_mesh(struct BME_Mesh *bm, int type);
 int BME_make_edgeface(struct BME_Mesh *bm);
+
+/*BME_traversals. c*/
+#define BME_RESTRICTWIRE 1
+#define BME_RESTRICTSELECT 2
+#define BME_RESTRICTVISIT 4
+void BME_MeshLoop_walk(struct BME_Mesh *bm, struct BME_Edge *se, void*(*func)(void *userData, struct BME_Edge *walkedge, struct BME_Vert *walkvert), void *userData, short restrictflag);
+void BME_MeshWalk(struct BME_Mesh *bm, struct BME_Vert *v, void(*func)(void *userData, struct BME_Edge *apply), void *userData, short restrictflag);
+struct BME_Edge *BME_edgeloop_nextedge(void *userData, struct BME_Edge *e, struct BME_Vert *sv);
+struct BME_Edge *BME_edgeshell_nextedge(void *userData, struct BME_Edge *e, struct BME_Vert *sv);
+void BME_MeshRing_walk(struct BME_Mesh *bm, struct BME_Edge *se, void*(*func)(void *userData, struct BME_Loop *walkloop), void *userData, short restrictflag);	
+struct BME_Edge *BME_edgering_nextedge(void *userData, struct BME_Loop *walkloop);
+
+
+/* bevel tool defines */
+/* element flags */
+#define BME_BEVEL_ORIG			1
+#define BME_BEVEL_BEVEL			(1<<1)
+#define BME_BEVEL_NONMAN		(1<<2)
+#define BME_BEVEL_WIRE			(1<<3)
+
+/* tool options */
+#define BME_BEVEL_SELECT		1
+#define BME_BEVEL_VERT			(1<<1)
+#define BME_BEVEL_RADIUS		(1<<2)
+#define BME_BEVEL_ANGLE			(1<<3)
+#define BME_BEVEL_WEIGHT		(1<<4)
+//~ #define BME_BEVEL_EWEIGHT		(1<<4)
+//~ #define BME_BEVEL_VWEIGHT		(1<<5)
+#define BME_BEVEL_PERCENT		(1<<6)
+#define BME_BEVEL_EMIN			(1<<7)
+#define BME_BEVEL_EMAX			(1<<8)
+#define BME_BEVEL_RUNNING		(1<<9)
+#define BME_BEVEL_RES			(1<<10)
+
+typedef struct BME_TransData {
+	BME_Mesh *bm; /* the bmesh the vert belongs to */
+	BME_Vert *v;  /* pointer to the vert this tdata applies to */
+	float co[3];  /* the original coordinate */
+	float org[3]; /* the origin */
+	float vec[3]; /* a directional vector; always, always normalize! */
+	void *loc;    /* a pointer to the data to transform (likely the vert's cos) */
+	float factor; /* primary scaling factor; also accumulates number of weighted edges for beveling tool */
+	float weight; /* another scaling factor; used primarily for propogating vertex weights to transforms; */
+	              /* weight is also used across recursive bevels to help with the math */
+	float maxfactor; /* the unscaled, original factor (used only by "edge verts" in recursive beveling) */
+	float *max;   /* the maximum distance this vert can be transformed; negative is infinite
+	               * it points to the "parent" maxfactor (where maxfactor makes little sense)
+	               * where the max limit is stored (limits are stored per-corner) */
+} BME_TransData;
+
+typedef struct BME_TransData_Head {
+	GHash *gh;       /* the hash structure for element lookup */
+	MemArena *ma;    /* the memory "pool" we will be drawing individual elements from */
+	int len;
+} BME_TransData_Head;
+
+typedef struct BME_Glob { /* stored in Global G for Transform() purposes */
+	BME_Mesh *bm;
+	BME_TransData_Head *td;
+	struct TransInfo *Trans; /* a pointer to the global Trans struct */
+	int imval[2]; /* for restoring original mouse co when initTransform() is called multiple times */
+	int options;
+	int res;
+} BME_Glob;
+
+struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BME_Vert *v);
+void BME_free_transdata(struct BME_TransData_Head *td);
+float *BME_bevel_calc_polynormal(struct BME_Poly *f, struct BME_TransData_Head *td);
+struct BME_Mesh *BME_bevel(struct BME_Mesh *bm, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd);
+
+
+
+
 #endif
+
+
+

Added: branches/bmesh/source/blender/blenkernel/intern/BME_bevel.c
===================================================================
--- branches/bmesh/source/blender/blenkernel/intern/BME_bevel.c	                        (rev 0)
+++ branches/bmesh/source/blender/blenkernel/intern/BME_bevel.c	2007-10-20 14:57:16 UTC (rev 12304)
@@ -0,0 +1,1196 @@
+/**
+ * BME_bevel.c    jan 2007
+ *
+ *	Beveling code for Bmesh
+ *
+ * $Id: BME_eulers.c,v 1.00 2007/01/17 17:42:01 Briggs Exp $
+ *
+ * ***** BEGIN GPL/BL DUAL 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): Levi Schooley
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_listBase.h"
+#include "DNA_object_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_global.h"
+#include "BKE_depsgraph.h"
+#include "BKE_utildefines.h"
+#include "BKE_bmesh.h"
+#include "BLI_memarena.h"
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "BLI_ghash.h"
+
+
+/* ------- Bevel code starts here -------- */
+
+BME_TransData_Head *BME_init_transdata(int bufsize) {
+	BME_TransData_Head *td;
+
+	td = MEM_callocN(sizeof(BME_TransData_Head), "BMesh transdata header");
+	td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp);
+	td->ma = BLI_memarena_new(bufsize);
+	BLI_memarena_use_calloc(td->ma);
+
+	return td;
+}
+
+void BME_free_transdata(BME_TransData_Head *td) {
+	BLI_ghash_free(td->gh,NULL,NULL);
+	BLI_memarena_free(td->ma);
+	MEM_freeN(td);
+}
+
+BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Vert *v,
+		float *co, float *org, float *vec, float *loc,
+		float factor, float weight, float maxfactor, float *max) {
+	BME_TransData *vtd;
+	int is_new = 0;
+
+	if (v == NULL) return NULL;
+
+	if ((vtd = BLI_ghash_lookup(td->gh, v)) == NULL && bm != NULL) {
+		vtd = BLI_memarena_alloc(td->ma, sizeof(*vtd));
+		BLI_ghash_insert(td->gh, v, vtd);
+		td->len++;
+		is_new = 1;
+	}
+
+	vtd->bm = bm;
+	vtd->v = v;
+	if (co != NULL) VECCOPY(vtd->co,co);
+	if (org == NULL && is_new) { VECCOPY(vtd->org,v->co); } /* default */
+	else if (org != NULL) VECCOPY(vtd->org,org);
+	if (vec != NULL) {
+		VECCOPY(vtd->vec,vec);
+		Normalize(vtd->vec);
+	}
+	vtd->loc = loc;
+
+	vtd->factor = factor;
+	vtd->weight = weight;
+	vtd->maxfactor = maxfactor;
+	vtd->max = max;
+
+	return vtd;
+}
+
+BME_TransData *BME_get_transdata(BME_TransData_Head *td, BME_Vert *v) {
+	BME_TransData *vtd;
+	vtd = BLI_ghash_lookup(td->gh, v);
+	return vtd;
+}
+
+/* a hack (?) to use the transdata memarena to allocate floats for use with the max limits */
+float *BME_new_transdata_float(BME_TransData_Head *td) {
+	return BLI_memarena_alloc(td->ma, sizeof(float));
+}
+
+int BME_is_nonmanifold_vert(BME_Mesh *bm, BME_Vert *v) {
+	BME_Edge *e, *oe;
+	BME_Loop *l;
+	int len, count, flag;
+
+	if (v->edge == NULL) {
+		/* loose vert */
+		return 1;
+	}
+
+	/* count edges while looking for non-manifold edges */
+	oe = v->edge;
+	for (len=0,e=v->edge; e != oe || (e == oe && len == 0); len++,e=BME_disk_nextedge(e,v)) {
+		if (e->loop == NULL) {
+			/* loose edge */
+			return 1;
+		}
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list