remove Face_Plane since we can directly access the real plane now

speed up CreateBrushWindings slightly since we know where the inverted plane is stored
This commit is contained in:
Jonathan 2022-08-08 01:06:50 -04:00
parent d2cfc0d025
commit 2abdeb2616
4 changed files with 11 additions and 29 deletions

View File

@ -80,8 +80,5 @@ struct bspbrush_t
using bspbrush_vector_t = std::vector<std::unique_ptr<bspbrush_t>>;
qplane3d Face_Plane(const face_t *face);
qplane3d Face_Plane(const side_t *face);
bspbrush_t LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, const contentflags_t &contents, const int hullnum);
void CreateBrushWindings(bspbrush_t *brush);

View File

@ -55,21 +55,6 @@ std::unique_ptr<bspbrush_t> bspbrush_t::copy_unique() const
return std::make_unique<bspbrush_t>(*this);
}
/*
=================
Face_Plane
=================
*/
qplane3d Face_Plane(const face_t *face)
{
return face->get_plane();
}
qplane3d Face_Plane(const side_t *face)
{
return face->get_plane();
}
/*
=================
CheckFace
@ -235,13 +220,13 @@ void CreateBrushWindings(bspbrush_t *brush)
for (int i = 0; i < brush->sides.size(); i++) {
side_t *side = &brush->sides[i];
w = BaseWindingForPlane(Face_Plane(side));
w = BaseWindingForPlane(side->get_plane());
for (int j = 0; j < brush->sides.size() && w; j++) {
if (i == j)
continue;
if (brush->sides[j].bevel)
continue;
qplane3d plane = -Face_Plane(&brush->sides[j]);
const qplane3d &plane = map.planes[brush->sides[j].planenum ^ 1];
w = w->clip(plane, qbsp_options.epsilon.value(), false)[SIDE_FRONT]; // CLIP_EPSILON);
}

View File

@ -136,8 +136,8 @@ static vec_t BrushVolume(const bspbrush_t &brush)
if (!side.w.size()) {
continue;
}
auto plane = Face_Plane(&side);
vec_t d = -(qv::dot(corner, plane.normal) - plane.dist);
auto &plane = side.get_plane();
vec_t d = -(qv::dot(corner, plane.get_normal()) - plane.get_dist());
vec_t area = side.w.area();
volume += d * area;
}
@ -465,7 +465,7 @@ static twosided<std::unique_ptr<bspbrush_t>> SplitBrush(std::unique_ptr<bspbrush
if (!w) {
break;
}
auto [frontOpt, backOpt] = w->clip(Face_Plane(&face));
auto [frontOpt, backOpt] = w->clip(face.get_plane());
w = backOpt;
}

View File

@ -1842,16 +1842,16 @@ TEST_CASE("BrushFromBounds") {
if (side.w.directional_equal(top_winding)) {
found++;
auto plane = Face_Plane(&side);
CHECK(plane.normal == qvec3d{0,0,1});
CHECK(plane.dist == 32);
auto &plane = side.get_plane();
CHECK(plane.get_normal() == qvec3d{0,0,1});
CHECK(plane.get_dist() == 32);
}
if (side.w.directional_equal(bottom_winding)) {
found++;
auto plane = Face_Plane(&side);
CHECK(plane.normal == qvec3d{0,0,-1});
CHECK(plane.dist == -2);
auto plane = side.get_plane();
CHECK(plane.get_normal() == qvec3d{0,0,-1});
CHECK(plane.get_dist() == -2);
}
}
CHECK(found == 2);