From 1909d4c520bfbebb34f361d2b16705a62f623c48 Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Sat, 24 May 2008 16:37:11 -0800 Subject: [PATCH] The rule for when to keep coplanar surfaces was very wrong; fix it. [git-p4: depot-paths = "//depot/solvespace/": change = 1740] --- graphicswin.cpp | 7 +++++-- mesh.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/graphicswin.cpp b/graphicswin.cpp index 3c48e48..9f70f1b 100644 --- a/graphicswin.cpp +++ b/graphicswin.cpp @@ -1189,9 +1189,12 @@ void GraphicsWindow::Paint(int w, int h) { SBsp3 *pb = SBsp3::FromMesh(mb); SMesh br; ZERO(&br); - br.flipNormal = true; br.keepCoplanar = false; + br.flipNormal = true; + br.keepCoplanar = false; br.AddAgainstBsp(mb, pa); - br.flipNormal = false; br.keepCoplanar = false; + + br.flipNormal = false; + br.keepCoplanar = false; br.AddAgainstBsp(ma, pb); dbp("triangles in = %d %d out = %d", ma->l.n, mb->l.n, br.l.n); diff --git a/mesh.cpp b/mesh.cpp index 8f69045..d92e671 100644 --- a/mesh.cpp +++ b/mesh.cpp @@ -104,10 +104,10 @@ void SBsp3::InsertInPlane(bool pos2, STriangle *tr, SMesh *m) { } ll = ll->more; } - - if(m->flipNormal && !pos2 && (!onFace || !sameNormal)) { + + if(m->flipNormal && ((!pos2 && !onFace) || (onFace && !sameNormal))) { m->AddTriangle(tr->c, tr->b, tr->a); - } else if(!(m->flipNormal) && (pos2 || + } else if(!(m->flipNormal) && ((pos2 && !onFace) || (onFace && sameNormal && m->keepCoplanar))) { m->AddTriangle(tr->a, tr->b, tr->c); @@ -153,6 +153,7 @@ alt: } else { // I suppose this actually is allowed to happen, if the coplanar // face is the leaf, and all of its neighbors are earlier in tree? + dbp("insert in plane"); InsertInPlane(false, tr, instead); } } else {