From a2ea5d821795429a3bbdf80e6329ad83837c0c7b Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 7 Aug 2023 15:33:09 -0600 Subject: [PATCH] style: remove all "using namespace polylib" --- common/decompile.cc | 10 ++++------ common/mathlib.cc | 4 +--- light/bounce.cc | 10 ++++------ light/surflight.cc | 8 +++----- light/trace_embree.cc | 15 +++++++-------- 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/common/decompile.cc b/common/decompile.cc index 61eb5dcb..7feb6de7 100644 --- a/common/decompile.cc +++ b/common/decompile.cc @@ -230,14 +230,12 @@ struct decomp_plane_t : qplane3d // brush creation -using namespace polylib; - template void RemoveRedundantPlanes(std::vector &planes) { auto removed = std::remove_if(planes.begin(), planes.end(), [&planes](const T &plane) { // outward-facing plane - std::optional winding = winding_t::from_plane(plane, 10e6); + std::optional winding = polylib::winding_t::from_plane(plane, 10e6); // clip `winding` by all of the other planes, flipped for (const T &plane2 : planes) { @@ -267,7 +265,7 @@ struct decomp_brush_face_t * The currently clipped section of the face. * May be nullopt to indicate it was clipped away. */ - std::optional winding; + std::optional winding; /** * The face we were originally derived from */ @@ -292,13 +290,13 @@ public: } decomp_brush_face_t(const mbsp_t *bsp, const mface_t *face) - : winding(winding_t::from_face(bsp, face)), + : winding(polylib::winding_t::from_face(bsp, face)), original_face(face) { buildInwardFacingEdgePlanes(); } - decomp_brush_face_t(std::optional &&windingToTakeOwnership, const mface_t *face) + decomp_brush_face_t(std::optional &&windingToTakeOwnership, const mface_t *face) : winding(std::move(windingToTakeOwnership)), original_face(face) { diff --git a/common/mathlib.cc b/common/mathlib.cc index 1c682cae..4ff9c2cd 100644 --- a/common/mathlib.cc +++ b/common/mathlib.cc @@ -28,8 +28,6 @@ #include -using namespace polylib; - qmat3x3d RotateAboutX(double t) { // https://en.wikipedia.org/wiki/Rotation_matrix#Examples @@ -412,7 +410,7 @@ std::pair, std::vector> ClipPoly(const std::vector(), std::vector()); - winding_t w = winding_t::from_winding_points(poly); + auto w = polylib::winding_t::from_winding_points(poly); auto clipped = w.clip({plane.xyz(), plane[3]}); diff --git a/light/bounce.cc b/light/bounce.cc index 1a752853..b02b9956 100644 --- a/light/bounce.cc +++ b/light/bounce.cc @@ -39,8 +39,6 @@ #include #include -using namespace polylib; - static std::atomic_size_t bouncelightpoints; void ResetBounce() @@ -88,8 +86,8 @@ static bool Face_ShouldBounce(const mbsp_t *bsp, const mface_t *face) } static void MakeBounceLight(const mbsp_t *bsp, const settings::worldspawn_keys &cfg, lightsurf_t &surf, - qvec3d texture_color, int32_t style, const std::vector &points, const winding_t &winding, const vec_t &area, - const qvec3d &facenormal, const qvec3d &facemidpoint) + qvec3d texture_color, int32_t style, const std::vector &points, const polylib::winding_t &winding, + const vec_t &area, const qvec3d &facenormal, const qvec3d &facemidpoint) { if (!Face_IsEmissive(bsp, surf.face)) { return; @@ -168,7 +166,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m return; } - winding_t winding = winding_t::from_face(bsp, &face); + auto winding = polylib::winding_t::from_face(bsp, &face); vec_t area = winding.area(); if (area < 1.f) { @@ -238,7 +236,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m } } else { winding.dice(cfg.bouncelightsubdivision.value(), - [&points, &faceplane](winding_t &w) { points.push_back(w.center() + faceplane.normal); }); + [&points, &faceplane](polylib::winding_t &w) { points.push_back(w.center() + faceplane.normal); }); } for (auto &style : emitcolors) { diff --git a/light/surflight.cc b/light/surflight.cc index 575cc136..d20274f6 100644 --- a/light/surflight.cc +++ b/light/surflight.cc @@ -37,8 +37,6 @@ See file, 'COPYING', for details. #include -using namespace polylib; - static std::atomic_size_t total_surflight_points; void ResetSurflight() @@ -109,7 +107,7 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys auto &l = surf.vpl = std::make_unique(); // Create winding... - winding_t winding = winding_t::from_winding_points(poly); + auto winding = polylib::winding_t::from_winding_points(poly); auto face_modelinfo = ModelInfoForFace(bsp, face - bsp->dfaces.data()); for (auto &pt : winding) { @@ -152,7 +150,7 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys } } } else { - winding.dice(cfg.surflightsubdivision.value(), [&](winding_t &w) { + winding.dice(cfg.surflightsubdivision.value(), [&](polylib::winding_t &w) { ++l->points_before_culling; qvec3f point = w.center() + l->surfnormal; @@ -246,7 +244,7 @@ static void MakeSurfaceLightsThread(const mbsp_t *bsp, const settings::worldspaw if (info != nullptr) { if (!(info->flags.native & Q2_SURF_LIGHT) || info->value == 0) { if (info->flags.native & Q2_SURF_LIGHT) { - qvec3d wc = winding_t::from_face(bsp, face).center(); + qvec3d wc = polylib::winding_t::from_face(bsp, face).center(); logging::print( "WARNING: surface light '{}' at [{}] has 0 intensity.\n", Face_TextureName(bsp, face), wc); } diff --git a/light/trace_embree.cc b/light/trace_embree.cc index 284ab6b7..14ad78de 100644 --- a/light/trace_embree.cc +++ b/light/trace_embree.cc @@ -27,8 +27,6 @@ #include #include -using namespace polylib; - sceneinfo skygeom; // sky. always occludes. sceneinfo solidgeom; // solids. always occludes. sceneinfo filtergeom; // conditional occluders.. needs to run ray intersection filter @@ -206,7 +204,8 @@ sceneinfo CreateGeometry( return s; } -static void CreateGeometryFromWindings(RTCDevice g_device, RTCScene scene, const std::vector &windings) +static void CreateGeometryFromWindings( + RTCDevice g_device, RTCScene scene, const std::vector &windings) { if (windings.empty()) return; @@ -474,13 +473,13 @@ qplane3d Node_Plane(const mbsp_t *bsp, const bsp2_dnode_t *node, bool side) * `planes` all of the node planes that bound this leaf, facing inward. */ static void Leaf_MakeFaces(const mbsp_t *bsp, const modelinfo_t *modelinfo, const mleaf_t *leaf, - const std::vector &planes, std::vector &result) + const std::vector &planes, std::vector &result) { for (const qplane3d &plane : planes) { // flip the inward-facing split plane to get the outward-facing plane of the face we're constructing qplane3d faceplane = -plane; - std::optional winding = winding_t::from_plane(faceplane, 10e6); + std::optional winding = polylib::winding_t::from_plane(faceplane, 10e6); // clip `winding` by all of the other planes for (const qplane3d &plane2 : planes) { @@ -504,7 +503,7 @@ static void Leaf_MakeFaces(const mbsp_t *bsp, const modelinfo_t *modelinfo, cons } void MakeFaces_r(const mbsp_t *bsp, const modelinfo_t *modelinfo, const int nodenum, std::vector *planes, - std::vector &result) + std::vector &result) { if (nodenum < 0) { const int leafnum = -nodenum - 1; @@ -531,7 +530,7 @@ void MakeFaces_r(const mbsp_t *bsp, const modelinfo_t *modelinfo, const int node } static void MakeFaces( - const mbsp_t *bsp, const modelinfo_t *modelinfo, const dmodelh2_t *model, std::vector &result) + const mbsp_t *bsp, const modelinfo_t *modelinfo, const dmodelh2_t *model, std::vector &result) { std::vector planes; MakeFaces_r(bsp, modelinfo, model->headnode[0], &planes, result); @@ -644,7 +643,7 @@ void Embree_TraceInit(const mbsp_t *bsp) } /* Special handling of skip-textured bmodels */ - std::vector skipwindings; + std::vector skipwindings; for (const modelinfo_t *modelinfo : tracelist) { if (modelinfo->model->numfaces == 0) { MakeFaces(bsp, modelinfo, modelinfo->model, skipwindings);