WriteLightmaps: revert to how I was getting the sample points

This commit is contained in:
Eric Wasylishen 2016-02-15 15:26:54 -07:00
parent 7128a8e956
commit b2687481d6
1 changed files with 6 additions and 7 deletions

View File

@ -1626,7 +1626,6 @@ WriteLightmaps(bsp2_dface_t *face, facesup_t *facesup, const lightsurf_t *lights
const lightmap_t *lightmaps) const lightmap_t *lightmaps)
{ {
int numstyles, size, mapnum, width, s, t, i, j; int numstyles, size, mapnum, width, s, t, i, j;
const lightsample_t *sample;
vec_t light, maxcolor; vec_t light, maxcolor;
vec3_t color, direction; vec3_t color, direction;
byte *out, *lit, *lux; byte *out, *lit, *lux;
@ -1667,14 +1666,13 @@ WriteLightmaps(bsp2_dface_t *face, facesup_t *facesup, const lightsurf_t *lights
if (facesup) if (facesup)
facesup->lightofs = out - filebase; facesup->lightofs = out - filebase;
else else
face->lightofs = out - filebase; face->lightofs = out - filebase;
width = (lightsurf->texsize[0] + 1) * oversample; width = (lightsurf->texsize[0] + 1) * oversample;
for (mapnum = 0; mapnum < MAXLIGHTMAPS; mapnum++) { for (mapnum = 0; mapnum < MAXLIGHTMAPS; mapnum++) {
if (lightmaps[mapnum].style == 255) if (lightmaps[mapnum].style == 255)
break; break;
sample = lightmaps[mapnum].samples;
for (t = 0; t <= lightsurf->texsize[1]; t++) { for (t = 0; t <= lightsurf->texsize[1]; t++) {
for (s = 0; s <= lightsurf->texsize[0]; s++) { for (s = 0; s <= lightsurf->texsize[0]; s++) {
@ -1683,11 +1681,14 @@ WriteLightmaps(bsp2_dface_t *face, facesup_t *facesup, const lightsurf_t *lights
VectorCopy(vec3_origin, direction); VectorCopy(vec3_origin, direction);
for (i = 0; i < oversample; i++) { for (i = 0; i < oversample; i++) {
for (j = 0; j < oversample; j++) { for (j = 0; j < oversample; j++) {
const int col = (s*oversample) + j;
const int row = (t*oversample) + i;
const lightsample_t *sample = lightmaps[mapnum].samples + (row * width) + col;
VectorAdd(color, sample->color, color); VectorAdd(color, sample->color, color);
VectorAdd(direction, sample->direction, direction); VectorAdd(direction, sample->direction, direction);
sample++;
} }
sample += width - oversample;
} }
VectorScale(color, 1.0 / oversample / oversample, color); VectorScale(color, 1.0 / oversample / oversample, color);
@ -1733,9 +1734,7 @@ WriteLightmaps(bsp2_dface_t *face, facesup_t *facesup, const lightsurf_t *lights
v = (temp[1]+1)*128; *lux++ = (v>255)?255:v; v = (temp[1]+1)*128; *lux++ = (v>255)?255:v;
v = (temp[2]+1)*128; *lux++ = (v>255)?255:v; v = (temp[2]+1)*128; *lux++ = (v>255)?255:v;
} }
sample -= width * oversample - oversample;
} }
sample += width * oversample - width;
} }
} }
} }