light: fix saving bogus lightmaps for non-lightmapped faces when -bounce is in use
This commit is contained in:
parent
b33cd040f7
commit
0e5438ab14
|
|
@ -157,7 +157,7 @@ typedef struct {
|
||||||
struct ltface_ctx
|
struct ltface_ctx
|
||||||
{
|
{
|
||||||
const bsp2_t *bsp;
|
const bsp2_t *bsp;
|
||||||
lightsurf_t lightsurf;
|
lightsurf_t *lightsurf;
|
||||||
lightmap_t lightmaps[MAXLIGHTMAPS + 1];
|
lightmap_t lightmaps[MAXLIGHTMAPS + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2070,20 +2070,25 @@ void LightFaceShutdown(struct ltface_ctx *ctx)
|
||||||
free(ctx->lightmaps[i].samples);
|
free(ctx->lightmaps[i].samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->lightsurf.points)
|
if (!ctx->lightsurf)
|
||||||
free(ctx->lightsurf.points);
|
return;
|
||||||
|
|
||||||
if (ctx->lightsurf.normals)
|
if (ctx->lightsurf->points)
|
||||||
free(ctx->lightsurf.normals);
|
free(ctx->lightsurf->points);
|
||||||
|
|
||||||
if (ctx->lightsurf.occlusion)
|
if (ctx->lightsurf->normals)
|
||||||
free(ctx->lightsurf.occlusion);
|
free(ctx->lightsurf->normals);
|
||||||
|
|
||||||
if (ctx->lightsurf.occluded)
|
if (ctx->lightsurf->occlusion)
|
||||||
free(ctx->lightsurf.occluded);
|
free(ctx->lightsurf->occlusion);
|
||||||
|
|
||||||
if (ctx->lightsurf.pvs)
|
if (ctx->lightsurf->occluded)
|
||||||
free(ctx->lightsurf.pvs);
|
free(ctx->lightsurf->occluded);
|
||||||
|
|
||||||
|
if (ctx->lightsurf->pvs)
|
||||||
|
free(ctx->lightsurf->pvs);
|
||||||
|
|
||||||
|
free(ctx->lightsurf);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
@ -2115,7 +2120,6 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
|
||||||
|
|
||||||
const bsp2_t *bsp = ctx->bsp;
|
const bsp2_t *bsp = ctx->bsp;
|
||||||
lightmap_t *lightmaps = ctx->lightmaps;
|
lightmap_t *lightmaps = ctx->lightmaps;
|
||||||
lightsurf_t *lightsurf = &ctx->lightsurf;
|
|
||||||
const char *texname = Face_TextureName(bsp, face);
|
const char *texname = Face_TextureName(bsp, face);
|
||||||
|
|
||||||
/* One extra lightmap is allocated to simplify handling overflow */
|
/* One extra lightmap is allocated to simplify handling overflow */
|
||||||
|
|
@ -2144,6 +2148,11 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
|
||||||
if (!Q_strcasecmp(texname, "skip"))
|
if (!Q_strcasecmp(texname, "skip"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* all good, this face is going to be lightmapped. */
|
||||||
|
ctx->lightsurf = (lightsurf_t *) calloc(1, sizeof(lightsurf_t));
|
||||||
|
lightsurf_t *lightsurf = ctx->lightsurf;
|
||||||
|
|
||||||
|
|
||||||
/* if liquid doesn't have the TEX_SPECIAL flag set, the map was qbsp'ed with
|
/* if liquid doesn't have the TEX_SPECIAL flag set, the map was qbsp'ed with
|
||||||
* lit water in mind. In that case receive light from both top and bottom.
|
* lit water in mind. In that case receive light from both top and bottom.
|
||||||
* (lit will only be rendered in compatible engines, but degrades gracefully.)
|
* (lit will only be rendered in compatible engines, but degrades gracefully.)
|
||||||
|
|
@ -2281,7 +2290,11 @@ void
|
||||||
LightFaceIndirect(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, struct ltface_ctx *ctx)
|
LightFaceIndirect(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, struct ltface_ctx *ctx)
|
||||||
{
|
{
|
||||||
lightmap_t *lightmaps = ctx->lightmaps;
|
lightmap_t *lightmaps = ctx->lightmaps;
|
||||||
lightsurf_t *lightsurf = &ctx->lightsurf;
|
lightsurf_t *lightsurf = ctx->lightsurf;
|
||||||
|
|
||||||
|
if (lightsurf == NULL)
|
||||||
|
return; /* this face is not lightmapped */
|
||||||
|
|
||||||
if (debugmode == debugmode_bounce)
|
if (debugmode == debugmode_bounce)
|
||||||
{
|
{
|
||||||
Lightmap_ClearAll(lightmaps);
|
Lightmap_ClearAll(lightmaps);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue