Merge branch 'stable'
* stable: light: trace: raise stack depth 128->256 to handle lavabloom_bad.bsp from Pritchard light: use Face_TextureName() everywhere we need texture names. Handle negative miplump->dataofs[texnum]. build: appveyor: use v140_xp toolset for xp compatibility # Conflicts: # appveyor.yml
This commit is contained in:
commit
7646175048
|
|
@ -332,6 +332,9 @@ extern char mapfilename[1024];
|
|||
void
|
||||
PrintFaceInfo(const bsp2_dface_t *face, const bsp2_t *bsp);
|
||||
|
||||
const miptex_t *
|
||||
Face_Miptex(const bsp2_t *bsp, const bsp2_dface_t *face);
|
||||
|
||||
const char *
|
||||
Face_TextureName(const bsp2_t *bsp, const bsp2_dface_t *face);
|
||||
|
||||
|
|
|
|||
|
|
@ -785,13 +785,20 @@ finds the texture that is meant to be projected.
|
|||
*/
|
||||
static miptex_t *FindProjectionTexture(const bsp2_t *bsp, const char *texname)
|
||||
{
|
||||
if (!bsp->texdatasize)
|
||||
return NULL;
|
||||
|
||||
dmiptexlump_t *miplump = bsp->dtexdata.header;
|
||||
miptex_t *miptex;
|
||||
int texnum;
|
||||
/*outer loop finds the textures*/
|
||||
for (texnum = 0; texnum< miplump->nummiptex; texnum++)
|
||||
{
|
||||
miptex = (miptex_t*)(bsp->dtexdata.base + miplump->dataofs[texnum]);
|
||||
int offset = miplump->dataofs[texnum];
|
||||
if (offset < 0)
|
||||
continue;
|
||||
|
||||
miptex = (miptex_t*)(bsp->dtexdata.base + offset);
|
||||
if (!Q_strcasecmp(miptex->name, texname))
|
||||
return miptex;
|
||||
}
|
||||
|
|
@ -1696,10 +1703,7 @@ static void SubdividePolygon (const bsp2_dface_t *face, const modelinfo_t *face_
|
|||
return;
|
||||
}
|
||||
|
||||
const texinfo_t *tex = &bsp->texinfo[face->texinfo];
|
||||
const int offset = bsp->dtexdata.header->dataofs[tex->miptex];
|
||||
const miptex_t *miptex = (const miptex_t *)(bsp->dtexdata.base + offset);
|
||||
const char *texname = miptex->name;
|
||||
const char *texname = Face_TextureName(bsp, face);
|
||||
|
||||
for (i=0; i<num_surfacelight_templates; i++) {
|
||||
if (!Q_strcasecmp(texname, ValueForKey(surfacelight_templates[i], "_surface"))) {
|
||||
|
|
@ -1765,24 +1769,15 @@ static void MakeSurfaceLights(const bsp2_t *bsp)
|
|||
for (i=0; i<bsp->numleafs; i++) {
|
||||
const bsp2_dleaf_t *leaf = bsp->dleafs + i;
|
||||
const bsp2_dface_t *surf;
|
||||
int ofs;
|
||||
qboolean underwater = leaf->contents != CONTENTS_EMPTY;
|
||||
|
||||
for (k = 0; k < leaf->nummarksurfaces; k++) {
|
||||
const texinfo_t *info;
|
||||
const miptex_t *miptex;
|
||||
const modelinfo_t *face_modelinfo;
|
||||
int facenum = bsp->dmarksurfaces[leaf->firstmarksurface + k];
|
||||
|
||||
surf = &bsp->dfaces[facenum];
|
||||
info = &bsp->texinfo[surf->texinfo];
|
||||
|
||||
/* Don't crash if there are no textuers */
|
||||
if (!bsp->texdatasize)
|
||||
continue;
|
||||
|
||||
ofs = bsp->dtexdata.header->dataofs[info->miptex];
|
||||
miptex = (const miptex_t *)(bsp->dtexdata.base + ofs);
|
||||
const char *texname = Face_TextureName(bsp, surf);
|
||||
|
||||
face_modelinfo = ModelInfoForFace(bsp, facenum);
|
||||
|
||||
/* Skip face with no modelinfo */
|
||||
|
|
@ -1791,7 +1786,7 @@ static void MakeSurfaceLights(const bsp2_t *bsp)
|
|||
|
||||
/* Ignore the underwater side of liquid surfaces */
|
||||
// FIXME: Use a Face_TextureName function for this
|
||||
if (miptex->name[0] == '*' && underwater)
|
||||
if (texname[0] == '*' && underwater)
|
||||
continue;
|
||||
|
||||
/* Skip if already handled */
|
||||
|
|
|
|||
|
|
@ -274,14 +274,13 @@ void
|
|||
PrintFaceInfo(const bsp2_dface_t *face, const bsp2_t *bsp)
|
||||
{
|
||||
const texinfo_t *tex = &bsp->texinfo[face->texinfo];
|
||||
const int offset = bsp->dtexdata.header->dataofs[tex->miptex];
|
||||
const miptex_t *miptex = (const miptex_t *)(bsp->dtexdata.base + offset);
|
||||
const char *texname = Face_TextureName(bsp, face);
|
||||
int i;
|
||||
|
||||
logprint("face %d, texture %s, %d edges...\n"
|
||||
" vectors (%3.3f, %3.3f, %3.3f) (%3.3f)\n"
|
||||
" (%3.3f, %3.3f, %3.3f) (%3.3f)\n",
|
||||
(int)(face - bsp->dfaces), miptex->name, face->numedges,
|
||||
(int)(face - bsp->dfaces), texname, face->numedges,
|
||||
tex->vecs[0][0], tex->vecs[0][1], tex->vecs[0][2], tex->vecs[0][3],
|
||||
tex->vecs[1][0], tex->vecs[1][1], tex->vecs[1][2], tex->vecs[1][3]);
|
||||
|
||||
|
|
@ -365,14 +364,13 @@ CalcFaceExtents(const bsp2_dface_t *face,
|
|||
surf->texsize[i] = maxs[i] - mins[i];
|
||||
if (surf->texsize[i] >= MAXDIMENSION) {
|
||||
const dplane_t *plane = bsp->dplanes + face->planenum;
|
||||
const int offset = bsp->dtexdata.header->dataofs[tex->miptex];
|
||||
const miptex_t *miptex = (const miptex_t *)(bsp->dtexdata.base + offset);
|
||||
const char *texname = Face_TextureName(bsp, face);
|
||||
Error("Bad surface extents:\n"
|
||||
" surface %d, %s extents = %d, scale = %g\n"
|
||||
" texture %s at (%s)\n"
|
||||
" surface normal (%s)\n",
|
||||
(int)(face - bsp->dfaces), i ? "t" : "s", surf->texsize[i], surf->lightmapscale,
|
||||
miptex->name, VecStr(worldpoint), VecStrf(plane->normal));
|
||||
texname, VecStr(worldpoint), VecStrf(plane->normal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2087,17 +2085,31 @@ void LightFaceShutdown(struct ltface_ctx *ctx)
|
|||
free(ctx->lightsurf);
|
||||
}
|
||||
|
||||
const miptex_t *
|
||||
Face_Miptex(const bsp2_t *bsp, const bsp2_dface_t *face)
|
||||
{
|
||||
if (!bsp->texdatasize)
|
||||
return NULL;
|
||||
|
||||
int texnum = bsp->texinfo[face->texinfo].miptex;
|
||||
const dmiptexlump_t *miplump = bsp->dtexdata.header;
|
||||
|
||||
int offset = miplump->dataofs[texnum];
|
||||
if (offset < 0)
|
||||
return NULL; //sometimes the texture just wasn't written. including its name.
|
||||
|
||||
const miptex_t *miptex = (miptex_t*)(bsp->dtexdata.base + offset);
|
||||
return miptex;
|
||||
}
|
||||
|
||||
const char *
|
||||
Face_TextureName(const bsp2_t *bsp, const bsp2_dface_t *face)
|
||||
{
|
||||
int texnum = bsp->texinfo[face->texinfo].miptex;
|
||||
if (!bsp->texdatasize)
|
||||
const miptex_t *miptex = Face_Miptex(bsp, face);
|
||||
if (miptex)
|
||||
return miptex->name;
|
||||
else
|
||||
return "";
|
||||
const dmiptexlump_t *miplump = bsp->dtexdata.header;
|
||||
if (!miplump->dataofs[texnum])
|
||||
return ""; //sometimes the texture just wasn't written. including its name.
|
||||
const miptex_t *miptex = (miptex_t*)(bsp->dtexdata.base + miplump->dataofs[texnum]);
|
||||
return miptex->name;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -202,22 +202,18 @@ Face_Contents(const bsp2_t *bsp, const bsp2_dface_t *face)
|
|||
if (!bsp->texdatasize)
|
||||
return CONTENTS_SOLID; // no textures in bsp
|
||||
|
||||
int texnum = bsp->texinfo[face->texinfo].miptex;
|
||||
const dmiptexlump_t *miplump = bsp->dtexdata.header;
|
||||
const miptex_t *miptex;
|
||||
|
||||
if (!miplump->dataofs[texnum])
|
||||
const char *texname = Face_TextureName(bsp, face);
|
||||
|
||||
if (texname[0] == '\0')
|
||||
return CONTENTS_SOLID; //sometimes the texture just wasn't written. including its name.
|
||||
|
||||
miptex = (miptex_t*)(bsp->dtexdata.base + miplump->dataofs[texnum]);
|
||||
|
||||
if (!Q_strncasecmp(miptex->name, "sky", 3))
|
||||
if (!Q_strncasecmp(texname, "sky", 3))
|
||||
return CONTENTS_SKY;
|
||||
else if (!Q_strncasecmp(miptex->name, "*lava", 5))
|
||||
else if (!Q_strncasecmp(texname, "*lava", 5))
|
||||
return CONTENTS_LAVA;
|
||||
else if (!Q_strncasecmp(miptex->name, "*slime", 6))
|
||||
else if (!Q_strncasecmp(texname, "*slime", 6))
|
||||
return CONTENTS_SLIME;
|
||||
else if (miptex->name[0] == '*')
|
||||
else if (texname[0] == '*')
|
||||
return CONTENTS_WATER;
|
||||
else
|
||||
return CONTENTS_SOLID;
|
||||
|
|
@ -346,18 +342,6 @@ BSP_MakeTnodes(const bsp2_t *bsp)
|
|||
* ============================================================================
|
||||
*/
|
||||
|
||||
static miptex_t *
|
||||
MiptexForFace(const bsp2_dface_t *face, const bsp2_t *bsp)
|
||||
{
|
||||
const texinfo_t *tex;
|
||||
dmiptexlump_t *miplump = bsp->dtexdata.header;
|
||||
miptex_t *miptex;
|
||||
tex = &bsp->texinfo[face->texinfo];
|
||||
|
||||
miptex = (miptex_t*)(bsp->dtexdata.base + miplump->dataofs[tex->miptex]);
|
||||
return miptex;
|
||||
}
|
||||
|
||||
vec_t fix_coord(vec_t in, int width)
|
||||
{
|
||||
if (in > 0)
|
||||
|
|
@ -377,8 +361,7 @@ SampleTexture(const bsp2_dface_t *face, const bsp2_t *bsp, const vec3_t point)
|
|||
{
|
||||
vec_t texcoord[2];
|
||||
const texinfo_t *tex;
|
||||
dmiptexlump_t *miplump = bsp->dtexdata.header;
|
||||
miptex_t *miptex;
|
||||
const miptex_t *miptex;
|
||||
int x, y;
|
||||
byte *data;
|
||||
int sample;
|
||||
|
|
@ -386,16 +369,15 @@ SampleTexture(const bsp2_dface_t *face, const bsp2_t *bsp, const vec3_t point)
|
|||
if (!bsp->texdatasize)
|
||||
return -1;
|
||||
|
||||
miptex = Face_Miptex(bsp, face);
|
||||
|
||||
if (miptex == NULL)
|
||||
return -1;
|
||||
|
||||
tex = &bsp->texinfo[face->texinfo];
|
||||
|
||||
WorldToTexCoord(point, tex, texcoord);
|
||||
|
||||
if (miplump->dataofs[tex->miptex] == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
miptex = (miptex_t*)(bsp->dtexdata.base + miplump->dataofs[tex->miptex]);
|
||||
|
||||
x = fix_coord(texcoord[0], miptex->width);
|
||||
y = fix_coord(texcoord[1], miptex->height);
|
||||
|
||||
|
|
@ -462,7 +444,7 @@ typedef struct {
|
|||
* TraceLine
|
||||
* ==============
|
||||
*/
|
||||
#define MAX_TSTACK 128
|
||||
#define MAX_TSTACK 256
|
||||
int
|
||||
TraceLine(const dmodel_t *model, const int traceflags,
|
||||
const vec3_t start, const vec3_t stop)
|
||||
|
|
@ -487,6 +469,7 @@ TraceLine(const dmodel_t *model, const int traceflags,
|
|||
return TRACE_HIT_NONE;
|
||||
}
|
||||
|
||||
// FIXME: check for stack overflow
|
||||
// const tracestack_t *const tstack_max = tracestack + MAX_TSTACK;
|
||||
|
||||
if (traceflags <= 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue