diff --git a/source/build/include/build.h b/source/build/include/build.h index 88f6dc6bb..4e9d7abde 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -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 diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 3ae659ae4..bc73e5f27 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -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); -} - diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 5db8c63e1..f99677c4f 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -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);