Merge branch 'brushbsp' of https://github.com/ericwa/ericw-tools into brushbsp

This commit is contained in:
Eric Wasylishen 2022-06-18 12:53:53 -06:00
commit 158c65b056
5 changed files with 24 additions and 8 deletions

View File

@ -75,6 +75,14 @@ public:
{
}
template<typename Iter, std::enable_if_t<is_iterator_v<Iter>, int> = 0>
constexpr aabb(Iter start, Iter end) : aabb()
{
for (auto it = start; it != end; it++) {
*this += *it;
}
}
constexpr bool operator==(const aabb &other) const { return m_mins == other.m_mins && m_maxs == other.m_maxs; }
constexpr const value_type &mins() const { return m_mins; }

View File

@ -95,7 +95,7 @@ static void CheckFace(face_t *face, const mapface_t &sourceface)
const qvec3d &p2 = face->w[(i + 1) % face->w.size()];
for (auto &v : p1)
if (v > options.worldextent.value() || v < -options.worldextent.value())
if (fabs(v) > options.worldextent.value())
FError("line {}: coordinate out of range ({})", sourceface.linenum, v);
/* check the point is on the face plane */

View File

@ -300,9 +300,18 @@ static std::list<face_t *> CSGFace_ClipAgainstSingleBrush(std::list<face_t *> in
return outside;
}
// fixme-brushbsp: determinism: sort `result` set by .map file order
struct brush_ptr_less
{
constexpr bool operator()(const brush_t *a, const brush_t *b) const
{
return a->file_order < b->file_order;
}
};
using brush_result_set_t = std::set<const brush_t *, brush_ptr_less>;
// fixme-brushbsp: add bounds test
static void GatherPossibleClippingBrushes_R(const node_t *node, const face_t *srcface, std::set<const brush_t *> &result)
static void GatherPossibleClippingBrushes_R(const node_t *node, const face_t *srcface, brush_result_set_t &result)
{
if (node->planenum == PLANENUM_LEAF) {
for (auto *brush : node->original_brushes) {
@ -322,9 +331,9 @@ GatherPossibleClippingBrushes
Starting a search at `node`, returns brushes that possibly intersect `srcface`.
==================
*/
static std::set<const brush_t *> GatherPossibleClippingBrushes(const mapentity_t* srcentity, const node_t *node, const face_t *srcface)
static brush_result_set_t GatherPossibleClippingBrushes(const mapentity_t* srcentity, const node_t *node, const face_t *srcface)
{
std::set<const brush_t *> result;
brush_result_set_t result;
GatherPossibleClippingBrushes_R(node, srcface, result);

View File

@ -436,8 +436,7 @@ void MakeTreePortals_r(node_t *node, portalstats_t &stats)
for (int i = 0; i < 3; i++)
{
// fixme-brushbsp: use proper map bounds
if (node->bounds.mins()[i] < -8000 || node->bounds.mins()[i] > 8000)
if (fabs(node->bounds.mins()[i]) > options.worldextent.value())
{
printf ("WARNING: node with unbounded volume\n");
break;

View File

@ -558,7 +558,7 @@ bool WindingIsHuge(const winding_t &w)
{
for (size_t i = 0; i < w.size(); i++) {
for (size_t j = 0; j < 3; j++)
if (w[i][j] < -8000 || w[i][j] > 8000)
if (fabs(w[i][j]) > options.worldextent.value())
return true;
}
return false;