1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-21 14:31:17 +00:00

Angle cleanup - RADF_TO_BINANG (#1155)

* Run formatter

* Touch up angle macros (parentheses and hex constants)

* Use `RADF_TO_BINANG` more
This commit is contained in:
Dragorn421 2022-03-13 19:46:46 +01:00 committed by GitHub
parent aab5bc9211
commit 61b864a89c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 120 additions and 128 deletions

View file

@ -687,9 +687,9 @@ void BossTw_FlyTo(BossTw* this, GlobalContext* globalCtx) {
yDiff = this->targetPos.y - this->actor.world.pos.y;
zDiff = this->targetPos.z - this->actor.world.pos.z;
yawTarget = (s16)(Math_FAtan2F(xDiff, zDiff) * (32768.0f / M_PI));
yawTarget = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff));
xzDist = sqrtf(SQ(xDiff) + SQ(zDiff));
pitchTarget = (s16)(Math_FAtan2F(yDiff, xzDist) * (32768.0f / M_PI));
pitchTarget = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist));
Math_ApproachS(&this->actor.world.rot.x, pitchTarget, 0xA, this->rotateSpeed);
Math_ApproachS(&this->actor.world.rot.y, yawTarget, 0xA, this->rotateSpeed);
@ -2360,8 +2360,8 @@ void BossTw_DeathBall(BossTw* this, GlobalContext* globalCtx) {
yDiff = this->targetPos.y - this->actor.world.pos.y;
zDiff = this->targetPos.z - this->actor.world.pos.z;
yaw = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI);
Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff))) * (32768 / M_PI), 5,
yaw = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff));
Math_ApproachS(&this->actor.world.rot.x, RADF_TO_BINANG(Math_FAtan2F(yDiff, sqrtf(SQ(xDiff) + SQ(zDiff)))), 5,
this->rotateSpeed);
Math_ApproachS(&this->actor.world.rot.y, yaw, 5, this->rotateSpeed);
func_8002D908(&this->actor);
@ -3924,10 +3924,10 @@ void BossTw_BlastFire(BossTw* this, GlobalContext* globalCtx) {
yDiff = (player->actor.world.pos.y + 30.0f) - this->actor.world.pos.y;
zDiff = player->actor.world.pos.z - this->actor.world.pos.z;
// yaw
this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI);
this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff));
// pitch
distXZ = sqrtf(SQ(xDiff) + SQ(zDiff));
this->actor.world.rot.x = Math_FAtan2F(yDiff, distXZ) * (32768 / M_PI);
this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, distXZ));
this->actor.speedXZ = 20.0f;
for (i = 0; i < 50; i++) {
@ -4114,9 +4114,9 @@ void BossTw_BlastIce(BossTw* this, GlobalContext* globalCtx) {
xDiff = player->actor.world.pos.x - this->actor.world.pos.x;
yDiff = (player->actor.world.pos.y + 30.0f) - this->actor.world.pos.y;
zDiff = player->actor.world.pos.z - this->actor.world.pos.z;
this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI);
this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff));
xzDist = sqrtf(SQ(xDiff) + SQ(zDiff));
this->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI);
this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist));
this->actor.speedXZ = 20.0f;
for (i = 0; i < 50; i++) {
this->blastTailPos[i] = this->actor.world.pos;
@ -5383,9 +5383,9 @@ void BossTw_TwinrovaSetupFly(BossTw* this, GlobalContext* globalCtx) {
this->actionFunc = BossTw_TwinrovaFly;
this->rotateSpeed = 0.0f;
this->actor.speedXZ = 0.0f;
this->actor.world.rot.y = Math_FAtan2F(xDiff, zDiff) * (32768 / M_PI);
this->actor.world.rot.y = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff));
xzDist = sqrtf(SQ(xDiff) + SQ(zDiff));
this->actor.world.rot.x = Math_FAtan2F(yDiff, xzDist) * (32768 / M_PI);
this->actor.world.rot.x = RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist));
Animation_MorphToLoop(&this->skelAnime, &object_tw_Anim_032BF8, -10.0f);
}
@ -5402,12 +5402,9 @@ void BossTw_TwinrovaFly(BossTw* this, GlobalContext* globalCtx) {
xDiff = this->targetPos.x - this->actor.world.pos.x;
yDiff = this->targetPos.y - this->actor.world.pos.y;
zDiff = this->targetPos.z - this->actor.world.pos.z;
// Convert from radians to degrees, then degrees to binary angle
yaw = (s16)(Math_FAtan2F(xDiff, zDiff) * ((180.0f / M_PI) * (65536.0f / 360.0f)));
yaw = RADF_TO_BINANG(Math_FAtan2F(xDiff, zDiff));
xzDist = sqrtf(SQ(xDiff) + SQ(zDiff));
Math_ApproachS(&this->actor.world.rot.x,
(f32)(s16)(Math_FAtan2F(yDiff, xzDist) * ((180.0f / M_PI) * (65536.0f / 360.0f))), 0xA,
this->rotateSpeed);
Math_ApproachS(&this->actor.world.rot.x, (f32)RADF_TO_BINANG(Math_FAtan2F(yDiff, xzDist)), 0xA, this->rotateSpeed);
Math_ApproachS(&this->actor.world.rot.y, yaw, 0xA, this->rotateSpeed);
Math_ApproachS(&this->actor.shape.rot.y, yaw, 0xA, this->rotateSpeed);
Math_ApproachF(&this->rotateSpeed, 2000.0f, 1.0f, 100.0f);