Fix floating point precision loss in renderer [part 1]

Patch for https://bugzilla.icculus.org/show_bug.cgi?id=5931 by
Eugene C. from 2013 plus recent fix for tcMod rotate.

I merged the changes into the OpenGL2 renderer though the fix for
tcMod turb doesn't translate.
This commit is contained in:
Zack Middleton 2017-08-02 22:39:27 -05:00
parent 9c4c363ccc
commit 30fdd88c9f
8 changed files with 63 additions and 47 deletions

View file

@ -509,7 +509,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
int i;
drawSurf_t *drawSurf;
int oldSort;
float originalTime;
double originalTime;
// save original time for entity shader offsets
originalTime = backEnd.refdef.floatTime;
@ -562,7 +562,10 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
if ( entityNum != REFENTITYNUM_WORLD ) {
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime;
// FIXME: e.shaderTime must be passed as int to avoid fp-precision loss issues
backEnd.refdef.floatTime = originalTime - (double)backEnd.currentEntity->e.shaderTime;
// we have to reset the shaderTime as well otherwise image animations start
// from the wrong frame
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
@ -713,7 +716,7 @@ void RB_SetGL2D (void) {
// set time for 2D shaders
backEnd.refdef.time = ri.Milliseconds();
backEnd.refdef.floatTime = backEnd.refdef.time * 0.001f;
backEnd.refdef.floatTime = (double)backEnd.refdef.time * 0.001f;
}