From: havoc Date: Sat, 4 Mar 2006 14:52:53 +0000 (+0000) Subject: some cleanup of surface->cached_dlight handling to fix the broken unlit q1bsp handlin... X-Git-Tag: xonotic-v0.1.0preview~4247 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=d3b4529a89a8361c1bd437b873cbdcae3c4d2ca6;p=xonotic%2Fdarkplaces.git some cleanup of surface->cached_dlight handling to fix the broken unlit q1bsp handling (it was not appearing fullbright as it should), and this also is a slight optimization git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6067 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index 4ce812c8..f2a7bb03 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1898,13 +1898,13 @@ void RSurf_SetColorPointer(const entity_render_t *ent, const msurface_t *surface } 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) @@ -2388,7 +2388,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces) 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; @@ -2419,7 +2419,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces) 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; diff --git a/model_brush.c b/model_brush.c index 44aeb7ae..93222301 100644 --- a/model_brush.c +++ b/model_brush.c @@ -2095,8 +2095,6 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) // 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); @@ -2116,6 +2114,7 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) 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; @@ -2123,6 +2122,8 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) 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