Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-01-30 00:49:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-30 00:49:40 +0400
commitf02f491ed04b3427840c375de3fd62c9de59cd84 (patch)
treeea04d196ecfb44ca6ab38f21d658b0b896de9c46 /source/blender/bmesh
parente9678e74b071b5edd1fac233ac6dac5df821242f (diff)
correction to r54188, also don't attempt to triangulate triangles.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c19
-rw-r--r--source/blender/bmesh/tools/bmesh_triangulate.c8
2 files changed, 12 insertions, 15 deletions
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);
+ }
}
}
}