[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25564] branches/bmesh/blender/source/ blender: pre-merge commit; decided might as well get it over with.

Joseph Eagar joeedh at gmail.com
Sat Dec 26 09:47:39 CET 2009


Revision: 25564
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25564
Author:   joeedh
Date:     2009-12-26 09:47:38 +0100 (Sat, 26 Dec 2009)

Log Message:
-----------
pre-merge commit; decided might as well get it over with.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenlib/intern/math_vector_inline.c
    branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
    branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
    branches/bmesh/blender/source/blender/editors/transform/transform.c
    branches/bmesh/blender/source/blender/editors/transform/transform.h

Modified: branches/bmesh/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/math_vector_inline.c	2009-12-26 01:04:46 UTC (rev 25563)
+++ branches/bmesh/blender/source/blender/blenlib/intern/math_vector_inline.c	2009-12-26 08:47:38 UTC (rev 25564)
@@ -76,7 +76,7 @@
 {
 	r[0] += a[0];
 	r[1] += a[1];
-	r[1] += a[1];
+	r[2] += a[2];
 }
 
 MINLINE void add_v3_v3v3(float *r, float *a, float *b)
@@ -102,7 +102,7 @@
 {
 	r[0] -= a[0];
 	r[1] -= a[1];
-	r[1] -= a[1];
+	r[2] -= a[2];
 }
 
 MINLINE void sub_v3_v3v3(float *r, float *a, float *b)

Modified: branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2009-12-26 01:04:46 UTC (rev 25563)
+++ branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2009-12-26 08:47:38 UTC (rev 25564)
@@ -249,21 +249,11 @@
 
 	BMO_ITER(e, &oiter, bm, op, "edges", BM_EDGE) {
 		if (BM_Edge_FaceCount(e) == 2) {
-			BMO_SetFlag(bm, e->v1, VERT_MARK);
-			BMO_SetFlag(bm, e->v2, VERT_MARK);
-
 			BM_Join_Faces(bm, e->loop->f, 
 				      ((BMLoop*)e->loop->radial.next->data)->f,
 				      e);
 		}
 	}
-
-	//BMO_InitOpf(bm, &fop, "dissolvefaces faces=%ff", FACE_MARK);
-	//BMO_Exec_Op(bm, &fop);
-
-	//BMO_CopySlot(op, &fop, "regionout", "regionout");
-
-	//BMO_Finish_Op(bm, &fop);
 }
 
 static int test_extra_verts(BMesh *bm, BMVert *v)

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2009-12-26 01:04:46 UTC (rev 25563)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2009-12-26 08:47:38 UTC (rev 25564)
@@ -503,8 +503,7 @@
 				break;
 		}
 		
-		ele = BMIter_New(&iter, em->bm, type, NULL);
-		for ( ; ele; ele=BMIter_Step(&iter)) {
+		BM_ITER(ele, &iter, em->bm, type, NULL) {
 			if (flag & BM_SELECT) BM_Select(em->bm, ele, 0);
 			BM_ClearHFlag(ele, flag);
 		}

Modified: branches/bmesh/blender/source/blender/editors/transform/transform.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/transform/transform.c	2009-12-26 01:04:46 UTC (rev 25563)
+++ branches/bmesh/blender/source/blender/editors/transform/transform.c	2009-12-26 08:47:38 UTC (rev 25564)
@@ -3930,7 +3930,7 @@
 }
 
 /* ********************  Edge Slide   *************** */
-#if 1
+#if 0
 static int createSlideVerts(TransInfo *t) {
 #else
 static BMEdge *get_other_edge(BMesh *bm, BMVert *v, BMEdge *e)
@@ -3938,40 +3938,68 @@
 	BMIter iter;
 	BMEdge *e2;
 
-	BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) {
+	BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, v) {
 		if (BM_TestHFlag(e2, BM_SELECT) && e2 != e)
-			return e;
+			return e2;
 	}
 
 	return NULL;
 }
 
-static BMLoop *get_next_loop(BMesh *bm, BMVert *v, BMFace *f, 
-                             BMEdge *olde, BMEdge *nexte)
+static BMLoop *get_next_loop(BMesh *bm, BMVert *v, BMLoop *l, 
+                             BMEdge *olde, BMEdge *nexte, float vec[3])
 {
-	BMIter iter;
-	BMLoop *l, firstl;
+	BMLoop *firstl;
+	float a[3] = {0.0f, 0.0f, 0.0f}, n[3] = {0.0f, 0.0f, 0.0f};
+	int i=0;
 
-	BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) {
-		if (l->e == olde)
-			break;
-	}
-
 	firstl = l;
 	do {
 		l = BM_OtherFaceLoop(l->e, l->f, v);
 		if (l->radial.next->data == l)
 			return NULL;
 		
-		if (BM_OtherFaceLoop(l->e, l->f, v)->e == nexte)
+		if (l->e == nexte) {
+			if (i) {
+				mul_v3_fl(a, 1.0f / (float)i);
+			} else {
+				float f1[3], f2[3], f3[3], n[3];
+
+				sub_v3_v3v3(f1, BM_OtherEdgeVert(olde, v)->co, v->co);
+				sub_v3_v3v3(f2, BM_OtherEdgeVert(nexte, v)->co, v->co);
+
+				cross_v3_v3v3(f3, f1, l->f->no);
+				cross_v3_v3v3(a, f2, l->f->no);
+				mul_v3_fl(a, -1.0f);
+
+				add_v3_v3(a, f3);
+				mul_v3_fl(a, 0.5f);
+			}
+			
+			VECCOPY(vec, a);
+			return l;
+		} else {
+			sub_v3_v3v3(n, BM_OtherEdgeVert(l->e, l->v)->co, l->v->co);
+			add_v3_v3v3(a, a, n);
+			i += 1;
+		}
+
+		if (BM_OtherFaceLoop(l->e, l->f, v)->e == nexte) {
+			if (i)
+				mul_v3_fl(a, 1.0f / (float)i);
+			
+			VECCOPY(vec, a);
 			return BM_OtherFaceLoop(l->e, l->f, v);
+		}
 		
-		if (l->e == nexte)
-			return l;
-
 		l = l->radial.next->data;
 	} while (l != firstl); 
 
+	if (i)
+		mul_v3_fl(a, 1.0f / (float)i);
+	
+	VECCOPY(vec, a);
+	
 	return NULL;
 }
 
@@ -3979,21 +4007,22 @@
 {
 	Mesh *me = t->obedit->data;
 	BMEditMesh *em = me->edit_btmesh;
+	BMesh *bm = em->bm;
 	BMIter iter, iter2;
 	BMEdge *e, *e1, *e2;
-	BMVert *v, *first;
+	BMVert *v, *v2, *first;
 	BMLoop *l, *l1, *l2;
-	TransDataSlideVert *tempsv;
+	TransDataSlideVert *tempsv, *sv;
 	GHash **uvarray= NULL;
 	SlideData *sld = MEM_callocN(sizeof(*sld), "sld");
-	int  uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
-	int uvlay_idx;
 	TransDataSlideUv *slideuvs=NULL, *suv=NULL, *suv_last=NULL;
 	RegionView3D *v3d = t->ar->regiondata;
 	float projectMat[4][4];
 	float start[3] = {0.0f, 0.0f, 0.0f}, end[3] = {0.0f, 0.0f, 0.0f};
-	float vec[3], i, j;
+	float vec[3], vec2[3];
 	float totvec=0.0;
+	int uvlay_tot= CustomData_number_of_layers(&em->bm->pdata, CD_MTFACE);
+	int uvlay_idx, numsel, i, j;
 
 	if (!v3d) {
 		/*ok, let's try to survive this*/
@@ -4024,7 +4053,7 @@
 
 	BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 		if (BM_TestHFlag(e, BM_SELECT)) {
-			if (BM_Edge_FaceCount(e) > 2)
+			if (BM_Edge_FaceCount(e) > 2 || BM_Edge_FaceCount(e) == 0)
 				return 0; //can't handle more then 2 faces around an edge
 		}
 	}
@@ -4054,10 +4083,10 @@
 		if (!v)
 			break;
 
-		BMINDX_SET(v, 0);
+		BMINDEX_SET(v, 0);
 
 		if (!v->edge)
-			continue
+			continue;
 		
 		first = v;
 
@@ -4067,38 +4096,104 @@
 		/*first, rewind*/
 		numsel = 0;
 		do {
+			BMINDEX_SET(v, 0);
+
 			e = get_other_edge(bm, v, e);
 			if (!e) {
 				e = v->edge;
 				break;
 			}
 
-			v = BM_OtherEdgeVert(e, v);
 			numsel += 1;
-		} while (e != v->edge);
 
+			if (!BMINDEX_GET(BM_OtherEdgeVert(e, v)))
+				break;
+
+			v = BM_OtherEdgeVert(e, v);
+		} while (e != first->edge);
+
 		l1 = l2 = l = NULL;
+		l1 = e->loop;
+		l2 = e->loop->radial.next->data;
 
+		l = BM_OtherFaceLoop(l1->e, l1->f, v);
+		sub_v3_v3v3(vec, BM_OtherEdgeVert(l->e, v)->co, v->co);
+
+		if (l2 != l1) {
+			l = BM_OtherFaceLoop(l2->e, l2->f, v);
+			sub_v3_v3v3(vec2, BM_OtherEdgeVert(l->e, v)->co, v->co);
+		} else {
+			l2 = NULL;
+		}
+
 		/*iterate over the loop*/
 		first = v;
+		j = 0;
 		do {
 			TransDataSlideVert *sv = tempsv + j;
 
 			sv->v = v;
 			sv->origvert = *v;
+			VECCOPY(sv->upvec, vec);
+			if (l2)
+				VECCOPY(sv->downvec, vec2);
 
+			l = BM_OtherFaceLoop(l1->e, l1->f, v);
+			sv->up = BM_OtherEdgeVert(l->e, v);
+
+			if (l2) {
+				l = BM_OtherFaceLoop(l2->e, l2->f, v);
+				sv->down = BM_OtherEdgeVert(l->e, v);
+			}
+
+			v2=v, v = BM_OtherEdgeVert(e, v);
+
+			e1 = e;
 			e = get_other_edge(bm, v, e);
 			if (!e) {
-				e = v->edge;
+				sv = tempsv + j + 1;
+				sv->v = v;
+				sv->origvert = *v;
+				
+				l = BM_OtherFaceLoop(l1->e, l1->f, v);
+				sv->up = BM_OtherEdgeVert(l->e, v);
+
+				if (l2) {
+					l = BM_OtherFaceLoop(l2->e, l2->f, v);
+					sv->down = BM_OtherEdgeVert(l->e, v);
+				}
+
+				BMINDEX_SET(v, 0);
+				BMINDEX_SET(v2, 0);
+
+				j += 2;
 				break;
 			}
 
-			v = BM_OtherEdgeVert(e, v);
-			j += 1
-		} while (e != v->edge);
+			l1 = get_next_loop(bm, v, l1, e1, e, vec);
+			l2 = l2 ? get_next_loop(bm, v, l2, e1, e, vec2) : NULL;
+
+			j += 1;
+
+			BMINDEX_SET(v, 0);
+			BMINDEX_SET(v2, 0);
+		} while (e != first->edge && l1);
 	}
 
-	MEM_freeN(tempsv);
+	//EDBM_clear_flag_all(em, BM_SELECT);
+
+	sld->sv = tempsv;
+	sld->totsv = j;
+	
+	sld->start[0] = t->mval[0] - 40;
+	sld->start[1] = t->mval[1];
+
+	sld->end[0] = t->mval[0] + 40;
+	sld->end[1] = t->mval[1];
+	
+	t->customData = sld;
+
+	return 1;
 #endif
 #if 0
 	Mesh *me = t->obedit->data;
@@ -4632,6 +4727,25 @@
 
 int doEdgeSlide(TransInfo *t, float perc)
 {
+	SlideData *sld = t->customData;
+	TransDataSlideVert *svlist = sld->sv, *sv;
+	float vec[3];
+	int i;
+
+	sv = svlist;
+	for (i=0; i<sld->totsv; i++, sv++) {
+		if (perc > 0.0f) {
+			VECCOPY(vec, sv->upvec);
+			mul_v3_fl(vec, perc);
+			add_v3_v3v3(sv->v->co, sv->origvert.co, vec);
+		} else {
+			VECCOPY(vec, sv->downvec);
+			mul_v3_fl(vec, perc);
+			add_v3_v3v3(sv->v->co, sv->origvert.co, vec);
+		}
+	}
+
+	return 1;
 #if 0
 	Mesh *me= t->obedit->data;
 	EditMesh *em = me->edit_mesh;
@@ -4738,8 +4852,9 @@
 		}
 
 	}
+
+	return 1;
 #endif
-	return 1;
 }
 
 int EdgeSlide(TransInfo *t, short mval[2])

Modified: branches/bmesh/blender/source/blender/editors/transform/transform.h
===================================================================
--- branches/bmesh/blender/source/blender/editors/transform/transform.h	2009-12-26 01:04:46 UTC (rev 25563)
+++ branches/bmesh/blender/source/blender/editors/transform/transform.h	2009-12-26 08:47:38 UTC (rev 25564)
@@ -195,16 +195,23 @@
 	struct BMVert vup, vdown;
 	struct BMVert origvert;
 
-	struct BMEdge *up, *down;
+	struct BMVert *up, *down;
 	struct BMVert *v;
+
+	float upvec[3], downvec[3];
 } TransDataSlideVert;
 
 typedef struct SlideData {
+	TransDataSlideVert *sv;
+	int totsv;
+
+	/*
 	TransDataSlideUv *slideuv, *suv_last;
 	int totuv, uvlay_tot;
 	struct GHash *vhash, **uvhash;
 	struct EditVert *nearest;
 	struct LinkNode *edgelist, *vertlist;
+	*/
 	short start[2], end[2];
 } SlideData;
 





More information about the Bf-blender-cvs mailing list