mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 04:50:42 +00:00
- Remove calcSinTableValue()
inline function and clean up use of PI
/fPI
and BANG2RAD
#defines.
This commit is contained in:
parent
6b66a958d0
commit
0190a98a10
12 changed files with 18 additions and 43 deletions
|
@ -89,16 +89,6 @@ inline int Cos(int ang)
|
||||||
return costable[ang & 2047];
|
return costable[ang & 2047];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double Sinf(double ang)
|
|
||||||
{
|
|
||||||
return (1 << 30) * sin(BANG2RAD * ang);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double Cosf(double ang)
|
|
||||||
{
|
|
||||||
return (1 << 30) * sin(BANG2RAD * (ang + 512.));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int SinScale16(int ang)
|
inline int SinScale16(int ang)
|
||||||
{
|
{
|
||||||
return FixedToInt(costable[(ang - 512) & 2047]);
|
return FixedToInt(costable[(ang - 512) & 2047]);
|
||||||
|
|
|
@ -232,9 +232,9 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
|
||||||
predict.at20 = clamp(predict.at20+pInput->horz, IntToFixed(-60), IntToFixed(60));
|
predict.at20 = clamp(predict.at20+pInput->horz, IntToFixed(-60), IntToFixed(60));
|
||||||
|
|
||||||
if (predict.at20 > 0)
|
if (predict.at20 > 0)
|
||||||
predict.at24 = FloatToFixed(fmulscale30(120., Sinf(FixedToFloat(predict.at20) * 8.)));
|
predict.at24 = FloatToFixed(fmulscale30(120., bsinf(FixedToFloat(predict.at20) * 8., 16)));
|
||||||
else if (predict.at20 < 0)
|
else if (predict.at20 < 0)
|
||||||
predict.at24 = FloatToFixed(fmulscale30(180., Sinf(FixedToFloat(predict.at20) * 8.)));
|
predict.at24 = FloatToFixed(fmulscale30(180., bsinf(FixedToFloat(predict.at20) * 8., 16)));
|
||||||
else
|
else
|
||||||
predict.at24 = 0;
|
predict.at24 = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -127,7 +127,7 @@ void GameInterface::UpdateSounds()
|
||||||
|
|
||||||
if (gMe->pSprite)
|
if (gMe->pSprite)
|
||||||
{
|
{
|
||||||
listener.angle = -(float)gMe->pSprite->ang * pi::pi() / 1024; // Build uses a period of 2048.
|
listener.angle = -gMe->pSprite->ang * BAngRadian; // Build uses a period of 2048.
|
||||||
listener.velocity.Zero();
|
listener.velocity.Zero();
|
||||||
listener.position = GetSoundPos(&gMe->pSprite->pos);
|
listener.position = GetSoundPos(&gMe->pSprite->pos);
|
||||||
listener.valid = true;
|
listener.valid = true;
|
||||||
|
|
|
@ -631,7 +631,7 @@ void viewDrawScreen(bool sceneonly)
|
||||||
int viewingRange = viewingrange;
|
int viewingRange = viewingrange;
|
||||||
videoSetCorrectedAspect();
|
videoSetCorrectedAspect();
|
||||||
|
|
||||||
int v1 = xs_CRoundToInt(double(viewingrange) * tan(r_fov * (PI / 360.)));
|
int v1 = xs_CRoundToInt(double(viewingrange) * tan(r_fov * (pi::pi() / 360.)));
|
||||||
|
|
||||||
renderSetAspect(v1, yxaspect);
|
renderSetAspect(v1, yxaspect);
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,6 @@ enum rendmode_t {
|
||||||
REND_POLYMER
|
REND_POLYMER
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PI 3.14159265358979323846
|
|
||||||
#define fPI 3.14159265358979323846f
|
|
||||||
|
|
||||||
#define BANG2RAD (PI * (1./1024.))
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAXSECTORS = 4096,
|
MAXSECTORS = 4096,
|
||||||
|
@ -717,14 +712,6 @@ int32_t wallvisible(int32_t const x, int32_t const y, int16_t const wallnum);
|
||||||
void renderSetRollAngle(float rolla);
|
void renderSetRollAngle(float rolla);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrecacheHardwareTextures(int nTile);
|
void PrecacheHardwareTextures(int nTile);
|
||||||
void Polymost_Startup();
|
void Polymost_Startup();
|
||||||
|
|
||||||
|
|
|
@ -412,19 +412,19 @@ static int32_t engineLoadTables(void)
|
||||||
reciptable[i] = divscale30(2048, i+2048);
|
reciptable[i] = divscale30(2048, i+2048);
|
||||||
|
|
||||||
for (i=0; i<=512; i++)
|
for (i=0; i<=512; i++)
|
||||||
sintable[i] = (int16_t)(16384.f * sinf((float)i * BANG2RAD) + 0.0001f);
|
sintable[i] = bsinf(i);
|
||||||
for (i=513; i<1024; i++)
|
for (i=513; i<1024; i++)
|
||||||
sintable[i] = sintable[1024-i];
|
sintable[i] = sintable[1024-i];
|
||||||
for (i=1024; i<2048; i++)
|
for (i=1024; i<2048; i++)
|
||||||
sintable[i] = -sintable[i-1024];
|
sintable[i] = -sintable[i-1024];
|
||||||
|
|
||||||
for (i=0; i<640; i++)
|
for (i=0; i<640; i++)
|
||||||
radarang[i] = (int16_t)(atanf(((float)(640-i)-0.5f) * (1.f/160.f)) * (-64.f * (1.f/BANG2RAD)) + 0.0001f);
|
radarang[i] = atan((639.5 - i) / 160.) * (-64. / BAngRadian);
|
||||||
for (i=0; i<640; i++)
|
for (i=0; i<640; i++)
|
||||||
radarang[1279-i] = -radarang[i];
|
radarang[1279-i] = -radarang[i];
|
||||||
|
|
||||||
for (i=0; i<5120; i++)
|
for (i=0; i<5120; i++)
|
||||||
qradarang[i] = FloatToFixed(atanf(((float)(5120-i)-0.5f) * (1.f/1280.f)) * (-64.f * (1.f/BANG2RAD)));
|
qradarang[i] = FloatToFixed(atan((5119.5 - i) / 1280.) * (-64. / BAngRadian));
|
||||||
for (i=0; i<5120; i++)
|
for (i=0; i<5120; i++)
|
||||||
qradarang[10239-i] = -qradarang[i];
|
qradarang[10239-i] = -qradarang[i];
|
||||||
|
|
||||||
|
@ -1000,10 +1000,8 @@ void set_globalang(fixed_t const ang)
|
||||||
qglobalang = ang & 0x7FFFFFF;
|
qglobalang = ang & 0x7FFFFFF;
|
||||||
|
|
||||||
float const f_ang = FixedToFloat(ang);
|
float const f_ang = FixedToFloat(ang);
|
||||||
float const f_ang_radians = f_ang * M_PI * (1.f/1024.f);
|
float const fcosang = bcosf(f_ang);
|
||||||
|
float const fsinang = bsinf(f_ang);
|
||||||
float const fcosang = cosf(f_ang_radians) * 16384.f;
|
|
||||||
float const fsinang = sinf(f_ang_radians) * 16384.f;
|
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
fcosglobalang = fcosang;
|
fcosglobalang = fcosang;
|
||||||
|
@ -3195,7 +3193,7 @@ void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
void renderSetRollAngle(float rolla)
|
void renderSetRollAngle(float rolla)
|
||||||
{
|
{
|
||||||
gtang = rolla * (fPI * (1.f/1024.f));
|
gtang = rolla * BAngRadian;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2458,7 +2458,7 @@ void polymost_drawrooms()
|
||||||
{
|
{
|
||||||
// calculates the extend of the zenith glitch
|
// calculates the extend of the zenith glitch
|
||||||
float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f);
|
float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f);
|
||||||
float verticalfov = atanf(verticalfovtan) * (2.f / fPI);
|
float verticalfov = atanf(verticalfovtan) * (2.f / pi::pi());
|
||||||
static constexpr float const maxhorizangle = 0.6361136f; // horiz of 199 in degrees
|
static constexpr float const maxhorizangle = 0.6361136f; // horiz of 199 in degrees
|
||||||
float zenglitch = verticalfov + maxhorizangle - 0.95f; // less than 1 because the zenith glitch extends a bit
|
float zenglitch = verticalfov + maxhorizangle - 0.95f; // less than 1 because the zenith glitch extends a bit
|
||||||
if (zenglitch > 0.f)
|
if (zenglitch > 0.f)
|
||||||
|
@ -2850,7 +2850,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang
|
||||||
{
|
{
|
||||||
// calculates the extend of the zenith glitch
|
// calculates the extend of the zenith glitch
|
||||||
float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f);
|
float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f);
|
||||||
float verticalfov = atanf(verticalfovtan) * (2.f / fPI);
|
float verticalfov = atanf(verticalfovtan) * (2.f / pi::pi());
|
||||||
static constexpr float const maxhorizangle = 0.6361136f; // horiz of 199 in degrees
|
static constexpr float const maxhorizangle = 0.6361136f; // horiz of 199 in degrees
|
||||||
float zenglitch = verticalfov + maxhorizangle - 0.95f; // less than 1 because the zenith glitch extends a bit
|
float zenglitch = verticalfov + maxhorizangle - 0.95f; // less than 1 because the zenith glitch extends a bit
|
||||||
if (zenglitch > 0.f)
|
if (zenglitch > 0.f)
|
||||||
|
|
|
@ -456,7 +456,7 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
|
||||||
else if (type == SOURCE_Swirly)
|
else if (type == SOURCE_Swirly)
|
||||||
{
|
{
|
||||||
int which = *(int*)source;
|
int which = *(int*)source;
|
||||||
float phase = (leveltime << (6 + which)) * (M_PI / 1024);
|
float phase = (leveltime << (6 + which)) * BAngRadian;
|
||||||
pos->X = fcampos.X + 256 * cos(phase);
|
pos->X = fcampos.X + 256 * cos(phase);
|
||||||
pos->Z = fcampos.Z + 256 * sin(phase);
|
pos->Z = fcampos.Z + 256 * sin(phase);
|
||||||
}
|
}
|
||||||
|
@ -519,7 +519,7 @@ void GameInterface::UpdateSounds()
|
||||||
}
|
}
|
||||||
auto fv = GetSoundPos(&pos);
|
auto fv = GetSoundPos(&pos);
|
||||||
SoundListener listener;
|
SoundListener listener;
|
||||||
listener.angle = -(float)ang * pi::pi() / 1024; // Build uses a period of 2048.
|
listener.angle = -ang * BAngRadian; // Build uses a period of 2048.
|
||||||
listener.velocity.Zero();
|
listener.velocity.Zero();
|
||||||
listener.position = GetSoundPos(&pos);
|
listener.position = GetSoundPos(&pos);
|
||||||
listener.underwater = false;
|
listener.underwater = false;
|
||||||
|
|
|
@ -375,7 +375,7 @@ void DrawView(double smoothRatio, bool sceneonly)
|
||||||
static uint8_t sectorCeilingPal[MAXSECTORS];
|
static uint8_t sectorCeilingPal[MAXSECTORS];
|
||||||
static uint8_t wallPal[MAXWALLS];
|
static uint8_t wallPal[MAXWALLS];
|
||||||
int const viewingRange = viewingrange;
|
int const viewingRange = viewingrange;
|
||||||
int const vr = xs_CRoundToInt(65536.f * tanf(r_fov * (fPI / 360.f)));
|
int const vr = xs_CRoundToInt(65536.f * tanf(r_fov * (pi::pi() / 360.f)));
|
||||||
|
|
||||||
|
|
||||||
videoSetCorrectedAspect();
|
videoSetCorrectedAspect();
|
||||||
|
|
|
@ -413,7 +413,7 @@ void GameInterface::UpdateSounds(void)
|
||||||
|
|
||||||
if (c != nullptr)
|
if (c != nullptr)
|
||||||
{
|
{
|
||||||
listener.angle = -(float)ca * pi::pi() / 1024; // Build uses a period of 2048.
|
listener.angle = -ca * BAngRadian; // Build uses a period of 2048.
|
||||||
listener.velocity.Zero();
|
listener.velocity.Zero();
|
||||||
listener.position = GetSoundPos(c);
|
listener.position = GetSoundPos(c);
|
||||||
listener.underwater = false;
|
listener.underwater = false;
|
||||||
|
|
|
@ -1755,7 +1755,7 @@ drawscreen(PLAYERp pp, double smoothratio)
|
||||||
|
|
||||||
|
|
||||||
videoSetCorrectedAspect();
|
videoSetCorrectedAspect();
|
||||||
renderSetAspect(xs_CRoundToInt(double(viewingrange)* tan(r_fov* (PI / 360.))), yxaspect);
|
renderSetAspect(xs_CRoundToInt(double(viewingrange)* tan(r_fov * (pi::pi() / 360.))), yxaspect);
|
||||||
OverlapDraw = true;
|
OverlapDraw = true;
|
||||||
DrawOverlapRoom(tx, ty, tz, tang.asq16(), thoriz.asq16(), tsectnum);
|
DrawOverlapRoom(tx, ty, tz, tang.asq16(), thoriz.asq16(), tsectnum);
|
||||||
OverlapDraw = false;
|
OverlapDraw = false;
|
||||||
|
|
|
@ -594,7 +594,7 @@ void GameInterface::UpdateSounds(void)
|
||||||
PLAYERp pp = Player + screenpeek;
|
PLAYERp pp = Player + screenpeek;
|
||||||
SoundListener listener;
|
SoundListener listener;
|
||||||
|
|
||||||
listener.angle = -(pp->angle.ang.asbam() / (double)BAMUNIT) * pi::pi() / 1024; // Build uses a period of 2048.
|
listener.angle = -pp->angle.ang.asbuild() * BAngRadian; // Build uses a period of 2048.
|
||||||
listener.velocity.Zero();
|
listener.velocity.Zero();
|
||||||
listener.position = GetSoundPos((vec3_t*)&pp->posx);
|
listener.position = GetSoundPos((vec3_t*)&pp->posx);
|
||||||
listener.underwater = false;
|
listener.underwater = false;
|
||||||
|
|
Loading…
Reference in a new issue