diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-30 00:49:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-30 00:49:40 +0400 |
commit | f02f491ed04b3427840c375de3fd62c9de59cd84 (patch) | |
tree | ea04d196ecfb44ca6ab38f21d658b0b896de9c46 /source | |
parent | e9678e74b071b5edd1fac233ac6dac5df821242f (diff) |
correction to r54188, also don't attempt to triangulate triangles.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.c | 19 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_triangulate.c | 8 |
3 files changed, 12 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index b7e7fea897f..d31916c43c1 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -415,7 +415,6 @@ void mul_v2_m3v3(float r[2], float M[3][3], float a[3]) { 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]) diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index af8ae5f9454..80cee7b8910 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -671,13 +671,14 @@ static bool bm_face_goodline(float const (*projectverts)[2], BMFace *f, int v1i, * \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 @@ static BMLoop *find_ear(BMFace *f, float (*projectverts)[2], const bool use_beau /** * \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 @@ static BMLoop *find_ear(BMFace *f, float (*projectverts)[2], const bool use_beau * 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 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, 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) { diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c index 9948a15ea56..4ab5383f0b6 100644 --- a/source/blender/bmesh/tools/bmesh_triangulate.c +++ b/source/blender/bmesh/tools/bmesh_triangulate.c @@ -42,13 +42,17 @@ void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only) 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); + } } } } |