- simplified calcSinTableValue and inlined it.

There's no need for all this magic voodoo - the sin function already returns the proper values all by itself.
This commit is contained in:
Christoph Oelckers 2020-08-02 22:03:22 +02:00
parent 9606601554
commit 8acc4101be
3 changed files with 11 additions and 13 deletions

View File

@ -938,7 +938,14 @@ int32_t videoSetRenderMode(int32_t renderer);
void renderSetRollAngle(float rolla);
#endif
double calcSinTableValue(double index);
//
// Calculates and returns a sintable[] value of the equivilent index (and supports fractional indexes also)
//
inline double calcSinTableValue(double index)
{
return 16384. * sin(BANG2RAD * index);
}
// pal: pass -1 to invalidate all palettes for the tile, or >=0 for a particular palette
// how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield

View File

@ -4323,12 +4323,3 @@ void renderSetRollAngle(float rolla)
}
#endif
//
// Calculates and returns a sintable[] value of the equivilent index (and supports fractional indexes also)
//
double calcSinTableValue(double index)
{
double value = fabs(16384. * sin(BANG2RAD * (index - (fmod(index, 512) * 2))));
return (index >= 1024 ? -value : value);
}

View File

@ -305,11 +305,11 @@ void displayweapon_d(int snum, double smoothratio)
gun_pos = 80 - (opos + fmulscale16(npos - opos, smoothratio));
weapon_xoffset = (160)-90;
weapon_xoffset -= calcSinTableValue(fmod((weapon_sway / 2.) + 512, 2048)) / (1024. + 512.);
weapon_xoffset -= calcSinTableValue((weapon_sway / 2.) + 512) / (1024. + 512.);
weapon_xoffset -= 58 + p->weapon_ang;
if( sprite[p->i].xrepeat < 32 )
gun_pos -= fabs(calcSinTableValue(fmod(weapon_sway * 4., 2048)) / 512.);
else gun_pos -= fabs(calcSinTableValue(fmod(weapon_sway / 2., 2048)) / 1024.);
gun_pos -= fabs(calcSinTableValue(weapon_sway * 4.) / 512.);
else gun_pos -= fabs(calcSinTableValue(weapon_sway / 2.) / 1024.);
gun_pos -= (p->hard_landing<<3);