mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-16 04:30:38 +00:00
Add gethiq16angle and the getq16angle wrapper to the engine
This commit is contained in:
parent
e2a789b8cc
commit
6fcb8f7a6a
2 changed files with 27 additions and 0 deletions
|
@ -935,6 +935,12 @@ int32_t krand(void);
|
||||||
|
|
||||||
int32_t ksqrt(uint32_t num);
|
int32_t ksqrt(uint32_t num);
|
||||||
int32_t LUNATIC_FASTCALL getangle(int32_t xvect, int32_t yvect);
|
int32_t LUNATIC_FASTCALL getangle(int32_t xvect, int32_t yvect);
|
||||||
|
fix16_t LUNATIC_FASTCALL gethiq16angle(int32_t xvect, int32_t yvect);
|
||||||
|
|
||||||
|
static FORCE_INLINE fix16_t LUNATIC_FASTCALL getq16angle(int32_t xvect, int32_t yvect)
|
||||||
|
{
|
||||||
|
return fix16_from_int(getangle(xvect, yvect));
|
||||||
|
}
|
||||||
|
|
||||||
static FORCE_INLINE CONSTEXPR uint32_t uhypsq(int32_t const dx, int32_t const dy)
|
static FORCE_INLINE CONSTEXPR uint32_t uhypsq(int32_t const dx, int32_t const dy)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4023,6 +4023,27 @@ int32_t LUNATIC_FASTCALL getangle(int32_t xvect, int32_t yvect)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fix16_t LUNATIC_FASTCALL gethiq16angle(int32_t xvect, int32_t yvect)
|
||||||
|
{
|
||||||
|
fix16_t rv;
|
||||||
|
|
||||||
|
if ((xvect | yvect) == 0)
|
||||||
|
rv = 0;
|
||||||
|
else if (xvect == 0)
|
||||||
|
rv = fix16_from_int(512 + ((yvect < 0) << 10));
|
||||||
|
else if (yvect == 0)
|
||||||
|
rv = fix16_from_int(((xvect < 0) << 10));
|
||||||
|
else if (xvect == yvect)
|
||||||
|
rv = fix16_from_int(256 + ((xvect < 0) << 10));
|
||||||
|
else if (xvect == -yvect)
|
||||||
|
rv = fix16_from_int(768 + ((xvect > 0) << 10));
|
||||||
|
else if (klabs(xvect) > klabs(yvect))
|
||||||
|
rv = ((qradarang[5120 + scale(1280, yvect, xvect)] >> 6) + fix16_from_int(((xvect < 0) << 10))) & 0x7FFFFFF;
|
||||||
|
else rv = ((qradarang[5120 - scale(1280, xvect, yvect)] >> 6) + fix16_from_int(512 + ((yvect < 0) << 10))) & 0x7FFFFFF;
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// ksqrt
|
// ksqrt
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue