qbsp: refactor BrushMostlyOnSide to take separate normal/dist

This commit is contained in:
Eric Wasylishen 2017-07-22 19:36:55 -06:00
parent b8dec3ed2b
commit 11a7e7bc88
3 changed files with 9 additions and 11 deletions

View File

@ -50,6 +50,6 @@ bool PlaneInvEqual(const qbsp_plane_t *p1, const qbsp_plane_t *p2);
bool BoundBrush (brush_t *brush);
vec_t BrushVolume (const brush_t *brush);
int BrushMostlyOnSide (const brush_t *brush, const plane_t *plane);
int BrushMostlyOnSide (const brush_t *brush, const vec3_t normal, vec_t dist);
#endif

View File

@ -1282,7 +1282,7 @@ BrushMostlyOnSide
from q3map
==================
*/
int BrushMostlyOnSide (const brush_t *brush, const plane_t *plane)
int BrushMostlyOnSide (const brush_t *brush, const vec3_t planenormal, vec_t planedist)
{
vec_t max;
int side;
@ -1296,7 +1296,7 @@ int BrushMostlyOnSide (const brush_t *brush, const plane_t *plane)
continue;
for (int j=0 ; j<w->numpoints ; j++) {
const vec_t d = DotProduct (w->points[j], plane->normal) - plane->dist;
const vec_t d = DotProduct (w->points[j], planenormal) - planedist;
if (d > max) {
max = d;
side = SIDE_FRONT;

View File

@ -156,11 +156,10 @@ TEST(qbsp, BrushVolume) {
TEST(qbsp, BrushMostlyOnSide1) {
brush_t *brush = load128x128x32Brush();
plane_t plane1;
VectorSet(plane1.normal, -1, 0, 0);
plane1.dist = -100;
vec3_t plane1normal = { -1, 0, 0 };
vec_t plane1dist = -100;
EXPECT_EQ(SIDE_FRONT, BrushMostlyOnSide(brush, &plane1));
EXPECT_EQ(SIDE_FRONT, BrushMostlyOnSide(brush, plane1normal, plane1dist));
FreeMem(brush, BRUSH, 1);
}
@ -168,11 +167,10 @@ TEST(qbsp, BrushMostlyOnSide1) {
TEST(qbsp, BrushMostlyOnSide2) {
brush_t *brush = load128x128x32Brush();
plane_t plane2;
VectorSet(plane2.normal, 1, 0, 0);
plane2.dist = 100;
vec3_t plane1normal = { 1, 0, 0 };
vec_t plane1dist = 100;
EXPECT_EQ(SIDE_BACK, BrushMostlyOnSide(brush, &plane2));
EXPECT_EQ(SIDE_BACK, BrushMostlyOnSide(brush, plane1normal, plane1dist));
FreeMem(brush, BRUSH, 1);
}