light: refactor some more stuff to GLM

This commit is contained in:
Eric Wasylishen 2017-02-06 23:00:48 -07:00
parent f018b7324d
commit 9246454bfc
3 changed files with 7 additions and 17 deletions

View File

@ -40,7 +40,7 @@ int Face_VertexAtIndex(const bsp2_t *bsp, const bsp2_dface_t *f, int v)
return bsp->dedges[edge].v[0]; return bsp->dedges[edge].v[0];
} }
void static void
Vertex_GetPos(const bsp2_t *bsp, int num, vec3_t out) Vertex_GetPos(const bsp2_t *bsp, int num, vec3_t out)
{ {
Q_assert(num >= 0 && num < bsp->numvertexes); Q_assert(num >= 0 && num < bsp->numvertexes);
@ -50,12 +50,6 @@ Vertex_GetPos(const bsp2_t *bsp, int num, vec3_t out)
out[i] = v->point[i]; out[i] = v->point[i];
} }
void Face_PointAtIndex(const bsp2_t *bsp, const bsp2_dface_t *f, int v, vec3_t out)
{
const int vertnum = Face_VertexAtIndex(bsp, f, v);
Vertex_GetPos(bsp, vertnum, out);
}
void void
Face_Normal(const bsp2_t *bsp, const bsp2_dface_t *f, vec3_t norm) Face_Normal(const bsp2_t *bsp, const bsp2_dface_t *f, vec3_t norm)
{ {

View File

@ -28,8 +28,6 @@
int Face_GetNum(const bsp2_t *bsp, const bsp2_dface_t *f); int Face_GetNum(const bsp2_t *bsp, const bsp2_dface_t *f);
int Face_VertexAtIndex(const bsp2_t *bsp, const bsp2_dface_t *f, int v); int Face_VertexAtIndex(const bsp2_t *bsp, const bsp2_dface_t *f, int v);
void Vertex_GetPos(const bsp2_t *bsp, int num, vec3_t out);
void Face_PointAtIndex(const bsp2_t *bsp, const bsp2_dface_t *f, int v, vec3_t out);
void Face_Normal(const bsp2_t *bsp, const bsp2_dface_t *f, vec3_t norm); void Face_Normal(const bsp2_t *bsp, const bsp2_dface_t *f, vec3_t norm);
plane_t Face_Plane(const bsp2_t *bsp, const bsp2_dface_t *f); plane_t Face_Plane(const bsp2_t *bsp, const bsp2_dface_t *f);
const texinfo_t *Face_Texinfo(const bsp2_t *bsp, const bsp2_dface_t *face); const texinfo_t *Face_Texinfo(const bsp2_t *bsp, const bsp2_dface_t *face);

View File

@ -119,8 +119,7 @@ public:
if (m_texsize[i] >= MAXDIMENSION) { if (m_texsize[i] >= MAXDIMENSION) {
const plane_t plane = Face_Plane(bsp, face); const plane_t plane = Face_Plane(bsp, face);
vec3_t point; const glm::vec3 point = Face_PointAtIndex_E(bsp, face, 0); // grab first vert
Face_PointAtIndex(bsp, face, 0, point); // grab first vert
const char *texname = Face_TextureName(bsp, face); const char *texname = Face_TextureName(bsp, face);
Error("Bad surface extents:\n" Error("Bad surface extents:\n"
@ -128,7 +127,7 @@ public:
" texture %s at (%s)\n" " texture %s at (%s)\n"
" surface normal (%s)\n", " surface normal (%s)\n",
Face_GetNum(bsp, face), i ? "t" : "s", m_texsize[i], m_lightmapscale, Face_GetNum(bsp, face), i ? "t" : "s", m_texsize[i], m_lightmapscale,
texname, VecStrf(point), texname, glm::to_string(point).c_str(),
VecStrf(plane.normal)); VecStrf(plane.normal));
} }
} }
@ -270,12 +269,11 @@ face_tris_t Face_MakeTris(const bsp2_t *bsp, const bsp2_dface_t *f)
{ {
v3 = Face_VertexAtIndex(bsp, f, j); v3 = Face_VertexAtIndex(bsp, f, j);
vec3_t p1, p2, p3; const glm::vec3 p1 = Vertex_GetPos_E(bsp, v1);
Vertex_GetPos(bsp, v1, p1); const glm::vec3 p2 = Vertex_GetPos_E(bsp, v2);
Vertex_GetPos(bsp, v2, p2); const glm::vec3 p3 = Vertex_GetPos_E(bsp, v3);
Vertex_GetPos(bsp, v3, p3);
const float area = TriangleArea(p1, p2, p3); const float area = GLM_TriangleArea(p1, p2, p3);
Q_assert(!isnan(area)); Q_assert(!isnan(area));
res.areas.push_back(area); res.areas.push_back(area);