From c9eab719bc4078e5724ea4f66998e3ae1183adcd Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 3 Aug 2022 13:26:04 -0400 Subject: [PATCH] remove old code add visible on mapface_t although it's unused --- include/qbsp/map.hh | 1 + qbsp/brush.cc | 59 ++------------------------------------------- qbsp/map.cc | 29 +++++++++++++++++++++- 3 files changed, 31 insertions(+), 58 deletions(-) diff --git a/include/qbsp/map.hh b/include/qbsp/map.hh index 1d4aa611..7a2b0481 100644 --- a/include/qbsp/map.hh +++ b/include/qbsp/map.hh @@ -45,6 +45,7 @@ struct mapface_t int texinfo = 0; int linenum = 0; bool bevel = false; + bool visible = false; winding_t winding; // winding used to calculate bevels surfflags_t flags{}; diff --git a/qbsp/brush.cc b/qbsp/brush.cc index b24ded18..e639105a 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -227,62 +227,6 @@ void FreeBrushes(mapentity_t *ent) } #endif -#if 0 -/* -============ -ExpandBrush -============= -*/ -static void ExpandBrush(bspbrush_t &hullbrush, const aabb3d &hull_size) -{ - int x, s; - qbsp_plane_t plane; - int cBevEdge = 0; - - // create all the hull points - for (auto &f : facelist) - for (size_t i = 0; i < f.w.size(); i++) { - AddHullPoint(hullbrush, f.w[i], hull_size); - cBevEdge++; - } - - // expand all of the planes - for (auto &mapface : hullbrush->faces) { - if (mapface.flags.no_expand) - continue; - qvec3d corner{}; - for (x = 0; x < 3; x++) { - if (mapface.get_plane().get_normal()[x] > 0) - corner[x] = hull_size[1][x]; - else if (mapface.get_plane().get_normal()[x] < 0) - corner[x] = hull_size[0][x]; - } - qplane3d plane = mapface.get_plane(); - plane.dist += qv::dot(corner, plane.normal); - mapface.planenum = map.add_or_find_plane(plane); - } - - // add any axis planes not contained in the brush to bevel off corners - for (x = 0; x < 3; x++) - for (s = -1; s <= 1; s += 2) { - // add the plane - qvec3d normal = {}; - normal[x] = (vec_t)s; - plane.set_normal(normal); - if (s == -1) - plane.get_dist() = -hullbrush->bounds.mins()[x] + -hull_size[0][x]; - else - plane.get_dist() = hullbrush->bounds.maxs()[x] + hull_size[1][x]; - AddBrushPlane(hullbrush, plane); - } - - // add all of the edge bevels - for (auto &f : facelist) - for (size_t i = 0; i < f.w.size(); i++) - AddHullEdge(hullbrush, f.w[i], f.w[(i + 1) % f.w.size()], hull_size); -} -#endif - //============================================================================ contentflags_t Brush_GetContents(const mapbrush_t *mapbrush) @@ -625,8 +569,9 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int } qbsp_options.target_game->count_contents_in_stats(brush.contents, stats); - dst->brushes.push_back(std::make_unique(std::move(brush))); + dst->bounds += brush.bounds; + dst->brushes.push_back(std::make_unique(std::move(brush))); } logging::percent(src->mapbrushes.size(), src->mapbrushes.size(), src == map.world_entity()); diff --git a/qbsp/map.cc b/qbsp/map.cc index 18b2ef03..42007e57 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2165,6 +2165,8 @@ inline void CalculateBrushBounds(mapbrush_t &ob) ob.bounds = {}; for (size_t i = 0; i < ob.faces.size(); i++) { + ob.faces[i].visible = false; + const auto &plane = ob.faces[i].get_plane(); std::optional w = BaseWindingForPlane(plane); @@ -2181,7 +2183,7 @@ inline void CalculateBrushBounds(mapbrush_t &ob) if (w) { ob.faces[i].winding = w.value(); - //side->visible = true; + ob.faces[i].visible = true; for (auto &p : w.value()) { ob.bounds += p; } @@ -2290,6 +2292,31 @@ void ProcessMapBrushes() num_offset++; } } + +#if 0 + // test expansion + for (auto &brush : entity.mapbrushes) { + for (auto &face : brush.faces) { + qvec3d corner{}; + const qvec3d hull[] = {{ -16, -16, -24 }, { 16, 16, 32 }}; + for (int32_t x = 0; x < 3; x++) { + if (face.get_plane().get_normal()[x] > 0) { + corner[x] = hull[1][x]; + } else if (face.get_plane().get_normal()[x] < 0) { + corner[x] = hull[0][x]; + } + } + qplane3d plane = face.get_plane(); + plane.dist += qv::dot(corner, plane.normal); + face.planenum = map.add_or_find_plane(plane); + // ??? + //face.bevel = false; + } + + // re-calculate brush bounds/windings + CalculateBrushBounds(brush); + } +#endif } logging::print(logging::flag::STAT, " {:8} brushes\n", map.total_brushes);