light: fixes for bjptools skip faces (which have no associated model)

This commit is contained in:
Eric Wasylishen 2020-08-20 12:08:46 -06:00
parent 0708999ba3
commit b35cb8eb7e
4 changed files with 16 additions and 3 deletions

View File

@ -420,6 +420,9 @@ void FixupGlobalSettings(void);
void GetFileSpace(byte **lightdata, byte **colordata, byte **deluxdata, int size);
void GetFileSpace_PreserveOffsetInBsp(byte **lightdata, byte **colordata, byte **deluxdata, int lightofs);
const modelinfo_t *ModelInfoForModel(const mbsp_t *bsp, int modelnum);
/**
* returs nullptr for "skip" faces
*/
const modelinfo_t *ModelInfoForFace(const mbsp_t *bsp, int facenum);
//bool Leaf_HasSky(const mbsp_t *bsp, const mleaf_t *leaf); //mxd. Missing definition
int light_main(int argc, const char **argv);

View File

@ -652,7 +652,7 @@ FindDebugFace(const mbsp_t *bsp)
dump_facenum = facenum;
const modelinfo_t *mi = ModelInfoForFace(bsp, facenum);
const int modelnum = (mi->model - bsp->dmodels);
const int modelnum = mi ? (mi->model - bsp->dmodels) : -1;
const char *texname = Face_TextureName(bsp, f);

View File

@ -639,7 +639,11 @@ PositionSamplePointOnFace(const mbsp_t *bsp,
}
const modelinfo_t *mi = ModelInfoForFace(bsp, Face_GetNum(bsp, face));
if (mi == nullptr) {
// missing model ("skip" faces) don't get lighting
return position_t(point);
}
// Get the point normal
qvec3f pointNormal;
if (phongShaded) {

View File

@ -117,6 +117,7 @@ CreateGeometry(const mbsp_t *bsp, RTCScene scene, const std::vector<const bsp2_d
if (face->numedges < 3)
continue;
// NOTE: can be null for "skip" faces
const modelinfo_t *modelinfo = ModelInfoForFace(bsp, Face_GetNum(bsp, face));
for (int j = 2; j < face->numedges; j++) {
@ -289,7 +290,12 @@ Embree_FilterFuncN(int* valid,
const modelinfo_t *source_modelinfo = rsi->self;
const modelinfo_t *hit_modelinfo = Embree_LookupModelinfo(geomID, primID);
Q_assert(hit_modelinfo != nullptr);
if (!hit_modelinfo) {
// we hit a "skip" face with no associated model
// reject hit (???)
valid[i] = INVALID;
continue;
}
if (hit_modelinfo->shadowworldonly.boolValue()) {
// we hit "_shadowworldonly" "1" geometry. Ignore the hit unless we are from world.