diff options
author | aap <aap@papnet.eu> | 2021-08-20 10:33:02 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2021-08-20 10:33:02 +0200 |
commit | aed313d81c7602e49dc5f0d2ccf382811744d0bb (patch) | |
tree | 6104b4d4b7497395e7f6619ea74700c40b38b49c /src/core | |
parent | disable switch workflow for now (diff) | |
download | re3-aed313d81c7602e49dc5f0d2ccf382811744d0bb.tar re3-aed313d81c7602e49dc5f0d2ccf382811744d0bb.tar.gz re3-aed313d81c7602e49dc5f0d2ccf382811744d0bb.tar.bz2 re3-aed313d81c7602e49dc5f0d2ccf382811744d0bb.tar.lz re3-aed313d81c7602e49dc5f0d2ccf382811744d0bb.tar.xz re3-aed313d81c7602e49dc5f0d2ccf382811744d0bb.tar.zst re3-aed313d81c7602e49dc5f0d2ccf382811744d0bb.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Cam.cpp | 70 | ||||
-rw-r--r-- | src/core/General.h | 34 |
2 files changed, 9 insertions, 95 deletions
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index b4da6296..72e1adf0 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -5063,6 +5063,11 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, // Using GetCarGun(LR/UD) will give us same unprocessed RightStick value as SA float stickX = -(pad->GetCarGunLeftRight()); float stickY = -pad->GetCarGunUpDown(); + // HACK to disable rotation on tank for now + if(car->GetModelIndex() == MI_RHINO){ + stickX = 0.0f; + stickY = 0.0f; + } // In SA this checks for m_bUseMouse3rdPerson so num2 / num8 do not move camera // when Keyboard & Mouse controls are used. To make it work better with III/VC, check for actual pad state instead @@ -5357,70 +5362,5 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, // SA // gTargetCoordsForLookingBehind = TargetCoors; - // SA code from CAutomobile::TankControl/FireTruckControl. - if (car->GetModelIndex() == MI_RHINO || car->GetModelIndex() == MI_FIRETRUCK) { - - float &carGunLR = ((CAutomobile*)car)->m_fCarGunLR; - CVector hi = Multiply3x3(Front, car->GetMatrix()); - - // III/VC's firetruck turret angle is reversed - float angleToFace = (car->GetModelIndex() == MI_FIRETRUCK ? -hi.Heading() : hi.Heading()); - - if (angleToFace <= carGunLR + PI) { - if (angleToFace < carGunLR - PI) - angleToFace = angleToFace + TWOPI; - } else { - angleToFace = angleToFace - TWOPI; - } - - float neededTurn = angleToFace - carGunLR; - float turnPerFrame = CTimer::GetTimeStep() * (car->GetModelIndex() == MI_FIRETRUCK ? 0.05f : 0.015f); - if (neededTurn <= turnPerFrame) { - if (neededTurn < -turnPerFrame) - angleToFace = carGunLR - turnPerFrame; - } else { - angleToFace = turnPerFrame + carGunLR; - } - - if (car->GetModelIndex() == MI_RHINO && carGunLR != angleToFace) { - DMAudio.PlayOneShot(car->m_audioEntityId, SOUND_CAR_TANK_TURRET_ROTATE, Abs(angleToFace - carGunLR)); - } - carGunLR = angleToFace; - - if (carGunLR < -PI) { - carGunLR += TWOPI; - } else if (carGunLR > PI) { - carGunLR -= TWOPI; - } - - // Because firetruk turret also has Y movement - if (car->GetModelIndex() == MI_FIRETRUCK) { - float &carGunUD = ((CAutomobile*)car)->m_fCarGunUD; - - float alphaToFace = Atan2(hi.z, hi.Magnitude2D()) + DEGTORAD(15.0f); - float neededAlphaTurn = alphaToFace - carGunUD; - float alphaTurnPerFrame = CTimer::GetTimeStepInSeconds(); - - if (neededAlphaTurn > alphaTurnPerFrame) { - neededTurn = alphaTurnPerFrame; - carGunUD = neededTurn + carGunUD; - } else { - if (neededAlphaTurn >= -alphaTurnPerFrame) { - carGunUD = alphaToFace; - } else { - carGunUD = carGunUD - alphaTurnPerFrame; - } - } - - float turretMinY = -DEGTORAD(20.0f); - float turretMaxY = DEGTORAD(20.0f); - if (turretMinY <= carGunUD) { - if (carGunUD > turretMaxY) - carGunUD = turretMaxY; - } else { - carGunUD = turretMinY; - } - } - } } #endif diff --git a/src/core/General.h b/src/core/General.h index c17d916d..62613445 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -6,36 +6,10 @@ class CGeneral { public: static float GetATanOfXY(float x, float y){ - if(x == 0.0f && y == 0.0f) - return 0.0f; - float xabs = Abs(x); - float yabs = Abs(y); - - if(xabs < yabs){ - if(y > 0.0f){ - if(x > 0.0f) - return 0.5f*PI - Atan2(x / y, 1.0f); - else - return 0.5f*PI + Atan2(-x / y, 1.0f); - }else{ - if(x > 0.0f) - return 1.5f*PI + Atan2(x / -y, 1.0f); - else - return 1.5f*PI - Atan2(-x / -y, 1.0f); - } - }else{ - if(y > 0.0f){ - if(x > 0.0f) - return Atan2(y / x, 1.0f); - else - return PI - Atan2(y / -x, 1.0f); - }else{ - if(x > 0.0f) - return 2.0f*PI - Atan2(-y / x, 1.0f); - else - return PI + Atan2(-y / -x, 1.0f); - } - } + float arc = atan2f(y, x); + if(arc < 0.0f) + arc += TWOPI; + return arc; } static float LimitAngle(float angle) |