style: remove all "using namespace std"

This commit is contained in:
Eric Wasylishen 2023-08-07 15:28:50 -06:00
parent db42b2116a
commit f8886b6e60
7 changed files with 54 additions and 65 deletions

View File

@ -170,8 +170,6 @@ float Lanczos2D(float x, float y, float a)
return lanczos; return lanczos;
} }
using namespace std;
qvec3f FaceNormal(std::vector<qvec3f> points) qvec3f FaceNormal(std::vector<qvec3f> points)
{ {
const int N = static_cast<int>(points.size()); const int N = static_cast<int>(points.size());
@ -211,22 +209,22 @@ std::pair<bool, qvec4f> MakeInwardFacingEdgePlane(const qvec3f &v0, const qvec3f
{ {
const float v0v1len = qv::length(v1 - v0); const float v0v1len = qv::length(v1 - v0);
if (v0v1len < POINT_EQUAL_EPSILON) if (v0v1len < POINT_EQUAL_EPSILON)
return make_pair(false, qvec4f(0)); return std::make_pair(false, qvec4f(0));
const qvec3f edgedir = (v1 - v0) / v0v1len; const qvec3f edgedir = (v1 - v0) / v0v1len;
const qvec3f edgeplane_normal = qv::cross(edgedir, faceNormal); const qvec3f edgeplane_normal = qv::cross(edgedir, faceNormal);
const float edgeplane_dist = qv::dot(edgeplane_normal, v0); const float edgeplane_dist = qv::dot(edgeplane_normal, v0);
return make_pair(true, qvec4f(edgeplane_normal[0], edgeplane_normal[1], edgeplane_normal[2], edgeplane_dist)); return std::make_pair(true, qvec4f(edgeplane_normal[0], edgeplane_normal[1], edgeplane_normal[2], edgeplane_dist));
} }
vector<qvec4f> MakeInwardFacingEdgePlanes(const std::vector<qvec3f> &points) std::vector<qvec4f> MakeInwardFacingEdgePlanes(const std::vector<qvec3f> &points)
{ {
const size_t N = points.size(); const size_t N = points.size();
if (N < 3) if (N < 3)
return {}; return {};
vector<qvec4f> result; std::vector<qvec4f> result;
result.reserve(points.size()); result.reserve(points.size());
const qvec3f faceNormal = FaceNormal(points); const qvec3f faceNormal = FaceNormal(points);
@ -261,7 +259,7 @@ float EdgePlanes_PointInsideDist(const std::vector<qvec4f> &edgeplanes, const qv
return min; // "outermost" point return min; // "outermost" point
} }
bool EdgePlanes_PointInside(const vector<qvec4f> &edgeplanes, const qvec3f &point) bool EdgePlanes_PointInside(const std::vector<qvec4f> &edgeplanes, const qvec3f &point)
{ {
if (edgeplanes.empty()) if (edgeplanes.empty())
return false; return false;
@ -354,7 +352,7 @@ std::pair<int, qvec3f> ClosestPointOnPolyBoundary(const std::vector<qvec3f> &pol
Q_assert(bestI != -1); Q_assert(bestI != -1);
return make_pair(bestI, bestPointOnPoly); return std::make_pair(bestI, bestPointOnPoly);
} }
std::pair<bool, qvec3f> InterpolateNormal( std::pair<bool, qvec3f> InterpolateNormal(
@ -374,7 +372,7 @@ std::pair<bool, qvec3f> InterpolateNormal(
Q_assert(points.size() == normals.size()); Q_assert(points.size() == normals.size());
if (points.size() < 3) if (points.size() < 3)
return make_pair(false, qvec3f{}); return std::make_pair(false, qvec3f{});
// Step through the triangles, being careful to handle zero-size ones // Step through the triangles, being careful to handle zero-size ones
@ -401,18 +399,18 @@ std::pair<bool, qvec3f> InterpolateNormal(
continue; continue;
const qvec3f interpolatedNormal = qv::Barycentric_ToPoint(bary, n0, n1, n2); const qvec3f interpolatedNormal = qv::Barycentric_ToPoint(bary, n0, n1, n2);
return make_pair(true, interpolatedNormal); return std::make_pair(true, interpolatedNormal);
} }
} }
return make_pair(false, qvec3f{}); return std::make_pair(false, qvec3f{});
} }
/// Returns (front part, back part) /// Returns (front part, back part)
std::pair<std::vector<qvec3f>, std::vector<qvec3f>> ClipPoly(const std::vector<qvec3f> &poly, const qvec4f &plane) std::pair<std::vector<qvec3f>, std::vector<qvec3f>> ClipPoly(const std::vector<qvec3f> &poly, const qvec4f &plane)
{ {
if (poly.empty()) if (poly.empty())
return make_pair(vector<qvec3f>(), vector<qvec3f>()); return make_pair(std::vector<qvec3f>(), std::vector<qvec3f>());
winding_t w = winding_t::from_winding_points(poly); winding_t w = winding_t::from_winding_points(poly);
@ -430,9 +428,9 @@ std::pair<std::vector<qvec3f>, std::vector<qvec3f>> ClipPoly(const std::vector<q
std::vector<qvec3f> ShrinkPoly(const std::vector<qvec3f> &poly, const float amount) std::vector<qvec3f> ShrinkPoly(const std::vector<qvec3f> &poly, const float amount)
{ {
const vector<qvec4f> edgeplanes = MakeInwardFacingEdgePlanes(poly); const std::vector<qvec4f> edgeplanes = MakeInwardFacingEdgePlanes(poly);
vector<qvec3f> clipped = poly; std::vector<qvec3f> clipped = poly;
for (const qvec4f &edge : edgeplanes) { for (const qvec4f &edge : edgeplanes) {
const qvec4f shrunkEdgePlane(edge[0], edge[1], edge[2], edge[3] + amount); const qvec4f shrunkEdgePlane(edge[0], edge[1], edge[2], edge[3] + amount);

View File

@ -39,7 +39,6 @@
#include <common/qvec.hh> #include <common/qvec.hh>
#include <common/parallel.hh> #include <common/parallel.hh>
using namespace std;
using namespace polylib; using namespace polylib;
static std::atomic_size_t bouncelightpoints; static std::atomic_size_t bouncelightpoints;
@ -225,7 +224,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m
qvec3d facenormal = faceplane.normal; qvec3d facenormal = faceplane.normal;
qvec3d facemidpoint = winding.center() + facenormal; // Lift 1 unit qvec3d facemidpoint = winding.center() + facenormal; // Lift 1 unit
vector<qvec3f> points; std::vector<qvec3f> points;
if (light_options.emissivequality.value() == emissivequality_t::LOW || if (light_options.emissivequality.value() == emissivequality_t::LOW ||
light_options.emissivequality.value() == emissivequality_t::MEDIUM) { light_options.emissivequality.value() == emissivequality_t::MEDIUM) {

View File

@ -40,8 +40,6 @@
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
using namespace std;
std::atomic<uint32_t> total_light_rays, total_light_ray_hits, total_samplepoints; std::atomic<uint32_t> total_light_rays, total_light_ray_hits, total_samplepoints;
std::atomic<uint32_t> total_bounce_rays, total_bounce_ray_hits; std::atomic<uint32_t> total_bounce_rays, total_bounce_ray_hits;
std::atomic<uint32_t> total_surflight_rays, total_surflight_ray_hits; // mxd std::atomic<uint32_t> total_surflight_rays, total_surflight_ray_hits; // mxd
@ -240,7 +238,7 @@ position_t CalcPointNormal(const mbsp_t *bsp, const mface_t *face, const qvec3f
// 2. Try snapping to poly // 2. Try snapping to poly
const pair<int, qvec3f> closest = ClosestPointOnPolyBoundary(points, point); const std::pair<int, qvec3f> closest = ClosestPointOnPolyBoundary(points, point);
float luxelSpaceDist; float luxelSpaceDist;
{ {
auto desired_point_in_lmspace = faceextents.worldToLMCoord(point); auto desired_point_in_lmspace = faceextents.worldToLMCoord(point);

View File

@ -38,8 +38,6 @@
#include <common/qvec.hh> #include <common/qvec.hh>
#include <tbb/parallel_for_each.h> #include <tbb/parallel_for_each.h>
using namespace std;
face_cache_t::face_cache_t(){}; face_cache_t::face_cache_t(){};
face_cache_t::face_cache_t(const mbsp_t *bsp, const mface_t *face, const std::vector<face_normal_t> &normals) face_cache_t::face_cache_t(const mbsp_t *bsp, const mface_t *face, const std::vector<face_normal_t> &normals)
@ -68,7 +66,7 @@ static neighbour_t FaceOverlapsEdge(const qvec3f &p0, const qvec3f &p1, const mb
} }
static void FacesOverlappingEdge_r( static void FacesOverlappingEdge_r(
const qvec3f &p0, const qvec3f &p1, const mbsp_t *bsp, int nodenum, vector<neighbour_t> *result) const qvec3f &p0, const qvec3f &p1, const mbsp_t *bsp, int nodenum, std::vector<neighbour_t> *result)
{ {
if (nodenum < 0) { if (nodenum < 0) {
// we don't do anything for leafs. // we don't do anything for leafs.
@ -110,10 +108,10 @@ static void FacesOverlappingEdge_r(
* Returns faces which have an edge that overlaps the given p0-p1 edge. * Returns faces which have an edge that overlaps the given p0-p1 edge.
* Uses hull 0. * Uses hull 0.
*/ */
inline vector<neighbour_t> FacesOverlappingEdge( inline std::vector<neighbour_t> FacesOverlappingEdge(
const qvec3f &p0, const qvec3f &p1, const mbsp_t *bsp, const dmodelh2_t *model) const qvec3f &p0, const qvec3f &p1, const mbsp_t *bsp, const dmodelh2_t *model)
{ {
vector<neighbour_t> result; std::vector<neighbour_t> result;
FacesOverlappingEdge_r(p0, p1, bsp, model->headnode[0], &result); FacesOverlappingEdge_r(p0, p1, bsp, model->headnode[0], &result);
return result; return result;
} }
@ -181,11 +179,11 @@ static float AngleBetweenPoints(const qvec3f &p1, const qvec3f &p2, const qvec3f
static bool s_builtPhongCaches; static bool s_builtPhongCaches;
static std::unordered_map<const mface_t *, std::vector<face_normal_t>> vertex_normals; static std::unordered_map<const mface_t *, std::vector<face_normal_t>> vertex_normals;
static map<const mface_t *, set<const mface_t *>> smoothFaces; static std::map<const mface_t *, std::set<const mface_t *>> smoothFaces;
static map<int, vector<const mface_t *>> vertsToFaces; static std::map<int, std::vector<const mface_t *>> vertsToFaces;
static map<int, vector<const mface_t *>> planesToFaces; static std::map<int, std::vector<const mface_t *>> planesToFaces;
static edgeToFaceMap_t EdgeToFaceMap; static edgeToFaceMap_t EdgeToFaceMap;
static vector<face_cache_t> FaceCache; static std::vector<face_cache_t> FaceCache;
void ResetPhong() void ResetPhong()
{ {
@ -198,7 +196,7 @@ void ResetPhong()
FaceCache = {}; FaceCache = {};
} }
vector<const mface_t *> FacesUsingVert(int vertnum) std::vector<const mface_t *> FacesUsingVert(int vertnum)
{ {
const auto &vertsToFaces_const = vertsToFaces; const auto &vertsToFaces_const = vertsToFaces;
@ -223,7 +221,7 @@ bool FacesSmoothed(const mface_t *f1, const mface_t *f2)
if (facesIt == smoothFaces.end()) if (facesIt == smoothFaces.end())
return false; return false;
const set<const mface_t *> &faceSet = facesIt->second; const std::set<const mface_t *> &faceSet = facesIt->second;
if (faceSet.find(f2) == faceSet.end()) if (faceSet.find(f2) == faceSet.end())
return false; return false;
@ -295,7 +293,7 @@ const mface_t *Face_EdgeIndexSmoothed(const mbsp_t *bsp, const mface_t *f, const
const int v0 = Face_VertexAtIndex(bsp, f, edgeindex); const int v0 = Face_VertexAtIndex(bsp, f, edgeindex);
const int v1 = Face_VertexAtIndex(bsp, f, (edgeindex + 1) % f->numedges); const int v1 = Face_VertexAtIndex(bsp, f, (edgeindex + 1) % f->numedges);
auto it = EdgeToFaceMap.find(make_pair(v1, v0)); auto it = EdgeToFaceMap.find(std::make_pair(v1, v0));
if (it != EdgeToFaceMap.end()) { if (it != EdgeToFaceMap.end()) {
for (const mface_t *neighbour : it->second) { for (const mface_t *neighbour : it->second) {
if (neighbour == f) { if (neighbour == f) {
@ -355,7 +353,7 @@ static edgeToFaceMap_t MakeEdgeToFaceMap(const mbsp_t *bsp)
continue; continue;
} }
const auto edge = make_pair(v0, v1); const auto edge = std::make_pair(v0, v1);
auto &edgeFacesRef = result[edge]; auto &edgeFacesRef = result[edge];
if (find(begin(edgeFacesRef), end(edgeFacesRef), &f) != end(edgeFacesRef)) { if (find(begin(edgeFacesRef), end(edgeFacesRef), &f) != end(edgeFacesRef)) {
@ -369,19 +367,19 @@ static edgeToFaceMap_t MakeEdgeToFaceMap(const mbsp_t *bsp)
return result; return result;
} }
static vector<face_normal_t> Face_VertexNormals(const mbsp_t *bsp, const mface_t *face) static std::vector<face_normal_t> Face_VertexNormals(const mbsp_t *bsp, const mface_t *face)
{ {
vector<face_normal_t> normals(face->numedges); std::vector<face_normal_t> normals(face->numedges);
tbb::parallel_for(0, face->numedges, [&](size_t i) { normals[i] = GetSurfaceVertexNormal(bsp, face, i); }); tbb::parallel_for(0, face->numedges, [&](size_t i) { normals[i] = GetSurfaceVertexNormal(bsp, face, i); });
return normals; return normals;
} }
#include <common/parallel.hh> #include <common/parallel.hh>
static vector<face_cache_t> MakeFaceCache(const mbsp_t *bsp) static std::vector<face_cache_t> MakeFaceCache(const mbsp_t *bsp)
{ {
logging::funcheader(); logging::funcheader();
vector<face_cache_t> result(bsp->dfaces.size()); std::vector<face_cache_t> result(bsp->dfaces.size());
logging::parallel_for(static_cast<size_t>(0), bsp->dfaces.size(), [&](size_t i) { logging::parallel_for(static_cast<size_t>(0), bsp->dfaces.size(), [&](size_t i) {
auto &face = bsp->dfaces[i]; auto &face = bsp->dfaces[i];
result[i] = face_cache_t(bsp, &bsp->dfaces[i], Face_VertexNormals(bsp, &face)); result[i] = face_cache_t(bsp, &bsp->dfaces[i], Face_VertexNormals(bsp, &face));

View File

@ -37,7 +37,6 @@ See file, 'COPYING', for details.
#include <common/qvec.hh> #include <common/qvec.hh>
using namespace std;
using namespace polylib; using namespace polylib;
static std::atomic_size_t total_surflight_points; static std::atomic_size_t total_surflight_points;

View File

@ -27,7 +27,6 @@
#include <vector> #include <vector>
#include <climits> #include <climits>
using namespace std;
using namespace polylib; using namespace polylib;
sceneinfo skygeom; // sky. always occludes. sceneinfo skygeom; // sky. always occludes.

View File

@ -11,8 +11,6 @@
#include <common/aabb.hh> #include <common/aabb.hh>
using namespace std;
TEST_SUITE("mathlib") TEST_SUITE("mathlib")
{ {
@ -37,7 +35,7 @@ TEST_SUITE("mathlib")
REQUIRE(2 == SampleCDF(cdf, 1)); REQUIRE(2 == SampleCDF(cdf, 1));
} }
static void checkBox(const vector<qvec4f> &edges, const vector<qvec3f> &poly) static void checkBox(const std::vector<qvec4f> &edges, const std::vector<qvec3f> &poly)
{ {
CHECK(EdgePlanes_PointInside(edges, qvec3f(0, 0, 0))); CHECK(EdgePlanes_PointInside(edges, qvec3f(0, 0, 0)));
CHECK(EdgePlanes_PointInside(edges, qvec3f(64, 0, 0))); CHECK(EdgePlanes_PointInside(edges, qvec3f(64, 0, 0)));
@ -53,7 +51,7 @@ TEST_SUITE("mathlib")
TEST_CASE("EdgePlanesOfNonConvexPoly") TEST_CASE("EdgePlanesOfNonConvexPoly")
{ {
// hourglass, non-convex // hourglass, non-convex
const vector<qvec3f> poly{{0, 0, 0}, {64, 64, 0}, {0, 64, 0}, {64, 0, 0}}; const std::vector<qvec3f> poly{{0, 0, 0}, {64, 64, 0}, {0, 64, 0}, {64, 0, 0}};
const auto edges = MakeInwardFacingEdgePlanes(poly); const auto edges = MakeInwardFacingEdgePlanes(poly);
// CHECK(vector<qvec4f>() == edges); // CHECK(vector<qvec4f>() == edges);
@ -61,7 +59,7 @@ TEST_SUITE("mathlib")
TEST_CASE("SlightlyConcavePoly") TEST_CASE("SlightlyConcavePoly")
{ {
const vector<qvec3f> poly{qvec3f(225.846161, -1744, 1774), qvec3f(248, -1744, 1798), const std::vector<qvec3f> poly{qvec3f(225.846161, -1744, 1774), qvec3f(248, -1744, 1798),
qvec3f(248, -1763.82605, 1799.65222), qvec3f(248, -1764, 1799.66663), qvec3f(248, -1892, 1810.33337), qvec3f(248, -1763.82605, 1799.65222), qvec3f(248, -1764, 1799.66663), qvec3f(248, -1892, 1810.33337),
qvec3f(248, -1893.21741, 1810.43481), qvec3f(248, -1921.59998, 1812.80005), qvec3f(248, -1924, 1813), qvec3f(248, -1893.21741, 1810.43481), qvec3f(248, -1921.59998, 1812.80005), qvec3f(248, -1924, 1813),
qvec3f(80, -1924, 1631), qvec3f(80, -1744, 1616)}; qvec3f(80, -1924, 1631), qvec3f(80, -1744, 1616)};
@ -74,7 +72,7 @@ TEST_SUITE("mathlib")
TEST_CASE("PointInPolygon") TEST_CASE("PointInPolygon")
{ {
// clockwise // clockwise
const vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {64, 64, 0}, {64, 0, 0}}; const std::vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {64, 64, 0}, {64, 0, 0}};
const auto edges = MakeInwardFacingEdgePlanes(poly); const auto edges = MakeInwardFacingEdgePlanes(poly);
checkBox(edges, poly); checkBox(edges, poly);
@ -83,7 +81,7 @@ TEST_SUITE("mathlib")
TEST_CASE("PointInPolygon_DegenerateEdgeHandling") TEST_CASE("PointInPolygon_DegenerateEdgeHandling")
{ {
// clockwise // clockwise
const vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {0, 64, 0}, // repeat of last point const std::vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {0, 64, 0}, // repeat of last point
{64, 64, 0}, {64, 0, 0}}; {64, 64, 0}, {64, 0, 0}};
const auto edges = MakeInwardFacingEdgePlanes(poly); const auto edges = MakeInwardFacingEdgePlanes(poly);
@ -92,7 +90,7 @@ TEST_SUITE("mathlib")
TEST_CASE("PointInPolygon_DegenerateFaceHandling1") TEST_CASE("PointInPolygon_DegenerateFaceHandling1")
{ {
const vector<qvec3f> poly{}; const std::vector<qvec3f> poly{};
const auto edges = MakeInwardFacingEdgePlanes(poly); const auto edges = MakeInwardFacingEdgePlanes(poly);
CHECK_FALSE(EdgePlanes_PointInside(edges, qvec3f(0, 0, 0))); CHECK_FALSE(EdgePlanes_PointInside(edges, qvec3f(0, 0, 0)));
@ -101,7 +99,7 @@ TEST_SUITE("mathlib")
TEST_CASE("PointInPolygon_DegenerateFaceHandling2") TEST_CASE("PointInPolygon_DegenerateFaceHandling2")
{ {
const vector<qvec3f> poly{ const std::vector<qvec3f> poly{
{0, 0, 0}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0},
@ -115,7 +113,7 @@ TEST_SUITE("mathlib")
TEST_CASE("PointInPolygon_DegenerateFaceHandling3") TEST_CASE("PointInPolygon_DegenerateFaceHandling3")
{ {
const vector<qvec3f> poly{ const std::vector<qvec3f> poly{
{0, 0, 0}, {0, 0, 0},
{10, 10, 10}, {10, 10, 10},
{20, 20, 20}, {20, 20, 20},
@ -130,7 +128,7 @@ TEST_SUITE("mathlib")
TEST_CASE("PointInPolygon_ColinearPointHandling") TEST_CASE("PointInPolygon_ColinearPointHandling")
{ {
// clockwise // clockwise
const vector<qvec3f> poly{{0, 0, 0}, {0, 32, 0}, // colinear const std::vector<qvec3f> poly{{0, 0, 0}, {0, 32, 0}, // colinear
{0, 64, 0}, {64, 64, 0}, {64, 0, 0}}; {0, 64, 0}, {64, 64, 0}, {64, 0, 0}};
const auto edges = MakeInwardFacingEdgePlanes(poly); const auto edges = MakeInwardFacingEdgePlanes(poly);
@ -146,20 +144,20 @@ TEST_SUITE("mathlib")
TEST_CASE("ClosestPointOnPolyBoundary") TEST_CASE("ClosestPointOnPolyBoundary")
{ {
// clockwise // clockwise
const vector<qvec3f> poly{ const std::vector<qvec3f> poly{
{0, 0, 0}, // edge 0 start, edge 3 end {0, 0, 0}, // edge 0 start, edge 3 end
{0, 64, 0}, // edge 1 start, edge 0 end {0, 64, 0}, // edge 1 start, edge 0 end
{64, 64, 0}, // edge 2 start, edge 1 end {64, 64, 0}, // edge 2 start, edge 1 end
{64, 0, 0} // edge 3 start, edge 2 end {64, 0, 0} // edge 3 start, edge 2 end
}; };
CHECK(make_pair(0, qvec3f(0, 0, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(0, 0, 0))); CHECK(std::make_pair(0, qvec3f(0, 0, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(0, 0, 0)));
// Either edge 1 or 2 contain the point qvec3f(64,64,0), but we expect the first edge to be returned // Either edge 1 or 2 contain the point qvec3f(64,64,0), but we expect the first edge to be returned
CHECK(make_pair(1, qvec3f(64, 64, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(100, 100, 100))); CHECK(std::make_pair(1, qvec3f(64, 64, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(100, 100, 100)));
CHECK(make_pair(2, qvec3f(64, 32, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(100, 32, 0))); CHECK(std::make_pair(2, qvec3f(64, 32, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(100, 32, 0)));
CHECK(make_pair(0, qvec3f(0, 0, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(-1, -1, 0))); CHECK(std::make_pair(0, qvec3f(0, 0, 0)) == ClosestPointOnPolyBoundary(poly, qvec3f(-1, -1, 0)));
} }
TEST_CASE("PolygonCentroid_empty") TEST_CASE("PolygonCentroid_empty")
@ -240,7 +238,7 @@ TEST_SUITE("mathlib")
// clockwise // clockwise
const std::array<qvec3f, 3> tri{qvec3f{0, 0, 0}, {0, 64, 0}, {64, 0, 0}}; const std::array<qvec3f, 3> tri{qvec3f{0, 0, 0}, {0, 64, 0}, {64, 0, 0}};
const auto triAsVec = vector<qvec3f>{tri.begin(), tri.end()}; const auto triAsVec = std::vector<qvec3f>{tri.begin(), tri.end()};
const auto edges = MakeInwardFacingEdgePlanes(triAsVec); const auto edges = MakeInwardFacingEdgePlanes(triAsVec);
const auto plane = PolyPlane(triAsVec); const auto plane = PolyPlane(triAsVec);
@ -308,10 +306,10 @@ TEST_SUITE("mathlib")
// |// | // |// |
// o-----o // o-----o
const vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {32, 64, 0}, // colinear const std::vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {32, 64, 0}, // colinear
{64, 64, 0}, {64, 0, 0}}; {64, 64, 0}, {64, 0, 0}};
const vector<qvec3f> normals{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, // colinear const std::vector<qvec3f> normals{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, // colinear
{0, 0, 0}, {-1, 0, 0}}; {0, 0, 0}, {-1, 0, 0}};
// First try all the known points // First try all the known points
@ -332,7 +330,7 @@ TEST_SUITE("mathlib")
CHECK_FALSE(InterpolateNormal(poly, normals, qvec3f(-0.1, 0, 0)).first); CHECK_FALSE(InterpolateNormal(poly, normals, qvec3f(-0.1, 0, 0)).first);
} }
static bool polysEqual(const vector<qvec3f> &p1, const vector<qvec3f> &p2) static bool polysEqual(const std::vector<qvec3f> &p1, const std::vector<qvec3f> &p2)
{ {
if (p1.size() != p2.size()) if (p1.size() != p2.size())
return false; return false;
@ -345,11 +343,11 @@ TEST_SUITE("mathlib")
TEST_CASE("ClipPoly1") TEST_CASE("ClipPoly1")
{ {
const vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {64, 64, 0}, {64, 0, 0}}; const std::vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {64, 64, 0}, {64, 0, 0}};
const vector<qvec3f> frontRes{{0, 0, 0}, {0, 64, 0}, {32, 64, 0}, {32, 0, 0}}; const std::vector<qvec3f> frontRes{{0, 0, 0}, {0, 64, 0}, {32, 64, 0}, {32, 0, 0}};
const vector<qvec3f> backRes{{32, 64, 0}, {64, 64, 0}, {64, 0, 0}, {32, 0, 0}}; const std::vector<qvec3f> backRes{{32, 64, 0}, {64, 64, 0}, {64, 0, 0}, {32, 0, 0}};
auto clipRes = ClipPoly(poly, qvec4f(-1, 0, 0, -32)); auto clipRes = ClipPoly(poly, qvec4f(-1, 0, 0, -32));
@ -359,9 +357,9 @@ TEST_SUITE("mathlib")
TEST_CASE("ShrinkPoly1") TEST_CASE("ShrinkPoly1")
{ {
const vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {64, 64, 0}, {64, 0, 0}}; const std::vector<qvec3f> poly{{0, 0, 0}, {0, 64, 0}, {64, 64, 0}, {64, 0, 0}};
const vector<qvec3f> shrunkPoly{{1, 1, 0}, {1, 63, 0}, {63, 63, 0}, {63, 1, 0}}; const std::vector<qvec3f> shrunkPoly{{1, 1, 0}, {1, 63, 0}, {63, 63, 0}, {63, 1, 0}};
const auto actualShrunk = ShrinkPoly(poly, 1.0f); const auto actualShrunk = ShrinkPoly(poly, 1.0f);
@ -370,9 +368,9 @@ TEST_SUITE("mathlib")
TEST_CASE("ShrinkPoly2") TEST_CASE("ShrinkPoly2")
{ {
const vector<qvec3f> poly{{0, 0, 0}, {64, 64, 0}, {64, 0, 0}}; const std::vector<qvec3f> poly{{0, 0, 0}, {64, 64, 0}, {64, 0, 0}};
const vector<qvec3f> shrunkPoly{ const std::vector<qvec3f> shrunkPoly{
{1.0f + sqrtf(2.0f), 1.0f, 0.0f}, {1.0f + sqrtf(2.0f), 1.0f, 0.0f},
{63.0f, 63.0f - sqrtf(2.0f), 0.0f}, {63.0f, 63.0f - sqrtf(2.0f), 0.0f},
{63, 1, 0}, {63, 1, 0},