mirror of
https://github.com/ZDoom/Raze.git
synced 2025-06-02 18:21:06 +00:00
- cleanup of bvectan family of functions.
This can be greatly simplified to a single bvectangbam function using atan2 directly.
This commit is contained in:
parent
b4d89cbac3
commit
057b8a7354
4 changed files with 10 additions and 48 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue