light: refactor tracelist to be a list of modelinfo_t instead of dmodel_t

This commit is contained in:
Eric Wasylishen 2016-04-05 23:25:36 -06:00
parent 7a336a4881
commit a6a89db530
3 changed files with 18 additions and 18 deletions

View File

@ -219,8 +219,8 @@ struct ltface_ctx
};
/* tracelist is a null terminated array of BSP models to use for LOS tests */
extern const dmodel_t *const *tracelist;
extern const dmodel_t *const *selfshadowlist;
extern const modelinfo_t *const *tracelist;
extern const modelinfo_t *const *selfshadowlist;
struct ltface_ctx;
struct ltface_ctx *LightFaceInit(const bsp2_t *bsp);

View File

@ -86,8 +86,8 @@ static byte *lux_file_p; // start of free space after luxfile data
static byte *lux_file_end; // end of space for luxfile data
static modelinfo_t *modelinfo;
const dmodel_t *const *tracelist;
const dmodel_t *const *selfshadowlist;
const modelinfo_t *const *tracelist;
const modelinfo_t *const *selfshadowlist;
int oversample = 1;
int write_litfile = 0; /* 0 for none, 1 for .lit, 2 for bspx, 3 for both */
@ -213,19 +213,19 @@ FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride)
entity_t *entity;
char modelname[20];
const char *attribute;
const dmodel_t **shadowmodels;
const dmodel_t **selfshadowmodels;
const modelinfo_t **shadowmodels;
const modelinfo_t **selfshadowmodels;
modelinfo_t *info;
float lightmapscale;
shadowmodels = (const dmodel_t **)malloc(sizeof(dmodel_t *) * (bsp->nummodels + 1));
memset(shadowmodels, 0, sizeof(dmodel_t *) * (bsp->nummodels + 1));
shadowmodels = (const modelinfo_t **)malloc(sizeof(modelinfo_t *) * (bsp->nummodels + 1));
memset(shadowmodels, 0, sizeof(modelinfo_t *) * (bsp->nummodels + 1));
selfshadowmodels = (const dmodel_t **)malloc(sizeof(dmodel_t *) * (bsp->nummodels + 1));
memset(selfshadowmodels, 0, sizeof(dmodel_t *) * (bsp->nummodels + 1));
selfshadowmodels = (const modelinfo_t **)malloc(sizeof(modelinfo_t *) * (bsp->nummodels + 1));
memset(selfshadowmodels, 0, sizeof(modelinfo_t *) * (bsp->nummodels + 1));
/* The world always casts shadows */
shadowmodels[0] = &bsp->dmodels[0];
shadowmodels[0] = &modelinfo[0];
numshadowmodels = 1;
numselfshadowmodels = 0;
@ -263,12 +263,12 @@ FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride)
/* Check if this model will cast shadows (shadow => shadowself) */
shadow = atoi(ValueForKey(entity, "_shadow"));
if (shadow) {
shadowmodels[numshadowmodels++] = &bsp->dmodels[i];
shadowmodels[numshadowmodels++] = info;
} else {
shadow = atoi(ValueForKey(entity, "_shadowself"));
if (shadow) {
info->shadowself = true;
selfshadowmodels[numselfshadowmodels++] = &bsp->dmodels[i];
selfshadowmodels[numselfshadowmodels++] = info;
}
}

View File

@ -135,9 +135,9 @@ MakeTnodes_embree(const bsp2_t *bsp)
std::vector<const bsp2_dface_t *> skyfaces, solidfaces;
/* Check against the list of global shadow casters */
for (const dmodel_t *const *model = tracelist; *model; model++) {
for (int i=0; i<(*model)->numfaces; i++) {
const bsp2_dface_t *face = &bsp->dfaces[(*model)->firstface + i];
for (const modelinfo_t *const *model = tracelist; *model; model++) {
for (int i=0; i<(*model)->model->numfaces; i++) {
const bsp2_dface_t *face = &bsp->dfaces[(*model)->model->firstface + i];
const miptex_t *miptex = MiptexForFace(bsp, face);
if (miptex != NULL && !strncmp("sky", miptex->name, 3)) {
@ -258,7 +258,7 @@ DirtTrace_embree(const vec3_t start, const vec3_t dir, vec_t dist, vec_t *hitdis
if (ray.geomID != solidgeom.geomID) {
// don't re-check the world's self-shadow model because it's already part of 'scene'
if (model->model != tracelist[0]) {
if (model->model != tracelist[0]->model) {
RTCScene selfshadowscene = selfshadowSceneForDModel[model->model];
ray = SetupRay(start, dir, dist);
rtcIntersect(selfshadowscene, ray);
@ -322,7 +322,7 @@ CalcPointsTrace_embree(const vec3_t start, const vec3_t dir, vec_t dist, vec_t *
// if there is no hit, but we were tracning on a submodel, also test against the world.
if (ray.geomID == RTC_INVALID_GEOMETRY_ID
&& model->model != tracelist[0]) {
&& model->model != tracelist[0]->model) {
ray = SetupRay(start, dir, dist);
rtcIntersect(scene, ray);
}