From 17abbc7123b1f79467d18c64b67235ce41c115c4 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 9 Jul 2015 22:28:08 -0500 Subject: Fix OpenGL2 ignoring last light grid point on each axis Also change light grid bounds clamping to make it more clear what invalid values are. --- src/renderergl1/tr_light.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/renderergl1/tr_light.c') diff --git a/src/renderergl1/tr_light.c b/src/renderergl1/tr_light.c index 779451f1..bd79df55 100644 --- a/src/renderergl1/tr_light.c +++ b/src/renderergl1/tr_light.c @@ -152,7 +152,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent ) { frac[i] = v - pos[i]; if ( pos[i] < 0 ) { pos[i] = 0; - } else if ( pos[i] >= tr.world->lightGridBounds[i] - 1 ) { + } else if ( pos[i] > tr.world->lightGridBounds[i] - 1 ) { pos[i] = tr.world->lightGridBounds[i] - 1; } } -- cgit From 3021d2b30e8d2b8456484cc9cd8adc30bda0a98e Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 12 Jul 2015 17:53:17 -0500 Subject: 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). --- src/renderergl1/tr_light.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/renderergl1/tr_light.c') 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< 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 } -- cgit