[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54193] trunk/blender/source/blender: correction to r54188, also don't attempt to triangulate triangles.

Campbell Barton ideasman42 at gmail.com
Tue Jan 29 21:49:46 CET 2013


Revision: 54193
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54193
Author:   campbellbarton
Date:     2013-01-29 20:49:40 +0000 (Tue, 29 Jan 2013)
Log Message:
-----------
correction to r54188, also don't attempt to triangulate triangles.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54188

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/math_matrix.c
    trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
    trunk/blender/source/blender/bmesh/tools/bmesh_triangulate.c

Modified: trunk/blender/source/blender/blenlib/intern/math_matrix.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_matrix.c	2013-01-29 19:27:05 UTC (rev 54192)
+++ trunk/blender/source/blender/blenlib/intern/math_matrix.c	2013-01-29 20:49:40 UTC (rev 54193)
@@ -415,7 +415,6 @@
 {
 	r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
 	r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
-	r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
 }
 
 void mul_m3_v3(float M[3][3], float r[3])

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2013-01-29 19:27:05 UTC (rev 54192)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2013-01-29 20:49:40 UTC (rev 54193)
@@ -671,13 +671,14 @@
  * \brief Find Ear
  *
  * Used by tessellator to find the next triangle to 'clip off' of a polygon while tessellating.
+ *
  * \param f The face to search.
- * \param verts an array of face vert coords.
+ * \param projectverts an array of face vert coords.
  * \param use_beauty Currently only applies to quads, can be extended later on.
  * \param abscoss Must be allocated by caller, and at least f->len length
  *        (allow to avoid allocating a new one for each tri!).
  */
-static BMLoop *find_ear(BMFace *f, float (*projectverts)[2], const bool use_beauty, float *abscoss)
+static BMLoop *poly_find_ear(BMFace *f, float (*projectverts)[2], const bool use_beauty, float *abscoss)
 {
 	BMLoop *bestear = NULL;
 
@@ -826,15 +827,7 @@
 /**
  * \brief BMESH TRIANGULATE FACE
  *
- * --- Prev description (wasn’t correct, ear clipping was currently simply picking the first tri in the loop!)
- * Triangulates a face using a simple 'ear clipping' algorithm that tries to
- * favor non-skinny triangles (angles less than 90 degrees).
- *
- * If the triangulator has bits left over (or cannot triangulate at all)
- * it uses a simple fan triangulation,
- * --- End of prev description
- *
- * Currently tries to repeatedly find the best triangle (i.e. the most "open" one), provided it does not
+ * Currently repeatedly find the best triangle (i.e. the most "open" one), provided it does not
  * produces a "remaining" face with too much wide/narrow angles
  * (using cos (i.e. dot product of normalized vectors) of angles).
  *
@@ -842,7 +835,7 @@
  * with a length equal to (f->len - 2). It will be filled with the new
  * triangles.
  *
- * \note newedgeflag sets a flag layer flag, obviously not the header flag.
+ * \note use_tag tags new flags and edges.
  */
 void BM_face_triangulate(BMesh *bm, BMFace *f,
                          BMFace **r_faces_new,
@@ -871,7 +864,7 @@
 	bm->elem_index_dirty |= BM_VERT; /* see above */
 
 	while (f->len > 3) {
-		l_iter = find_ear(f, projectverts, use_beauty, abscoss);
+		l_iter = poly_find_ear(f, projectverts, use_beauty, abscoss);
 
 		/* force triangulation - if we can't find an ear the face is degenerate */
 		if (l_iter == NULL) {

Modified: trunk/blender/source/blender/bmesh/tools/bmesh_triangulate.c
===================================================================
--- trunk/blender/source/blender/bmesh/tools/bmesh_triangulate.c	2013-01-29 19:27:05 UTC (rev 54192)
+++ trunk/blender/source/blender/bmesh/tools/bmesh_triangulate.c	2013-01-29 20:49:40 UTC (rev 54193)
@@ -42,13 +42,17 @@
 
 	if (tag_only == false) {
 		BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
-			BM_face_triangulate(bm, face, NULL, use_beauty, false);
+			if (face->len > 3) {
+				BM_face_triangulate(bm, face, NULL, use_beauty, false);
+			}
 		}
 	}
 	else {
 		BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) {
 			if (BM_elem_flag_test(face, BM_ELEM_TAG)) {
-				BM_face_triangulate(bm, face, NULL, use_beauty, true);
+				if (face->len > 3) {
+					BM_face_triangulate(bm, face, NULL, use_beauty, true);
+				}
 			}
 		}
 	}




More information about the Bf-blender-cvs mailing list