common: make Face_Plane_E return a plane3f

This commit is contained in:
Eric Wasylishen 2017-04-24 01:54:25 -06:00
parent a7df1994dc
commit 5eb4fd8790
5 changed files with 8 additions and 6 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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<float>;

View File

@ -60,7 +60,7 @@ public:
face_cache_t(const bsp2_t *bsp, const bsp2_dface_t *face, const std::vector<qvec3f> &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))
{ }

View File

@ -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;