- cleanup of bvectan family of functions.

This can be greatly simplified to a single bvectangbam function using atan2 directly.
This commit is contained in:
Christoph Oelckers 2021-04-10 12:54:29 +02:00
parent b4d89cbac3
commit 057b8a7354
4 changed files with 10 additions and 48 deletions

View file

@ -502,54 +502,11 @@ inline FSerializer &Serialize(FSerializer &arc, const char *key, fixedhoriz &obj
//---------------------------------------------------------------------------
//
// Double-precision implementation of `getangle()` with associated wrappers and helper functions.
// High precision vector angle function, mainly for the renderer.
//
//---------------------------------------------------------------------------
inline double bradarangf(double vect)
{
return atan(vect) * BRadAngScale;
}
inline double bvectangf(int32_t x, int32_t y)
{
if ((x | y) == 0)
{
return 0;
}
else if (x == 0)
{
return 512 + ((y < 0) << 10);
}
else if (y == 0)
{
return ((x < 0) << 10);
}
else if (x == y)
{
return 256 + ((x < 0) << 10);
}
else if (x == -y)
{
return 768 + ((x > 0) << 10);
}
else if (abs(x) > abs(y))
{
return fmod(bradarangf(double(y) / x) + ((x < 0) << 10), 2048.);
}
else
{
return fmod(bradarangf(double(x) / -y) + 512 + ((y < 0) << 10), 2048.);
}
}
inline int32_t bvectang(int32_t x, int32_t y)
{
return xs_CRoundToInt(bvectangf(x, y));
}
inline fixed_t bvectangq16(int32_t x, int32_t y)
{
return FloatToFixed(bvectangf(x, y));
}
inline binangle bvectangbam(int32_t x, int32_t y)
{
return bamang(xs_CRoundToUInt(bvectangf(x, y) * BAMUNIT));
return radang(atan2(y, x));
}