diff --git a/include/qbsp/brush.hh b/include/qbsp/brush.hh index 1962ace4..6c1db835 100644 --- a/include/qbsp/brush.hh +++ b/include/qbsp/brush.hh @@ -42,7 +42,7 @@ int Brush_NumFaces(const brush_t *brush); brush_t *LoadBrush(const mapbrush_t *mapbrush, const vec3_t rotate_offset, const int hullnum); void FreeBrushes(brush_t *brushlist); -int FindPlane(const qbsp_plane_t *plane, int *side); +int FindPlane(const vec3_t normal, const vec_t dist, int *side); bool PlaneEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2); bool PlaneInvEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2); diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 844bc38f..f2bfe0a5 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -249,19 +249,23 @@ NewPlane(const vec3_t normal, const vec_t dist, int *side) * - Returns a global plane number and the side that will be the front */ int -FindPlane(const qbsp_plane_t *plane, int *side) +FindPlane(const vec3_t normal, const vec_t dist, int *side) { - for (int i : map.planehash[plane_hash_fn(plane)]) { + qbsp_plane_t plane = {0}; + VectorCopy(normal, plane.normal); + plane.dist = dist; + + for (int i : map.planehash[plane_hash_fn(&plane)]) { const qbsp_plane_t &p = map.planes.at(i); - if (PlaneEqual(&p, plane)) { + if (PlaneEqual(&p, &plane)) { *side = SIDE_FRONT; return i; - } else if (PlaneInvEqual(&p, plane)) { + } else if (PlaneInvEqual(&p, &plane)) { *side = SIDE_BACK; return i; } } - return NewPlane(plane->normal, plane->dist, side); + return NewPlane(plane.normal, plane.dist, side); } @@ -432,7 +436,7 @@ CreateBrushFaces(hullbrush_t *hullbrush, const vec3_t rotate_offset, FreeMem(w, WINDING, 1); f->texinfo = hullnum ? 0 : mapface->texinfo; - f->planenum = FindPlane(&plane, &f->planeside); + f->planenum = FindPlane(plane.normal, plane.dist, &f->planeside); f->next = facelist; facelist = f; CheckFace(f); diff --git a/qbsp/portals.cc b/qbsp/portals.cc index 183e2af2..d986aa1f 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -418,7 +418,7 @@ MakeHeadnodePortals(const mapentity_t *entity, node_t *node) pl->normal[i] = 1; pl->dist = bounds[j][i]; } - p->planenum = FindPlane(pl, &side); + p->planenum = FindPlane(pl->normal, pl->dist, &side); p->winding = BaseWindingForPlane(pl); if (side)