[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11901] branches/soc-2007-red_fox/source/ blender: Bevel weights option for modifier; max limits per corner now

Levi Schooley redfox at hhofministries.org
Fri Aug 31 01:20:55 CEST 2007


Revision: 11901
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11901
Author:   red_fox
Date:     2007-08-31 01:20:55 +0200 (Fri, 31 Aug 2007)

Log Message:
-----------
Bevel weights option for modifier; max limits per corner now

Several little changes, the biggest being:
1. Edge crease and vertex weight options have been replaced 
by a custom bevel weight, set in editmode (Ctrl-Shift-E). You 
can set bevel weights per-vertex in vert selection mode, or 
per-edge in edge selection mode. Per-vert bevel weights only 
work when the "Verts only" option is enabled in the modifier.
2. Max limits have been moved, now, from entire mesh, to 
per-edge, to per-poly, to (currently) per-corner. Per-corner 
is the best solution, in my opinion, so this is where it 
stays. This eliminates "tearing," and even seems to correct 
some other issues and bugs.
3. Beveling for wire edges has been updated to have the same 
functionality as the rest of the beveling tool. (Had been 
neglected for some time.)
4. The editmode tool's header has been revamped to more 
intuitively guide the user on the status and use of the tool 
while it is in operation.

There are also a few other things such as bug fixes and 
tweaks that are two small to mention.

Levi

Modified Paths:
--------------
    branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h
    branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c
    branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c
    branches/soc-2007-red_fox/source/blender/blenkernel/intern/DerivedMesh.c
    branches/soc-2007-red_fox/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2007-red_fox/source/blender/blenkernel/intern/modifier.c
    branches/soc-2007-red_fox/source/blender/blenlib/BLI_editVert.h
    branches/soc-2007-red_fox/source/blender/makesdna/DNA_meshdata_types.h
    branches/soc-2007-red_fox/source/blender/src/buttons_editing.c
    branches/soc-2007-red_fox/source/blender/src/drawobject.c
    branches/soc-2007-red_fox/source/blender/src/editmesh.c
    branches/soc-2007-red_fox/source/blender/src/space.c
    branches/soc-2007-red_fox/source/blender/src/transform.c
    branches/soc-2007-red_fox/source/blender/src/transform_conversions.c

Modified: branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h
===================================================================
--- branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h	2007-08-30 22:02:32 UTC (rev 11900)
+++ branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h	2007-08-30 23:20:55 UTC (rev 11901)
@@ -86,6 +86,7 @@
 	int eflag1, eflag2;								/*reserved for use by eulers*/
 	int tflag1, tflag2;								/*reserved for use by tools*/
 	unsigned short flag, h;
+	float bweight;
 } BME_Vert;
 
 typedef struct BME_Edge
@@ -121,6 +122,7 @@
 {
 	struct BME_Poly *next, *prev;
 	int EID;
+	//~ float no[3];
 	struct BME_Loop *loopbase;						/*First editloop around Polygon.*/
 	struct ListBase holes;							/*list of inner loops in the face*/
 	unsigned int len;								/*total length of the face. Eulers should preserve this data*/
@@ -195,8 +197,9 @@
 #define BME_BEVEL_VERT			(1<<1)
 #define BME_BEVEL_RADIUS		(1<<2)
 #define BME_BEVEL_ANGLE			(1<<3)
-#define BME_BEVEL_EWEIGHT		(1<<4)
-#define BME_BEVEL_VWEIGHT		(1<<5)
+#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)
@@ -214,7 +217,7 @@
 	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
+	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;
@@ -236,6 +239,7 @@
 
 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);
 
 /*CONVERSION FUNCTIONS*/

Modified: branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c
===================================================================
--- branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c	2007-08-30 22:02:32 UTC (rev 11900)
+++ branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c	2007-08-30 23:20:55 UTC (rev 11901)
@@ -79,6 +79,7 @@
 		VECCOPY(v1->no,eve->no);
 		v1->flag = eve->f;
 		v1->h = eve->h;
+		v1->bweight = eve->bweight;
 
 		/* link the verts for edge and face construction;
 		 * kind of a dangerous thing - remember to cast back to BME_Vert before using! */
@@ -183,6 +184,7 @@
 		evlist[i]= eve1;
 		eve1->f = (unsigned char)v1->flag;
 		eve1->h = (unsigned char)v1->h;
+		eve1->bweight = v1->bweight;
 		CustomData_em_copy_data(&bm->vdata, &em->vdata, v1->data, &eve1->data);
 	}
 	
@@ -275,6 +277,7 @@
 		v1 = BME_MV(bm,mv->co);
 		vert_array[i] = v1;
 		v1->flag = mv->flag;
+		v1->bweight = mv->bweight/255.0f;
 		CustomData_to_em_block(&dm->vertData, &bm->vdata, i, &v1->data);
 	}
 	/*add edges*/
@@ -357,6 +360,7 @@
 		v1->tflag1 = i;
 		VECCOPY(mv->co,v1->co);
 		mv->flag = (unsigned char)v1->flag;
+		mv->bweight = (char)(255.0*v1->bweight);
 		CustomData_from_em_block(&bm->vdata, &result->vertData, v1->data, i);
 	}
 	medge = CDDM_get_edges(result);

Modified: branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c
===================================================================
--- branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c	2007-08-30 22:02:32 UTC (rev 11900)
+++ branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c	2007-08-30 23:20:55 UTC (rev 11901)
@@ -29,7 +29,7 @@
  *
  * The Original Code is: all of this file.
  *
- * Contributor(s): Geoffrey Bantle.
+ * Contributor(s): Geoffrey Bantle and Levi Schooley.
  *
  * ***** END GPL/BL DUAL LICENSE BLOCK *****
  */
@@ -193,7 +193,7 @@
 
 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) {
+		float factor, float weight, float maxfactor, float *max) {
 	BME_TransData *vtd;
 	int is_new = 0;
 
@@ -211,11 +211,7 @@
 	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 && is_new) {
-		VECCOPY(vtd->vec,v->no); /* default */
-		Normalize(vtd->vec);
-	}
-	else if (vec != NULL) {
+	if (vec != NULL) {
 		VECCOPY(vtd->vec,vec);
 		Normalize(vtd->vec);
 	}
@@ -235,6 +231,11 @@
 	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;
@@ -340,6 +341,7 @@
 	len = VecLength(nv->co);
 	VECADDFAC(nv->co,v->co,nv->co,len*percent);
 	nv->flag = v->flag;
+	nv->bweight = v->bweight;
 	if (ne) {
 		(*ne)->flag = e->flag;
 		(*ne)->h = e->h;
@@ -458,7 +460,7 @@
 			e1 = e2;
 		}
 		sv = BME_split_edge(bm,v,e1,&ne,0);
-		BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, -1); /* quick default */
+		BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
 		sv->tflag1 |= BME_BEVEL_BEVEL;
 		ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
 		BME_bevel_get_vec(vec1,v1,v,td);
@@ -497,7 +499,7 @@
 		else {
 			is_split_vert = 0;
 			sv = BME_split_edge(bm,v,l->e,&ne,0);
-			BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, -1); /* quick default */
+			BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */
 			sv->tflag1 |= BME_BEVEL_BEVEL;
 			ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
 		}
@@ -523,10 +525,15 @@
 			vtd1->weight = 0;
 		}
 		scale = vtd1->weight/vtd1->factor;
+		if (!vtd1->max) {
+			vtd1->max = BME_new_transdata_float(td);
+			*vtd1->max = -1;
+		}
 	}
 	else {
 		scale = vtd1->weight;
 	}
+	vtd->max = vtd1->max;
 
 	if (is_edge && vtd1->loc != NULL) {
 		maxfactor = vtd1->maxfactor;
@@ -546,30 +553,86 @@
 	VECSUB(vec1,sv->co,vtd1->org);
 	dis = VecLength(vec1);
 	Normalize(vec1);
-	//~ if (!(is_split_vert && dis == 0)) {
-		//~ if (dis == 0) {
-			//~ maxfactor = -1;
-		//~ }
-		BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd1->max);
-	//~ }
+	BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd->max);
 
 	return sv;
 }
 
+float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_TransData_Head *td) {
+	BME_TransData *vtd1, *vtd2;
+	float max, fac1, fac2, vec1[3], vec2[3], vec3[3];
+
+	BME_bevel_get_vec(vec1,v1,v2,td);
+	vtd1 = BME_get_transdata(td,v1);
+	vtd2 = BME_get_transdata(td,v2);
+
+	if (vtd1->loc == NULL) {
+		fac1 = 0;
+	}
+	else {
+		VECCOPY(vec2,vtd1->vec);
+		VecMulf(vec2,vtd1->factor);
+		if (Inpf(vec1, vec1)) {
+			Projf(vec2,vec2,vec1);
+			fac1 = VecLength(vec2)/value;
+		}
+		else {
+			fac1 = 0;
+		}
+	}
+
+	if (vtd2->loc == NULL) {
+		fac2 = 0;
+	}
+	else {
+		VECCOPY(vec3,vtd2->vec);
+		VecMulf(vec3,vtd2->factor);
+		if (Inpf(vec1, vec1)) {
+			Projf(vec2,vec3,vec1);
+			fac2 = VecLength(vec2)/value;
+		}
+		else {
+			fac2 = 0;
+		}
+	}
+
+	if (fac1 || fac2) {
+		max = VecLength(vec1)/(fac1 + fac2);
+		if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
+			*vtd1->max = max;
+		}
+		if (vtd2->max && (*vtd2->max < 0 || max < *vtd2->max)) {
+			*vtd2->max = max;
+		}
+	}
+	else {
+		max = -1;
+	}
+
+	return max;
+}
+
 BME_Vert *BME_bevel_wire(BME_Mesh *bm, BME_Vert *v, float value, int res, int options, BME_TransData_Head *td) {
-	BME_Vert *v1, *v2;
+	BME_Vert *ov1, *ov2, *v1, *v2;
 
-	v1 = BME_edge_getothervert(v->edge, v);
-	v2 = BME_edge_getothervert(BME_disk_nextedge(v->edge, v), v);
+	ov1 = BME_edge_getothervert(v->edge, v);
+	ov2 = BME_edge_getothervert(BME_disk_nextedge(v->edge, v), v);
 
 	/* split the edges */
-	v1 = BME_bevel_split_edge(bm,v,v1,NULL,NULL,value,td);
-	v2 = BME_bevel_split_edge(bm,v,v2,NULL,NULL,value,td);
+	v1 = BME_bevel_split_edge(bm,v,ov1,NULL,NULL,value,td);
 	v1->tflag1 |= BME_BEVEL_NONMAN;
+	v2 = BME_bevel_split_edge(bm,v,ov2,NULL,NULL,value,td);
 	v2->tflag1 |= BME_BEVEL_NONMAN;
 
+	if (value > 0.5) {
+		BME_bevel_set_max(v1,ov1,value,td);
+		BME_bevel_set_max(v2,ov2,value,td);
+	}
+
 	/* remove the original vert */
-	BME_JEKV(bm,v->edge,v);
+	if (res) {
+		BME_JEKV(bm,v->edge,v);
+	}
 
 	return v1;
 }
@@ -705,7 +768,7 @@
 BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int options, BME_TransData_Head *td) {
 	BME_Loop *l, *ol;
 	BME_TransData *vtd1, *vtd2;
-	float up_vec[3], vec1[3], vec2[3], vec3[3], fac1, fac2, tmp_max, max = -1;
+	float up_vec[3], vec1[3], vec2[3], vec3[3], fac1, fac2, max = -1;
 	int len, i;
 
 	up_vec[0] = 0.0f;
@@ -772,19 +835,16 @@
 					}
 				}
 				if (fac1 || fac2) {
-					tmp_max = VecLength(vec1)/(fac1 + fac2);
-					if (max < 0 || tmp_max < max) {
-						max = tmp_max;
+					max = VecLength(vec1)/(fac1 + fac2);
+					if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
+						*vtd1->max = max;
 					}
+					if (vtd2->max && (*vtd2->max < 0 || max < *vtd2->max)) {
+						*vtd2->max = max;
+					}
 				}
 			}
 		}
-		for (i=0,len=f->len; i<len && max>0; i++,l=l->next) {
-			vtd1 = BME_get_transdata(td,l->v);
-			if (vtd1->max < 0 || max < vtd1->max) {
-				vtd1->max = max;
-			}
-		}
 	}
 
 	return l->f;
@@ -819,7 +879,7 @@
 	}
 	else {
 		/* we'll use vtd->loc == NULL to mark that this vert is not moving */
-		vtd = BME_assign_transdata(td, bm, v, v->co, NULL, NULL, NULL, factor, weight, -1, -1);
+		vtd = BME_assign_transdata(td, bm, v, v->co, NULL, NULL, NULL, factor, weight, -1, NULL);
 	}
 }
 
@@ -841,7 +901,7 @@
 	VECSUB(vec1,v1->co,v->co);
 	VECSUB(vec2,v2->co,v->co);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list