NFC replace 2 nested loops with 1 loop and a lookup for speed improvement.
parent
bc4924ae47
commit
d974615d0e
|
@ -454,49 +454,48 @@ SSurface SSurface::MakeCopyTrimAgainst(SShell *parent,
|
||||||
SEdgeList inter = {};
|
SEdgeList inter = {};
|
||||||
|
|
||||||
SSurface *ss;
|
SSurface *ss;
|
||||||
for(ss = agnst->surface.First(); ss; ss = agnst->surface.NextAfter(ss)) {
|
SCurve *sc;
|
||||||
SCurve *sc;
|
for(sc = into->curve.First(); sc; sc = into->curve.NextAfter(sc)) {
|
||||||
for(sc = into->curve.First(); sc; sc = into->curve.NextAfter(sc)) {
|
if(sc->source != SCurve::Source::INTERSECTION) continue;
|
||||||
if(sc->source != SCurve::Source::INTERSECTION) continue;
|
if(opA) {
|
||||||
if(opA) {
|
if(sc->surfA != h) continue;
|
||||||
if(sc->surfA != h || sc->surfB != ss->h) continue;
|
ss = shb->surface.FindById(sc->surfB);
|
||||||
} else {
|
} else {
|
||||||
if(sc->surfB != h || sc->surfA != ss->h) continue;
|
if(sc->surfB != h) continue;
|
||||||
}
|
ss = sha->surface.FindById(sc->surfA);
|
||||||
|
}
|
||||||
|
int i;
|
||||||
|
for(i = 1; i < sc->pts.n; i++) {
|
||||||
|
Vector a = sc->pts[i-1].p,
|
||||||
|
b = sc->pts[i].p;
|
||||||
|
|
||||||
int i;
|
Point2d auv, buv;
|
||||||
for(i = 1; i < sc->pts.n; i++) {
|
ss->ClosestPointTo(a, &(auv.x), &(auv.y));
|
||||||
Vector a = sc->pts[i-1].p,
|
ss->ClosestPointTo(b, &(buv.x), &(buv.y));
|
||||||
b = sc->pts[i].p;
|
|
||||||
|
|
||||||
Point2d auv, buv;
|
SBspUv::Class c = (ss->bsp) ? ss->bsp->ClassifyEdge(auv, buv, ss) : SBspUv::Class::OUTSIDE;
|
||||||
ss->ClosestPointTo(a, &(auv.x), &(auv.y));
|
if(c != SBspUv::Class::OUTSIDE) {
|
||||||
ss->ClosestPointTo(b, &(buv.x), &(buv.y));
|
Vector ta = Vector::From(0, 0, 0);
|
||||||
|
Vector tb = Vector::From(0, 0, 0);
|
||||||
|
ret.ClosestPointTo(a, &(ta.x), &(ta.y));
|
||||||
|
ret.ClosestPointTo(b, &(tb.x), &(tb.y));
|
||||||
|
|
||||||
SBspUv::Class c = (ss->bsp) ? ss->bsp->ClassifyEdge(auv, buv, ss) : SBspUv::Class::OUTSIDE;
|
Vector tn = ret.NormalAt(ta.x, ta.y);
|
||||||
if(c != SBspUv::Class::OUTSIDE) {
|
Vector sn = ss->NormalAt(auv.x, auv.y);
|
||||||
Vector ta = Vector::From(0, 0, 0);
|
|
||||||
Vector tb = Vector::From(0, 0, 0);
|
|
||||||
ret.ClosestPointTo(a, &(ta.x), &(ta.y));
|
|
||||||
ret.ClosestPointTo(b, &(tb.x), &(tb.y));
|
|
||||||
|
|
||||||
Vector tn = ret.NormalAt(ta.x, ta.y);
|
// We are subtracting the portion of our surface that
|
||||||
Vector sn = ss->NormalAt(auv.x, auv.y);
|
// lies in the shell, so the in-plane edge normal should
|
||||||
|
// point opposite to the surface normal.
|
||||||
// We are subtracting the portion of our surface that
|
bool bkwds = true;
|
||||||
// lies in the shell, so the in-plane edge normal should
|
if((tn.Cross(b.Minus(a))).Dot(sn) < 0) bkwds = !bkwds;
|
||||||
// point opposite to the surface normal.
|
if((type == SSurface::CombineAs::DIFFERENCE && !opA) ||
|
||||||
bool bkwds = true;
|
(type == SSurface::CombineAs::INTERSECTION)) { // Invert all newly created edges for intersection
|
||||||
if((tn.Cross(b.Minus(a))).Dot(sn) < 0) bkwds = !bkwds;
|
bkwds = !bkwds;
|
||||||
if((type == SSurface::CombineAs::DIFFERENCE && !opA) ||
|
}
|
||||||
(type == SSurface::CombineAs::INTERSECTION)) { // Invert all newly created edges for intersection
|
if(bkwds) {
|
||||||
bkwds = !bkwds;
|
inter.AddEdge(tb, ta, sc->h.v, 1);
|
||||||
}
|
} else {
|
||||||
if(bkwds) {
|
inter.AddEdge(ta, tb, sc->h.v, 0);
|
||||||
inter.AddEdge(tb, ta, sc->h.v, 1);
|
|
||||||
} else {
|
|
||||||
inter.AddEdge(ta, tb, sc->h.v, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue