diff --git a/common/bsputils.cc b/common/bsputils.cc index 7a4995c8..260413c7 100644 --- a/common/bsputils.cc +++ b/common/bsputils.cc @@ -268,10 +268,10 @@ EdgePlanes_PointInside(const bsp2_dface_t *face, const plane_t *edgeplanes, cons // glm stuff -qvec4f Face_Plane_E(const bsp2_t *bsp, const bsp2_dface_t *f) +qplane3f Face_Plane_E(const bsp2_t *bsp, const bsp2_dface_t *f) { const plane_t pl = Face_Plane(bsp, f); - return qvec4f(pl.normal[0], pl.normal[1], pl.normal[2], pl.dist); + return qplane3f(qvec3f(pl.normal[0], pl.normal[1], pl.normal[2]), pl.dist); } qvec3f Face_PointAtIndex_E(const bsp2_t *bsp, const bsp2_dface_t *f, int v) diff --git a/include/common/bsputils.hh b/include/common/bsputils.hh index 4654ce78..cb03bfba 100644 --- a/include/common/bsputils.hh +++ b/include/common/bsputils.hh @@ -45,7 +45,7 @@ bool Light_PointInWorld(const bsp2_t *bsp, const vec3_t point); plane_t *Face_AllocInwardFacingEdgePlanes(const bsp2_t *bsp, const bsp2_dface_t *face); bool EdgePlanes_PointInside(const bsp2_dface_t *face, const plane_t *edgeplanes, const vec3_t point); -qvec4f Face_Plane_E(const bsp2_t *bsp, const bsp2_dface_t *f); +qplane3f Face_Plane_E(const bsp2_t *bsp, const bsp2_dface_t *f); qvec3f Face_PointAtIndex_E(const bsp2_t *bsp, const bsp2_dface_t *f, int v); qvec3f Vertex_GetPos_E(const bsp2_t *bsp, int num); qvec3f Face_Normal_E(const bsp2_t *bsp, const bsp2_dface_t *f); diff --git a/include/common/qvec.hh b/include/common/qvec.hh index a6efe942..15ec8d35 100644 --- a/include/common/qvec.hh +++ b/include/common/qvec.hh @@ -273,6 +273,8 @@ public: T distAbove(const qvec<3, T> &pt) const { return qv::dot(pt, m_normal) - m_dist; } const qvec<3, T> &normal() const { return m_normal; } const T dist() const { return m_dist; } + + const qvec<4, T> vec4() const { return qvec<4, T>(m_normal[0], m_normal[1], m_normal[2], m_dist); } }; using qplane3f = qplane3; diff --git a/include/light/phong.hh b/include/light/phong.hh index 00647b2b..3b80bd67 100644 --- a/include/light/phong.hh +++ b/include/light/phong.hh @@ -60,7 +60,7 @@ public: face_cache_t(const bsp2_t *bsp, const bsp2_dface_t *face, const std::vector &normals) : m_points(GLM_FacePoints(bsp, face)), m_normals(normals), - m_plane(Face_Plane_E(bsp, face)), + m_plane(Face_Plane_E(bsp, face).vec4()), m_edgePlanes(GLM_MakeInwardFacingEdgePlanes(m_points)), m_pointsShrunkBy1Unit(GLM_ShrinkPoly(m_points, 1.0f)) { } diff --git a/light/ltface.cc b/light/ltface.cc index 06a5e1b4..8e2489c3 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -1894,8 +1894,8 @@ LightFace_Bounce(const bsp2_t *bsp, const bsp2_dface_t *face, const lightsurf_t continue; } - const qvec4f plane = Face_Plane_E(bsp, face); - float scale = qv::dot(qvec3f(plane), -raydir); + const qplane3f plane = Face_Plane_E(bsp, face); + float scale = qv::dot(plane.normal(), -raydir); if (scale < 0) scale = 0;