}
else if (lightmode >= 1)
{
- if (surface->lightmapinfo)
+ if (surface->lightmapinfo && surface->lightmapinfo->stainsamples)
{
for (i = 0, c = varray_color4f + 4 * surface->num_firstvertex;i < surface->num_vertices;i++, c += 4)
{
- const unsigned char *lm = surface->lightmapinfo->samples + (surface->groupmesh->data_lightmapoffsets + surface->num_firstvertex)[i];
- if (lm)
+ if (surface->lightmapinfo->samples)
{
+ const unsigned char *lm = surface->lightmapinfo->samples + (surface->groupmesh->data_lightmapoffsets + surface->num_firstvertex)[i];
float scale = r_refdef.lightstylevalue[surface->lightmapinfo->styles[0]] * (1.0f / 32768.0f);
VectorScale(lm, scale, c);
if (surface->lightmapinfo->styles[1] != 255)
if (f && surface->num_triangles)
{
// if lightmap parameters changed, rebuild lightmap texture
- if (surface->cached_dlight && surface->lightmapinfo->samples)
+ if (surface->cached_dlight)
R_BuildLightMap(ent, surface);
// add face to draw list
surfacelist[numsurfacelist++] = surface;
if (f && surface->num_triangles)
{
// if lightmap parameters changed, rebuild lightmap texture
- if (surface->cached_dlight && surface->lightmapinfo->samples)
+ if (surface->cached_dlight)
R_BuildLightMap(ent, surface);
// add face to draw list
surfacelist[numsurfacelist++] = surface;
// lighting info
for (i = 0;i < MAXLIGHTMAPS;i++)
surface->lightmapinfo->styles[i] = in->styles[i];
- // force lightmap upload on first time seeing the surface
- surface->cached_dlight = true;
surface->lightmapinfo->lightmaptexturestride = 0;
surface->lightmaptexture = NULL;
i = LittleLong(in->lightofs);
else // LordHavoc: white lighting (bsp version 29)
surface->lightmapinfo->samples = loadmodel->brushq1.lightdata + (i * 3);
+ // check if we should apply a lightmap to this
if (!(surface->lightmapinfo->texinfo->flags & TEX_SPECIAL) || surface->lightmapinfo->samples)
{
int i, iu, iv;
if (ssize > 256 || tsize > 256)
Host_Error("Bad surface extents");
+ // force lightmap upload on first time seeing the surface
+ surface->cached_dlight = true;
// stainmap for permanent marks on walls
surface->lightmapinfo->stainsamples = (unsigned char *)Mem_Alloc(loadmodel->mempool, ssize * tsize * 3);
// clear to white