qbsp: hack to fix slightly off grid overlapping brushes having missing the overlapping parts deleted after CSG

fixes https://github.com/ericwa/tyrutils-ericw/issues/174
This commit is contained in:
Eric Wasylishen 2017-09-15 21:08:04 -06:00
parent 258f69a27f
commit 1ac4bf5a6b
1 changed files with 22 additions and 2 deletions

View File

@ -275,9 +275,29 @@ ClipInside(const face_t *clipface, bool precedence,
while (face) {
next = face->next;
/* HACK: Check for on-plane but not the same planenum
( https://github.com/ericwa/tyrutils-ericw/issues/174 )
*/
bool spurious_onplane = false;
{
vec_t dists[MAXEDGES + 1];
int sides[MAXEDGES + 1];
int counts[3];
CalcSides(&face->w, splitplane, sides, dists, counts);
if (counts[SIDE_ON] && !counts[SIDE_FRONT] && !counts[SIDE_BACK]) {
spurious_onplane = true;
}
}
/* Handle exactly on-plane faces */
if (face->planenum == clipface->planenum) {
if (clipface->planeside != face->planeside || precedence) {
if (face->planenum == clipface->planenum || spurious_onplane) {
const plane_t faceplane = Face_Plane(face);
const plane_t clipfaceplane = Face_Plane(clipface);
const vec_t dp = DotProduct(faceplane.normal, clipfaceplane.normal);
const bool opposite = (dp < 0);
if (opposite || precedence) {
/* always clip off opposite facing */
frags[clipface->planeside] = NULL;
frags[!clipface->planeside] = face;