[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45904] branches/blender-2.62-editmesh/ source/blender/blenkernel/intern/BME_tools.c: style cleanup to old bmesh bevel, for the purpose of diffing with the one in bmesh (now trink), for the purpose of diffing.

Campbell Barton ideasman42 at gmail.com
Tue Apr 24 06:36:39 CEST 2012


Revision: 45904
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45904
Author:   campbellbarton
Date:     2012-04-24 04:36:38 +0000 (Tue, 24 Apr 2012)
Log Message:
-----------
style cleanup to old bmesh bevel, for the purpose of diffing with the one in bmesh (now trink), for the purpose of diffing.

Modified Paths:
--------------
    branches/blender-2.62-editmesh/source/blender/blenkernel/intern/BME_tools.c

Modified: branches/blender-2.62-editmesh/source/blender/blenkernel/intern/BME_tools.c
===================================================================
--- branches/blender-2.62-editmesh/source/blender/blenkernel/intern/BME_tools.c	2012-04-24 02:01:23 UTC (rev 45903)
+++ branches/blender-2.62-editmesh/source/blender/blenkernel/intern/BME_tools.c	2012-04-24 04:36:38 UTC (rev 45904)
@@ -51,19 +51,21 @@
 
 /* ------- Bevel code starts here -------- */
 
-BME_TransData_Head *BME_init_transdata(int bufsize) {
+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, "BME_init_transdata gh");
+	td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BME_init_transdata gh");
 	td->ma = BLI_memarena_new(bufsize, "BME_TransData arena");
 	BLI_memarena_use_calloc(td->ma);
 
 	return td;
 }
 
-void BME_free_transdata(BME_TransData_Head *td) {
-	BLI_ghash_free(td->gh,NULL,NULL);
+void BME_free_transdata(BME_TransData_Head *td)
+{
+	BLI_ghash_free(td->gh, NULL, NULL);
 	BLI_memarena_free(td->ma);
 	MEM_freeN(td);
 }
@@ -96,11 +98,11 @@
 		copy_v3_v3(vtd->org, v->co); /* default */
 	}
 	else if (org != NULL) {
-		copy_v3_v3(vtd->org,org);
+		copy_v3_v3(vtd->org, org);
 	}
 
 	if (vec != NULL) {
-		copy_v3_v3(vtd->vec,vec);
+		copy_v3_v3(vtd->vec, vec);
 		normalize_v3(vtd->vec);
 	}
 
@@ -114,18 +116,21 @@
 	return vtd;
 }
 
-BME_TransData *BME_get_transdata(BME_TransData_Head *td, BME_Vert *v) {
+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) {
+float *BME_new_transdata_float(BME_TransData_Head *td)
+{
 	return BLI_memarena_alloc(td->ma, sizeof(float));
 }
 
-static int BME_is_nonmanifold_vert(BME_Mesh *UNUSED(bm), BME_Vert *v) {
+static int BME_is_nonmanifold_vert(BME_Mesh *UNUSED(bm), BME_Vert *v)
+{
 	BME_Edge *e, *oe;
 	BME_Loop *l;
 	int len, count, flag;
@@ -137,7 +142,7 @@
 
 	/* 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)) {
+	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;
@@ -154,7 +159,7 @@
 	e = NULL;
 	oe = v->edge;
 	l = oe->loop;
-	while(e != oe) {
+	while (e != oe) {
 		if (l->v == v) l = l->prev;
 		else l = l->next;
 		e = l->e;
@@ -187,7 +192,8 @@
 
 /* a wrapper for BME_JFKE that [for now just] checks to
  * make sure loop directions are compatible */
-static BME_Poly *BME_JFKE_safe(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e) {
+static BME_Poly *BME_JFKE_safe(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e)
+{
 	BME_Loop *l1, *l2;
 
 	l1 = e->loop;
@@ -200,9 +206,10 @@
 }
 
 /* a wrapper for BME_SFME that transfers element flags */
-static BME_Poly *BME_split_face(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Loop **nl, BME_Edge *example) {
+static BME_Poly *BME_split_face(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Loop **nl, BME_Edge *example)
+{
 	BME_Poly *nf;
-	nf = BME_SFME(bm,f,v1,v2,nl);
+	nf = BME_SFME(bm, f, v1, v2, nl);
 	nf->flag = f->flag;
 	/* if the edge was selected, select this face, too */
 	if (example && (example->flag & SELECT)) f->flag |= ME_FACE_SEL;
@@ -225,9 +232,9 @@
 	void *src[2];
 	float w[2];
 	if (v1->data && v2->data) {
-		src[0]= v1->data;
-		src[1]= v2->data;
-		w[0] = 1.0f-fac;
+		src[0] = v1->data;
+		src[1] = v2->data;
+		w[0] = 1.0f - fac;
 		w[1] = fac;
 		CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, v->data);
 	}
@@ -235,22 +242,24 @@
 #endif
 
 
-static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *UNUSED(v2), BME_Vert *v, BME_Edge *e1, float fac){
+static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *UNUSED(v2), BME_Vert *v, BME_Edge *e1, float fac)
+{
 	void *src[2];
 	float w[2];
-	BME_Loop *l=NULL, *v1loop = NULL, *vloop = NULL, *v2loop = NULL;
+	BME_Loop *l = NULL, *v1loop = NULL, *vloop = NULL, *v2loop = NULL;
 	
 	w[0] = 1.0f - fac;
 	w[1] = fac;
 
-	if(!e1->loop) return;
+	if (!e1->loop) return;
 	l = e1->loop;
-	do{
-		if(l->v == v1){ 
+	do {
+		if (l->v == v1) {
 			v1loop = l;
 			vloop = v1loop->next;
 			v2loop = vloop->next;
-		}else if(l->v == v){
+		}
+		else if (l->v == v) {
 			v1loop = l->next;
 			vloop = l;
 			v2loop = l->prev;
@@ -260,23 +269,24 @@
 		src[0] = v1loop->data;
 		src[1] = v2loop->data;					
 
-		CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, vloop->data); 				
+		CustomData_bmesh_interp(&bm->ldata, src, w, NULL, 2, vloop->data);
 		l = l->radial.next->data;
-	}while(l!=e1->loop);
+	} while (l != e1->loop);
 }
 
 
 /* a wrapper for BME_SEMV that transfers element flags */ /*add custom data interpolation in here!*/
-static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge **ne, float percent) {
+static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge **ne, float percent)
+{
 	BME_Vert *nv, *v2;
 	float len;
 
-	v2 = BME_edge_getothervert(e,v);
-	nv = BME_SEMV(bm,v,e,ne);
+	v2 = BME_edge_getothervert(e, v);
+	nv = BME_SEMV(bm, v, e, ne);
 	if (nv == NULL) return NULL;
-	VECSUB(nv->co,v2->co,v->co);
+	VECSUB(nv->co, v2->co, v->co);
 	len = len_v3(nv->co);
-	VECADDFAC(nv->co,v->co,nv->co,len*percent);
+	VECADDFAC(nv->co, v->co, nv->co, len * percent);
 	nv->flag = v->flag;
 	nv->bweight = v->bweight;
 	if (ne) {
@@ -286,46 +296,48 @@
 		(*ne)->bweight = e->bweight;
 	}
 	/*v->nv->v2*/
-	BME_data_facevert_edgesplit(bm,v2, v, nv, e, 0.75);	
+	BME_data_facevert_edgesplit(bm, v2, v, nv, e, 0.75);
 	return nv;
 }
 
-static void BME_collapse_vert(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv, float fac){
+static void BME_collapse_vert(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv, float fac)
+{
 	void *src[2];
 	float w[2];
-	BME_Loop *l=NULL, *kvloop=NULL, *tvloop=NULL;
-	BME_Vert *tv = BME_edge_getothervert(ke,kv);
+	BME_Loop *l = NULL, *kvloop = NULL, *tvloop = NULL;
+	BME_Vert *tv = BME_edge_getothervert(ke, kv);
 
 	w[0] = 1.0f - fac;
 	w[1] = fac;
 
-	if(ke->loop){
+	if (ke->loop) {
 		l = ke->loop;
-		do{
-			if(l->v == tv && l->next->v == kv){
+		do {
+			if (l->v == tv && l->next->v == kv) {
 				tvloop = l;
 				kvloop = l->next;
 
 				src[0] = kvloop->data;
 				src[1] = tvloop->data;
-				CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, kvloop->data); 								
+				CustomData_bmesh_interp(&bm->ldata, src, w, NULL, 2, kvloop->data);
 			}
-			l=l->radial.next->data;
-		}while(l!=ke->loop);
+			l = l->radial.next->data;
+		} while (l != ke->loop);
 	}
-	BME_JEKV(bm,ke,kv);
+	BME_JEKV(bm, ke, kv);
 }
 
 
 
-static int BME_bevel_is_split_vert(BME_Loop *l) {
+static int BME_bevel_is_split_vert(BME_Loop *l)
+{
 	/* look for verts that have already been added to the edge when
 	 * beveling other polys; this can be determined by testing the
 	 * vert and the edges around it for originality
 	 */
-	if ((l->v->tflag1 & BME_BEVEL_ORIG)==0
-			&& (l->e->tflag1 & BME_BEVEL_ORIG)
-			&& (l->prev->e->tflag1 & BME_BEVEL_ORIG))
+	if ((l->v->tflag1 & BME_BEVEL_ORIG) == 0
+	    && (l->e->tflag1 & BME_BEVEL_ORIG)
+	    && (l->prev->e->tflag1 & BME_BEVEL_ORIG))
 	{
 		return 1;
 	}
@@ -340,8 +352,8 @@
 {
 	BME_TransData *vtd1, *vtd2;
 
-	vtd1 = BME_get_transdata(td,v1);
-	vtd2 = BME_get_transdata(td,v2);
+	vtd1 = BME_get_transdata(td, v1);
+	vtd2 = BME_get_transdata(td, v2);
 	if (!vtd1 || !vtd2) {
 		//printf("BME_bevel_get_vec() got called without proper BME_TransData\n");
 		return -1;
@@ -350,7 +362,7 @@
 	/* compare the transform origins to see if we can use the vert co's;
 	 * if they belong to different origins, then we will use the origins to determine
 	 * the vector */
-	if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) {
+	if (compare_v3v3(vtd1->org, vtd2->org, 0.000001f)) {
 		sub_v3_v3v3(vec, v2->co, v1->co);
 		if (len_v3(vec) < 0.000001f) {
 			zero_v3(vec);
@@ -358,7 +370,7 @@
 		return 0;
 	}
 	else {
-		sub_v3_v3v3(vec,vtd2->org,vtd1->org);
+		sub_v3_v3v3(vec, vtd2->org, vtd1->org);
 		if (len_v3(vec) < 0.000001f) {
 			zero_v3(vec);
 		}
@@ -377,25 +389,25 @@
  * returns the length of the projected vector that lies along vec1 */
 static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *UNUSED(td))
 {
-	float factor, vec3[3], tmp[3],c1,c2;
+	float factor, vec3[3], tmp[3], c1, c2;
 
-	cross_v3_v3v3(tmp,vec1,vec2);
+	cross_v3_v3v3(tmp, vec1, vec2);
 	normalize_v3(tmp);
-	factor = dot_v3v3(up_vec,tmp);
+	factor = dot_v3v3(up_vec, tmp);
 	if ((factor > 0 && is_forward) || (factor < 0 && !is_forward)) {
-		cross_v3_v3v3(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */
+		cross_v3_v3v3(vec3, vec2, tmp); /* hmm, maybe up_vec should be used instead of tmp */
 	}
 	else {
-		cross_v3_v3v3(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */
+		cross_v3_v3v3(vec3, tmp, vec2); /* hmm, maybe up_vec should be used instead of tmp */
 	}
 	normalize_v3(vec3);
-	c1 = dot_v3v3(vec3,vec1);
-	c2 = dot_v3v3(vec1,vec1);
+	c1 = dot_v3v3(vec3, vec1);
+	c2 = dot_v3v3(vec1, vec1);
 	if (fabsf(c1) < 0.000001f || fabsf(c2) < 0.000001f) {
 		factor = 0.0f;
 	}
 	else {
-		factor = c2/c1;
+		factor = c2 / c1;
 	}
 
 	return factor;
@@ -405,7 +417,8 @@
  * using the vert and the loop passed, get or make the split vert, set its coordinates
  * and transform properties, and set the max limits.
  * Finally, return the split vert. */
-static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, BME_Loop *l, float *up_vec, float value, BME_TransData_Head *td) {
+static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, BME_Loop *l, float *up_vec, float value, BME_TransData_Head *td)
+{
 	BME_TransData *vtd, *vtd1 /* , *vtd2 */ /* UNUSED */;
 	BME_Vert *sv, *v2, *v3 /* , *ov */ /* UNUSED */;
 	BME_Loop *lv1, *lv2;
@@ -442,16 +455,16 @@
 			e1 = e2;
 		}
 		/* ov = BME_edge_getothervert(e1,v); */ /* UNUSED */
-		sv = BME_split_edge(bm,v,e1,&ne,0);
+		sv = BME_split_edge(bm, v, e1, &ne, 0);
 		//BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list