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

@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ ri.ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude))
#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ (int)( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude))
static float *TableForFunc( genFunc_t func )
{
@ -920,7 +920,7 @@ void RB_CalcEnvironmentTexCoords( float *st )
void RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *st )
{
int i;
float now;
double now;
now = ( wf->phase + tess.shaderTime * wf->frequency );
@ -954,11 +954,13 @@ void RB_CalcScaleTexCoords( const float scale[2], float *st )
void RB_CalcScrollTexCoords( const float scrollSpeed[2], float *st )
{
int i;
float timeScale = tess.shaderTime;
float adjustedScrollS, adjustedScrollT;
double timeScale;
double adjustedScrollS, adjustedScrollT;
adjustedScrollS = scrollSpeed[0] * timeScale;
adjustedScrollT = scrollSpeed[1] * timeScale;
timeScale = tess.shaderTime;
adjustedScrollS = (double)scrollSpeed[0] * timeScale;
adjustedScrollT = (double)scrollSpeed[1] * timeScale;
// clamp so coordinates don't continuously get larger, causing problems
// with hardware limits
@ -994,9 +996,9 @@ void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *st )
*/
void RB_CalcRotateTexCoords( float degsPerSecond, float *st )
{
float timeScale = tess.shaderTime;
float degs;
int index;
double timeScale = tess.shaderTime;
double degs;
int64_t index;
float sinValue, cosValue;
texModInfo_t tmi;