From 5cf82ee0235a3513224816a7d78ac7283af97d75 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 8 Oct 2021 19:04:11 -0600 Subject: [PATCH] qbsp: restore use of options.worldExtent should fix minor precision differences in .prt files --- bsputil/decompile.cpp | 2 +- include/common/polylib.hh | 6 +++--- include/qbsp/winding.hh | 5 +---- light/trace_embree.cc | 2 +- qbsp/qbsp.cc | 5 +++++ 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bsputil/decompile.cpp b/bsputil/decompile.cpp index 68e6b5ca..e24028a5 100644 --- a/bsputil/decompile.cpp +++ b/bsputil/decompile.cpp @@ -147,7 +147,7 @@ std::vector RemoveRedundantPlanes(const std::vector winding = winding_t::from_plane(normal, plane.distance); + std::optional winding = winding_t::from_plane(normal, plane.distance, 10e6); // clip `winding` by all of the other planes, flipped for (const decomp_plane_t &plane2 : planes) { diff --git a/include/common/polylib.hh b/include/common/polylib.hh index 152a0fa5..6bcbe8b8 100644 --- a/include/common/polylib.hh +++ b/include/common/polylib.hh @@ -420,7 +420,7 @@ public: return p; } - static winding_base_t from_plane(const qvec3d &normal, const vec_t &dist) + static winding_base_t from_plane(const qvec3d &normal, const vec_t &dist, const vec_t &worldextent) { /* find the major axis */ vec_t max = -VECT_MAX; @@ -452,8 +452,8 @@ public: qvec3d org = normal * dist; qvec3d vright = qv::cross(vup, normal); - vup *= 10e6; - vright *= 10e6; + vup *= worldextent; + vright *= worldextent; /* project a really big axis aligned box onto the plane */ winding_base_t w(4); diff --git a/include/qbsp/winding.hh b/include/qbsp/winding.hh index 74e15e7e..11f748d8 100644 --- a/include/qbsp/winding.hh +++ b/include/qbsp/winding.hh @@ -32,7 +32,4 @@ struct qbsp_plane_t : plane_t using winding_t = polylib::winding_base_t; -inline winding_t BaseWindingForPlane(const qbsp_plane_t *p) -{ - return winding_t::from_plane(p->normal, p->dist); -} +winding_t BaseWindingForPlane(const qbsp_plane_t *p); \ No newline at end of file diff --git a/light/trace_embree.cc b/light/trace_embree.cc index 1809d8a3..36698597 100644 --- a/light/trace_embree.cc +++ b/light/trace_embree.cc @@ -452,7 +452,7 @@ static void Leaf_MakeFaces( VectorScale(plane.normal, -1, faceplane.normal); faceplane.dist = -plane.dist; - std::optional winding = winding_t::from_plane(faceplane.normal, faceplane.dist); + std::optional winding = winding_t::from_plane(faceplane.normal, faceplane.dist, 10e6); // clip `winding` by all of the other planes for (const plane_t &plane2 : planes) { diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index dcd1bedb..58b7bea9 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -492,6 +492,11 @@ static void EmitAreaPortals(node_t *headnode) LogPrint(LOG_STAT, "{:5} numareaportals\n", map.bsp.dareaportals.size()); } +winding_t BaseWindingForPlane(const qbsp_plane_t *p) +{ + return winding_t::from_plane(p->normal, p->dist, options.worldExtent); +} + /* =============== ProcessEntity