CMorphBall: Collapse common code within ApplyGravity()

All that differs between the conditionals is the gravity value used, so
we can collapse all of this down to simply conditionally retrieve that.
This commit is contained in:
Lioncash 2020-05-11 18:39:21 -04:00
parent 0af9b16b92
commit c60290819e
2 changed files with 8 additions and 7 deletions

View File

@ -2168,12 +2168,13 @@ float CMorphBall::CalculateSurfaceFriction() const {
return friction;
}
void CMorphBall::ApplyGravity(CStateManager& mgr) {
if (x0_player.CheckSubmerged() && !mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit)) {
x0_player.SetMomentumWR(zeus::CVector3f(0.f, 0.f, g_tweakBall->GetBallWaterGravity() * x0_player.GetMass()));
} else {
x0_player.SetMomentumWR(zeus::CVector3f(0.f, 0.f, g_tweakBall->GetBallGravity() * x0_player.GetMass()));
}
void CMorphBall::ApplyGravity(const CStateManager& mgr) {
const float mass = x0_player.GetMass();
const bool hasGravitySuit = mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit);
const bool useWaterGravity = x0_player.CheckSubmerged() && !hasGravitySuit;
const float gravity = useWaterGravity ? g_tweakBall->GetBallWaterGravity() : g_tweakBall->GetBallGravity();
x0_player.SetMomentumWR(zeus::CVector3f(0.f, 0.f, gravity * mass));
}
void CMorphBall::SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag) {

View File

@ -249,7 +249,7 @@ public:
void ComputeLiftForces(const zeus::CVector3f& controlForce, const zeus::CVector3f& velocity,
const CStateManager& mgr);
float CalculateSurfaceFriction() const;
void ApplyGravity(CStateManager& mgr);
void ApplyGravity(const CStateManager& mgr);
void SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag);
float ComputeMaxSpeed() const;
void Touch(CActor& actor, CStateManager& mgr);