Merge pull request #210 from lioncash/bob

CPlayerCameraBob: Minor cleanup
This commit is contained in:
Phillip Stephens 2020-03-12 15:10:19 -07:00 committed by GitHub
commit ce5ce35743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 18 deletions

View File

@ -126,9 +126,8 @@ float CPlayerGun::skTractorBeamFactor = 0.5f / CPlayerState::GetMissileComboChar
CPlayerGun::CPlayerGun(TUniqueId playerId) CPlayerGun::CPlayerGun(TUniqueId playerId)
: x0_lights(8, zeus::CVector3f{-30.f, 0.f, 30.f}, 4, 4, 0, 0, 0, 0.1f) : x0_lights(8, zeus::CVector3f{-30.f, 0.f, 30.f}, 4, 4, 0, 0, 0, 0.1f)
, x538_playerId(playerId) , x538_playerId(playerId)
, x550_camBob(CPlayerCameraBob::ECameraBobType::One, , x550_camBob(CPlayerCameraBob::ECameraBobType::One, CPlayerCameraBob::GetCameraBobExtent(),
zeus::CVector2f(CPlayerCameraBob::kCameraBobExtentX, CPlayerCameraBob::kCameraBobExtentY), CPlayerCameraBob::GetCameraBobPeriod())
CPlayerCameraBob::kCameraBobPeriod)
, x678_morph(g_tweakPlayerGun->GetGunTransformTime(), g_tweakPlayerGun->GetHoloHoldTime()) , x678_morph(g_tweakPlayerGun->GetGunTransformTime(), g_tweakPlayerGun->GetHoloHoldTime())
, x6c8_hologramClipCube(zeus::CVector3f(-0.29329199f, 0.f, -0.2481945f), , x6c8_hologramClipCube(zeus::CVector3f(-0.29329199f, 0.f, -0.2481945f),
zeus::CVector3f(0.29329199f, 1.292392f, 0.2481945f)) zeus::CVector3f(0.29329199f, 1.292392f, 0.2481945f))

View File

@ -225,10 +225,9 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox&
x490_gun = std::make_unique<CPlayerGun>(uid); x490_gun = std::make_unique<CPlayerGun>(uid);
x49c_gunHolsterRemTime = g_tweakPlayerGun->GetGunNotFiringTime(); x49c_gunHolsterRemTime = g_tweakPlayerGun->GetGunNotFiringTime();
x4a0_failsafeTest = std::make_unique<CFailsafeTest>(); x4a0_failsafeTest = std::make_unique<CFailsafeTest>();
x76c_cameraBob.reset( x76c_cameraBob.reset(new CPlayerCameraBob(CPlayerCameraBob::ECameraBobType::One,
new CPlayerCameraBob(CPlayerCameraBob::ECameraBobType::One, CPlayerCameraBob::GetCameraBobExtent(),
zeus::CVector2f{CPlayerCameraBob::kCameraBobExtentX, CPlayerCameraBob::kCameraBobExtentY}, CPlayerCameraBob::GetCameraBobPeriod()));
CPlayerCameraBob::kCameraBobPeriod));
x9c4_26_ = true; x9c4_26_ = true;
x9c4_27_canEnterMorphBall = true; x9c4_27_canEnterMorphBall = true;
x9c4_28_canLeaveMorphBall = true; x9c4_28_canLeaveMorphBall = true;
@ -722,8 +721,8 @@ float CPlayer::UpdateCameraBob(float dt, CStateManager& mgr) {
const float strafeDist = const float strafeDist =
skStrafeDistances[size_t(x2b0_outOfWaterTicks == 2 ? x2ac_surfaceRestraint : ESurfaceRestraints::Water)]; skStrafeDistances[size_t(x2b0_outOfWaterTicks == 2 ? x2ac_surfaceRestraint : ESurfaceRestraints::Water)];
bobMag = std::min(std::sqrt(f30 * f30 + f29 * f29) / std::sqrt(strafeDist * strafeDist + maxVel * maxVel) * bobMag = std::min(std::sqrt(f30 * f30 + f29 * f29) / std::sqrt(strafeDist * strafeDist + maxVel * maxVel) *
CPlayerCameraBob::kOrbitBobScale, CPlayerCameraBob::GetOrbitBobScale(),
CPlayerCameraBob::kMaxOrbitBobScale); CPlayerCameraBob::GetMaxOrbitBobScale());
if (bobMag < 0.01f) if (bobMag < 0.01f)
bobMag = 0.f; bobMag = 0.f;
} }
@ -770,8 +769,8 @@ float CPlayer::UpdateCameraBob(float dt, CStateManager& mgr) {
x76c_cameraBob->SetPlayerVelocity(backupVel); x76c_cameraBob->SetPlayerVelocity(backupVel);
x76c_cameraBob->SetState(state, mgr); x76c_cameraBob->SetState(state, mgr);
x76c_cameraBob->SetBobMagnitude(bobMag); x76c_cameraBob->SetBobMagnitude(bobMag);
x76c_cameraBob->SetBobTimeScale((1.f - CPlayerCameraBob::kSlowSpeedPeriodScale) * bobMag + x76c_cameraBob->SetBobTimeScale((1.f - CPlayerCameraBob::GetSlowSpeedPeriodScale()) * bobMag +
CPlayerCameraBob::kSlowSpeedPeriodScale); CPlayerCameraBob::GetSlowSpeedPeriodScale());
x76c_cameraBob->Update(dt, mgr); x76c_cameraBob->Update(dt, mgr);
return bobMag; return bobMag;
@ -799,9 +798,9 @@ void CPlayer::PostUpdate(float dt, CStateManager& mgr) {
float cameraBobT = 0.f; float cameraBobT = 0.f;
if (mgr.GetCameraManager()->IsInCinematicCamera()) { if (mgr.GetCameraManager()->IsInCinematicCamera()) {
const zeus::CVector2f bobExtent(CPlayerCameraBob::kCameraBobExtentX, CPlayerCameraBob::kCameraBobExtentY); x76c_cameraBob = std::make_unique<CPlayerCameraBob>(CPlayerCameraBob::ECameraBobType::One,
x76c_cameraBob = std::make_unique<CPlayerCameraBob>(CPlayerCameraBob::ECameraBobType::One, bobExtent, CPlayerCameraBob::GetCameraBobExtent(),
CPlayerCameraBob::kCameraBobPeriod); CPlayerCameraBob::GetCameraBobPeriod());
} else { } else {
cameraBobT = UpdateCameraBob(dt, mgr); cameraBobT = UpdateCameraBob(dt, mgr);
} }

View File

@ -29,7 +29,7 @@ const float CPlayerCameraBob::kCameraDamping = 6.f * std::sqrt(80.f);
CPlayerCameraBob::CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float bobPeriod) CPlayerCameraBob::CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float bobPeriod)
: x0_type(type), x4_vec(vec), xc_bobPeriod(bobPeriod) { : x0_type(type), x4_vec(vec), xc_bobPeriod(bobPeriod) {
std::fill(std::begin(x7c_wanderPoints), std::end(x7c_wanderPoints), zeus::skForward); x7c_wanderPoints.fill(zeus::skForward);
} }
zeus::CTransform CPlayerCameraBob::GetViewWanderTransform() const { return xd0_viewWanderXf; } zeus::CTransform CPlayerCameraBob::GetViewWanderTransform() const { return xd0_viewWanderXf; }

View File

@ -27,6 +27,13 @@ public:
Unspecified Unspecified
}; };
static zeus::CVector2f GetCameraBobExtent() { return {kCameraBobExtentX, kCameraBobExtentY}; }
static float GetCameraBobPeriod() { return kCameraBobPeriod; }
static float GetOrbitBobScale() { return kOrbitBobScale; }
static float GetMaxOrbitBobScale() { return kMaxOrbitBobScale; }
static float GetSlowSpeedPeriodScale() { return kSlowSpeedPeriodScale; }
private:
static float kCameraBobExtentX; static float kCameraBobExtentX;
static float kCameraBobExtentY; static float kCameraBobExtentY;
static float kCameraBobPeriod; static float kCameraBobPeriod;
@ -46,7 +53,6 @@ public:
static const float kLandingBobDamping2; static const float kLandingBobDamping2;
static const float kCameraDamping; static const float kCameraDamping;
private:
ECameraBobType x0_type; ECameraBobType x0_type;
zeus::CVector2f x4_vec; zeus::CVector2f x4_vec;
float xc_bobPeriod; float xc_bobPeriod;
@ -65,8 +71,8 @@ private:
float x70_landingTranslation = 0.f; float x70_landingTranslation = 0.f;
float x74_camVelocity = 0.f; float x74_camVelocity = 0.f;
float x78_camTranslation = 0.f; float x78_camTranslation = 0.f;
zeus::CVector3f x7c_wanderPoints[4]; std::array<zeus::CVector3f, 4> x7c_wanderPoints;
float xb0_wanderPitches[4] = {}; std::array<float, 4> xb0_wanderPitches{};
float xc4_wanderTime = 0.f; float xc4_wanderTime = 0.f;
float xc8_viewWanderSpeed = kViewWanderSpeedMin; float xc8_viewWanderSpeed = kViewWanderSpeedMin;
u32 xcc_wanderIndex = 0; u32 xcc_wanderIndex = 0;