summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2015-07-12 17:53:17 -0500
committerTim Angus <tim@ngus.net>2016-04-07 11:02:30 +0100
commit3021d2b30e8d2b8456484cc9cd8adc30bda0a98e (patch)
tree160d81a94561c92574e72d47253d23b1786cb184
parent17abbc7123b1f79467d18c64b67235ce41c115c4 (diff)
Backport ignoring values outside lightgrid to OpenGL1
Fixes possibly of reading memory past end of lightGridData or reading wrong light grid data (wrapping around to next row).
-rw-r--r--src/renderergl1/tr_light.c6
-rw-r--r--src/renderergl2/tr_light.c10
2 files changed, 10 insertions, 6 deletions
diff --git a/src/renderergl1/tr_light.c b/src/renderergl1/tr_light.c
index bd79df55..35233739 100644
--- a/src/renderergl1/tr_light.c
+++ b/src/renderergl1/tr_light.c
@@ -183,6 +183,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
data = gridData;
for ( j = 0 ; j < 3 ; j++ ) {
if ( i & (1<<j) ) {
+ if ( pos[j] + 1 > tr.world->lightGridBounds[j] - 1 ) {
+ break; // ignore values outside lightgrid
+ }
factor *= frac[j];
data += gridStep[j];
} else {
@@ -190,6 +193,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) {
}
}
+ if ( j != 3 ) {
+ continue;
+ }
if ( !(data[0]+data[1]+data[2]) ) {
continue; // ignore samples in walls
}
diff --git a/src/renderergl2/tr_light.c b/src/renderergl2/tr_light.c
index ec54eab4..317f4585 100644
--- a/src/renderergl2/tr_light.c
+++ b/src/renderergl2/tr_light.c
@@ -181,18 +181,15 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) {
byte *data;
int lat, lng;
vec3_t normal;
- qboolean ignore;
#if idppc
float d0, d1, d2, d3, d4, d5;
#endif
factor = 1.0;
data = gridData;
- ignore = qfalse;
for ( j = 0 ; j < 3 ; j++ ) {
if ( i & (1<<j) ) {
- if ((pos[j] + 1) > world->lightGridBounds[j] - 1)
- {
- ignore = qtrue; // ignore values outside lightgrid
+ if ( pos[j] + 1 > world->lightGridBounds[j] - 1 ) {
+ break; // ignore values outside lightgrid
}
factor *= frac[j];
data += gridStep[j];
@@ -201,8 +198,9 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) {
}
}
- if ( ignore )
+ if ( j != 3 ) {
continue;
+ }
if (world->hdrLightGrid)
{