From 71d9f8ce8afe34f45ef8a22caca4a0e59da90f1d Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Wed, 6 Dec 2017 00:23:21 -0700 Subject: [PATCH] light: move NeighbouringFaces_new to phong.cc --- include/light/phong.hh | 5 ++++- light/ltface.cc | 22 ---------------------- light/phong.cc | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/light/phong.hh b/include/light/phong.hh index b5ee833d..ab2b856f 100644 --- a/include/light/phong.hh +++ b/include/light/phong.hh @@ -60,6 +60,7 @@ const bsp2_dface_t *Face_EdgeIndexSmoothed(const mbsp_t *bsp, const bsp2_dface_t /// a directed edge can be used by more than one face, e.g. two cube touching just along an edge using edgeToFaceMap_t = std::map, std::vector>; +std::vector NeighbouringFaces_new(const mbsp_t *bsp, const bsp2_dface_t *face); std::vector FacesUsingVert(int vertnum); const edgeToFaceMap_t &GetEdgeToFaceMap(); @@ -70,6 +71,7 @@ private: qvec4f m_plane; std::vector m_edgePlanes; std::vector m_pointsShrunkBy1Unit; + std::vector m_neighbours; public: face_cache_t(const mbsp_t *bsp, const bsp2_dface_t *face, const std::vector &normals) : @@ -77,7 +79,8 @@ public: m_normals(normals), m_plane(Face_Plane_E(bsp, face).vec4()), m_edgePlanes(GLM_MakeInwardFacingEdgePlanes(m_points)), - m_pointsShrunkBy1Unit(GLM_ShrinkPoly(m_points, 1.0f)) + m_pointsShrunkBy1Unit(GLM_ShrinkPoly(m_points, 1.0f)), + m_neighbours(NeighbouringFaces_new(bsp, face)) { } const std::vector &points() const { diff --git a/light/ltface.cc b/light/ltface.cc index 17bdaf9b..7805cdbf 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -422,28 +422,6 @@ std::vector NeighbouringFaces_old(const mbsp_t *bsp, const return result; } -std::vector NeighbouringFaces_new(const mbsp_t *bsp, const bsp2_dface_t *face) -{ - std::vector result; - std::set used_faces; - - for (int i=0; inumedges; i++) { - vec3_t p0, p1; - Face_PointAtIndex(bsp, face, i, p0); - Face_PointAtIndex(bsp, face, (i + 1) % face->numedges, p1); - - const std::vector tmp = FacesOverlappingEdge(p0, p1, bsp, &bsp->dmodels[0]); - for (const auto &neighbour : tmp) { - if (neighbour.face != face && used_faces.find(neighbour.face) == used_faces.end()) { - used_faces.insert(neighbour.face); - result.push_back(neighbour); - } - } - } - - return result; -} - position_t CalcPointNormal(const mbsp_t *bsp, const bsp2_dface_t *face, const qvec3f &origPoint, bool phongShaded, float face_lmscale, int recursiondepth, const qvec3f &modelOffset) { diff --git a/light/phong.cc b/light/phong.cc index 831bd1a3..cc6de530 100644 --- a/light/phong.cc +++ b/light/phong.cc @@ -109,6 +109,28 @@ FacesOverlappingEdge(const vec3_t p0, const vec3_t p1, const mbsp_t *bsp, const return result; } +std::vector NeighbouringFaces_new(const mbsp_t *bsp, const bsp2_dface_t *face) +{ + std::vector result; + std::set used_faces; + + for (int i=0; inumedges; i++) { + vec3_t p0, p1; + Face_PointAtIndex(bsp, face, i, p0); + Face_PointAtIndex(bsp, face, (i + 1) % face->numedges, p1); + + const std::vector tmp = FacesOverlappingEdge(p0, p1, bsp, &bsp->dmodels[0]); + for (const auto &neighbour : tmp) { + if (neighbour.face != face && used_faces.find(neighbour.face) == used_faces.end()) { + used_faces.insert(neighbour.face); + result.push_back(neighbour); + } + } + } + + return result; +} + /* return 0 if either vector is zero-length */ static float AngleBetweenVectors(const qvec3f &d1, const qvec3f &d2)