light: fixes for degenerate faces

This commit is contained in:
Eric Wasylishen 2017-07-05 20:43:47 -06:00
parent 014b5265b8
commit c0b88b7e99
2 changed files with 11 additions and 2 deletions

View File

@ -2760,6 +2760,10 @@ LightFace(const bsp2_t *bsp, bsp2_dface_t *face, facesup_t *facesup, const globa
if (!Q_strcasecmp(texname, "skip"))
return;
/* don't bother with degenerate faces */
if (face->numedges < 3)
return;
/* all good, this face is going to be lightmapped. */
lightsurf_t *lightsurf = new lightsurf_t {};
lightsurf->cfg = &cfg;

View File

@ -150,8 +150,13 @@ const qvec3f GetSurfaceVertexNormal(const bsp2_t *bsp, const bsp2_dface_t *f, co
{
Q_assert(s_builtPhongCaches);
const auto &face_normals_vector = vertex_normals.at(f);
return face_normals_vector.at(vertindex);
// handle degenerate faces
const auto it = vertex_normals.find(f);
if (it == vertex_normals.end()) {
return qvec3f(0,0,0);
}
const auto &face_normals_vec = it->second;
return face_normals_vec.at(vertindex);
}
static bool