1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-29 03:34:07 +00:00

fix Math_GetAtan2Tbl (#1132)

This commit is contained in:
fig02 2022-02-05 17:45:03 -05:00 committed by GitHub
parent c8f4d66b00
commit b41489c443
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,16 +78,20 @@ static u16 sATan2Tbl[] = {
}; };
u16 Math_GetAtan2Tbl(f32 x, f32 y) { u16 Math_GetAtan2Tbl(f32 x, f32 y) {
s32 tblIdx = ((x / y) * 1024.0f) + 0.5f;
u16 ret; u16 ret;
if (y == 0.0f) { if (y == 0.0f) {
ret = sATan2Tbl[0]; ret = sATan2Tbl[0];
} else if (tblIdx >= ARRAY_COUNT(sATan2Tbl)) {
ret = sATan2Tbl[0];
} else { } else {
ret = sATan2Tbl[tblIdx]; s32 tblIdx = ((x / y) * 1024.0f) + 0.5f;
if (tblIdx >= ARRAY_COUNT(sATan2Tbl)) {
ret = sATan2Tbl[0];
} else {
ret = sATan2Tbl[tblIdx];
}
} }
return ret; return ret;
} }