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

@ -65,7 +65,8 @@ R_BindAnimatedImageToTMU
=================
*/
static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) {
int index;
int64_t index;
double v;
if ( bundle->isVideoMap ) {
ri.CIN_RunCinematic(bundle->videoMapHandle);
@ -81,8 +82,10 @@ static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) {
// it is necessary to do this messy calc to make sure animations line up
// exactly with waveforms of the same frequency
index = ri.ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE);
index >>= FUNCTABLE_SIZE2;
//index = ri.ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE);
//index >>= FUNCTABLE_SIZE2;
v = tess.shaderTime * bundle->imageAnimationSpeed;
index = v;
if ( index < 0 ) {
index = 0; // may happen with shader time offsets