[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19149] branches/bmesh/blender/source/ blender/bmesh/intern/bmesh_polygon.c: yay tesselator is behaving.

Joseph Eagar joeedh at gmail.com
Sun Mar 1 02:04:29 CET 2009


Revision: 19149
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19149
Author:   joeedh
Date:     2009-03-01 02:03:52 +0100 (Sun, 01 Mar 2009)

Log Message:
-----------
yay tesselator is behaving.  seems to work ok now.  it's kindof slow, would be worth investigating faster methods someday, also get briggs more elegant method to work.  but don't want this to be a time sink.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c	2009-02-28 23:33:35 UTC (rev 19148)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_polygon.c	2009-03-01 01:03:52 UTC (rev 19149)
@@ -318,6 +318,10 @@
 	Normalize(v2);
 	
 	Crossf(v, v1, v2);
+
+	/*!! (turns nonzero into 1) is likely not necassary, 
+	  since '>' I *think* should always
+	  return 0 or 1, but I'm not totally sure. . .*/
 	return !!(v[2] > 0);
 }
 
@@ -339,7 +343,7 @@
 {
 	/*the hardcoded stuff here, 200000, 0.999, and 1.0001 may be problems
 	  in the future, not sure. - joeedh*/
-	static float outv[3] = {20000000.0f, 20000000.0f, 0.0f};
+	static float outv[3] = {2000.0f, 2000.0f, 0.0f};
 	float v1[3], v2[3], p[3], vv1[3], vv2[3], mid[3], a[3], b[3];
 	int i = 0, lcount=0;
 	
@@ -414,12 +418,10 @@
 		if (isear && !goodline(verts, v1->head.eflag2, v3->head.eflag2, nvert)) isear = 0;
 		if(isear){
 			angle = VecAngle3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]);
-			if(!bestear || angle < bestangle){
+			if(!bestear || ABS(angle-40.0) < bestangle){
 				bestear = l;
-				bestangle = angle;
+				bestangle = ABS(40.0-angle);
 			}
-			if(angle < 90.0)
-				break;
 		}
 		l = (BMLoop*)(l->head.next);
 	}
@@ -459,8 +461,9 @@
 		l = (BMLoop*)(l->head.next);
 	}while(l != f->loopbase);
 	
-	bmesh_update_face_normal(bm, f, projectverts);
+	//bmesh_update_face_normal(bm, f, projectverts);
 
+	compute_poly_normal(f->no, projectverts, f->len);	
 	compute_poly_plane(projectverts, i);
 	poly_rotate_plane(f->no, projectverts, i);
 	
@@ -473,6 +476,11 @@
 		if(l) {
 			done = 0;
 			f = bmesh_sfme(bm, f, ((BMLoop*)(l->head.prev))->v, ((BMLoop*)(l->head.next))->v, &newl);
+			if (!f) {
+				printf("yeek! triangulator failed to split face!\n");
+				break;
+			}
+
 			BMO_SetFlag(bm, newl->e, newedgeflag);
 			BMO_SetFlag(bm, f, newfaceflag);
 		}
@@ -482,7 +490,12 @@
 		l = f->loopbase;
 		while (l->f->len > 3){
 			nextloop = ((BMLoop*)(l->head.next->next));
-			bmesh_sfme(bm, l->f, l->v,nextloop->v, &newl);
+			f = bmesh_sfme(bm, l->f, l->v,nextloop->v, &newl);
+			if (!f) {
+				printf("triangle fan step of triangulator failed.\n");
+				return;
+			}
+
 			BMO_SetFlag(bm, newl->e, newedgeflag);
 			BMO_SetFlag(bm, f, newfaceflag);
 			l = nextloop;





More information about the Bf-blender-cvs mailing list