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>2012-10-23 09:48:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-10-23 09:48:21 +0400
commitc29760566529c4d5ddbd74734d486fd17a3e5811 (patch)
treef3223beb1f2ffd33d59667bc1ab20c6155a589fd /source/blender/bmesh
parent1ea210a8dcab7f9123e8680844835c876c61b0e4 (diff)
fix for edge collapse decimator re-combining triangles that make degenerate quads.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_decimate_collapse.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/bmesh/intern/bmesh_decimate_collapse.c b/source/blender/bmesh/intern/bmesh_decimate_collapse.c
index cbc7c0dac9d..8f275f6f3d3 100644
--- a/source/blender/bmesh/intern/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/intern/bmesh_decimate_collapse.c
@@ -338,10 +338,27 @@ static void bm_decim_triangulate_end(BMesh *bm)
if (l_a_index != -1) {
const int l_b_index = BM_elem_index_get(l_b);
if (l_a_index == l_b_index) {
- /* highly unlikely to fail, but prevents possible double-ups */
- if (l_a->f->len == 3 && l_b->f->len == 3) {
- BMFace *f[2] = {l_a->f, l_b->f};
- BM_faces_join(bm, f, 2, TRUE);
+ if (LIKELY(l_a->f->len == 3 && l_b->f->len == 3)) {
+ if (l_a->v != l_b->v) { /* if this is the case, faces have become flipped */
+ /* check we are not making a degenerate quad */
+ BMVert *vquad[4] = {
+ e->v1,
+ BM_vert_in_edge(e, l_a->next->v) ? l_a->prev->v : l_a->next->v,
+ e->v2,
+ BM_vert_in_edge(e, l_b->next->v) ? l_b->prev->v : l_b->next->v,
+ };
+
+ BLI_assert(ELEM3(vquad[0], vquad[1], vquad[2], vquad[3]) == FALSE);
+ BLI_assert(ELEM3(vquad[1], vquad[0], vquad[2], vquad[3]) == FALSE);
+ BLI_assert(ELEM3(vquad[2], vquad[1], vquad[0], vquad[3]) == FALSE);
+ BLI_assert(ELEM3(vquad[3], vquad[1], vquad[2], vquad[0]) == FALSE);
+
+ if (is_quad_convex_v3(vquad[0]->co, vquad[1]->co, vquad[2]->co, vquad[3]->co)) {
+ /* highly unlikely to fail, but prevents possible double-ups */
+ BMFace *f[2] = {l_a->f, l_b->f};
+ BM_faces_join(bm, f, 2, TRUE);
+ }
+ }
}
}
}