Improve boolean difference operations...

...by fixing the logic in KeepRegion() to properly keep/discard
regions where two surfaces coincide.

Now difference works as well as intersection in this respect.

Change inSame to coincSame for clarity.
This commit is contained in:
phkahler 2023-09-21 21:23:30 -04:00 committed by ruevs
parent 1919a18916
commit 1963a836ef

View File

@ -272,30 +272,33 @@ static bool KeepRegion(SSurface::CombineAs type, bool opA, SShell::Class shell,
{
bool inShell = (shell == SShell::Class::SURF_INSIDE),
outSide = (shell == SShell::Class::SURF_OUTSIDE),
inSame = (shell == SShell::Class::SURF_COINC_SAME),
coincSame = (shell == SShell::Class::SURF_COINC_SAME),
coincOpp = (shell == SShell::Class::SURF_COINC_OPP),
inOrig = (orig == SShell::Class::SURF_INSIDE);
// This one line is not really part of this functions logic
if(!inOrig) return false;
switch(type) {
case SSurface::CombineAs::UNION:
if(opA) {
return outSide;
} else {
return outSide || inSame;
return outSide || coincSame;
}
case SSurface::CombineAs::DIFFERENCE:
if(opA) {
return outSide;
return outSide || coincOpp;
} else {
return inShell || inSame;
return inShell;
}
case SSurface::CombineAs::INTERSECTION:
if(opA) {
return inShell;
} else {
return inShell || inSame;
return inShell || coincSame;
}
default: ssassert(false, "Unexpected combine type");