diff --git a/light/ltface.cc b/light/ltface.cc index 7e09ca08..d6ec5a47 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -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; diff --git a/light/phong.cc b/light/phong.cc index c29e3e43..7ba98e47 100644 --- a/light/phong.cc +++ b/light/phong.cc @@ -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