diff --git a/src/client/refresh/soft/header/model.h b/src/client/refresh/soft/header/model.h index 7135c97f..ec2faea7 100644 --- a/src/client/refresh/soft/header/model.h +++ b/src/client/refresh/soft/header/model.h @@ -95,8 +95,7 @@ typedef struct msurface_s // lighting info byte styles[MAXLIGHTMAPS]; - byte *samples; // [numstyles*surfsize] - byte *colorsamples; // [numstyles*surfsize*3] + byte *samples; // [numstyles*surfsize*3] struct msurface_s *nextalphasurface; } msurface_t; @@ -209,7 +208,6 @@ typedef struct model_s dvis_t *vis; byte *lightdata; - byte *colordata; // for alias models and sprites image_t *skins[MAX_MD2SKINS]; diff --git a/src/client/refresh/soft/sw_light.c b/src/client/refresh/soft/sw_light.c index 39bcff41..07b37d55 100644 --- a/src/client/refresh/soft/sw_light.c +++ b/src/client/refresh/soft/sw_light.c @@ -122,7 +122,6 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end) int s, t, ds, dt; int i; mtexinfo_t *tex; - byte *lightmap; int maps; int r; @@ -158,6 +157,8 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end) surf = r_worldmodel->surfaces + node->firstsurface; for (i=0 ; inumsurfaces ; i++, surf++) { + byte *lightmap; + if (surf->flags&(SURF_DRAWTURB|SURF_DRAWSKY)) continue; // no lightmaps @@ -181,7 +182,7 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end) ds >>= 4; dt >>= 4; - lightmap = surf->colorsamples; + lightmap = surf->samples; VectorCopy (vec3_origin, pointcolor); lightmap += 3 * (dt * ((surf->extents[0] >> 4) + 1) + ds); @@ -398,6 +399,7 @@ R_BuildLightMap (drawsurf_t* drawsurf) smax = (surf->extents[0]>>4)+1; tmax = (surf->extents[1]>>4)+1; size = smax*tmax; + if (blocklight_max <= blocklights + size) { r_outoflights = true; @@ -406,7 +408,6 @@ R_BuildLightMap (drawsurf_t* drawsurf) if (r_fullbright->value || !r_worldmodel->lightdata) { - memset(blocklights, 0, size * sizeof(light_t)); return; } @@ -423,11 +424,26 @@ R_BuildLightMap (drawsurf_t* drawsurf) maps++) { unsigned scale; + light_t *curr_light, *max_light; + + curr_light = blocklights; + max_light = blocklights + size; scale = drawsurf->lightadj[maps]; // 8.8 fraction - for (i=0 ; ifilelen) { @@ -266,22 +265,9 @@ Mod_LoadLighting (model_t *loadmodel, byte *mod_base, lump_t *l) return; } - size = l->filelen/3; + size = l->filelen; loadmodel->lightdata = Hunk_Alloc(size); - loadmodel->colordata = Hunk_Alloc(size * 3); - in = mod_base + l->fileofs; - for (i=0 ; i in[1] && in[0] > in[2]) - loadmodel->lightdata[i] = in[0]; - else if (in[1] > in[0] && in[1] > in[2]) - loadmodel->lightdata[i] = in[1]; - else - loadmodel->lightdata[i] = in[2]; - loadmodel->colordata[i*3 + 0] = loadmodel->lightdata[i]; - loadmodel->colordata[i*3 + 1] = loadmodel->lightdata[i]; - loadmodel->colordata[i*3 + 2] = loadmodel->lightdata[i]; - } + memcpy(loadmodel->lightdata, mod_base + l->fileofs, size); } @@ -671,12 +657,10 @@ Mod_LoadFaces (model_t *loadmodel, byte *mod_base, lump_t *l) if (i == -1) { out->samples = NULL; - out->colorsamples = NULL; } else { - out->samples = loadmodel->lightdata + i/3; - out->colorsamples = loadmodel->colordata + i; + out->samples = loadmodel->lightdata + i; } // set the drawing flags flag @@ -1022,11 +1006,10 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen) // lighting is a special case, because we keep only 1 byte out of 3 // (=> no colored lighting in soft renderer by default) { - int size = header->lumps[LUMP_LIGHTING].filelen/3; + int size = header->lumps[LUMP_LIGHTING].filelen; size = (size + 31) & ~31; - hunkSize += size; /* save color data */ - hunkSize += size * 3; + hunkSize += size; } hunkSize += calcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t), 6);