qbsp: rest of fix for qbsp_q2_bmodel_collision, only needed on type-cleanup branch

This commit is contained in:
Eric Wasylishen 2022-06-07 19:49:39 -06:00
parent 0326374d68
commit 4941a86cbe
2 changed files with 18 additions and 1 deletions

View File

@ -53,3 +53,4 @@ void FreeBrushes(mapentity_t *ent);
int FindPlane(const qplane3d &plane, int *side);
int FindPositivePlane(int planenum);
int FindPositivePlane(const qplane3d &plane, int *side);

View File

@ -253,6 +253,22 @@ int FindPositivePlane(int planenum)
return FindPlane(-plane, nullptr);
}
int FindPositivePlane(const qplane3d &plane, int *side)
{
int planenum = FindPlane(plane, side);
int positive_plane = FindPositivePlane(planenum);
if (planenum == positive_plane) {
return planenum;
}
// planenum itself isn't positive, so flip the planeside and return the positive version
if (side) {
*side = !*side;
}
return positive_plane;
}
/*
=============================================================================
@ -394,7 +410,7 @@ static std::vector<face_t> CreateBrushFaces(const mapentity_t *src, hullbrush_t
plane.dist = qv::dot(plane.normal, point);
f.texinfo = hullnum > 0 ? 0 : mapface.texinfo;
f.planenum = FindPlane(plane, &f.planeside);
f.planenum = FindPositivePlane(plane, &f.planeside);
f.src_entity = const_cast<mapentity_t *>(src); // FIXME: get rid of consts on src in the callers?
CheckFace(&f, mapface);