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 {