From 85a6b9095da572d3b4300e69b1382dc84196b4d3 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Tue, 20 Jun 2017 13:07:17 -0600 Subject: [PATCH] qbsp: refactor PlaneInvEqual --- include/qbsp/brush.hh | 4 ++-- qbsp/brush.cc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/qbsp/brush.hh b/include/qbsp/brush.hh index 41ed429f..17bd8b3b 100644 --- a/include/qbsp/brush.hh +++ b/include/qbsp/brush.hh @@ -42,7 +42,7 @@ brush_t *LoadBrush(const mapbrush_t *mapbrush, const vec3_t rotate_offset, const void FreeBrushes(brush_t *brushlist); int FindPlane(const qbsp_plane_t *plane, int *side); -int PlaneEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2); -int PlaneInvEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2); +bool PlaneEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2); +bool PlaneInvEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2); #endif diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 532efc27..8c6a7dd8 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -185,7 +185,7 @@ NormalizePlane(qbsp_plane_t *p) } -int +bool PlaneEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2) { return (fabs(p1->normal[0] - p2->normal[0]) < NORMAL_EPSILON && @@ -194,13 +194,13 @@ PlaneEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2) fabs(p1->dist - p2->dist) < DIST_EPSILON); } -int +bool PlaneInvEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2) { - return (fabs(p1->normal[0] + p2->normal[0]) < NORMAL_EPSILON && - fabs(p1->normal[1] + p2->normal[1]) < NORMAL_EPSILON && - fabs(p1->normal[2] + p2->normal[2]) < NORMAL_EPSILON && - fabs(p1->dist + p2->dist) < DIST_EPSILON); + qbsp_plane_t temp = {0}; + VectorScale(p1->normal, -1.0, temp.normal); + temp.dist = -p1->dist; + return PlaneEqual(&temp, p2); } /* Plane Hashing */