CCameraManager: Collapse private static variables into functions

Four of the five variables aren't modified, so they can be specified
directly within the functions and just be reused in place of the
variable names. This allows the constants to be elided or put into
read-only memory if necessary. It also makes the mutable value explicit.
This commit is contained in:
Lioncash 2019-09-27 22:46:56 -04:00
parent 8591787409
commit 359f505787
2 changed files with 7 additions and 15 deletions

View File

@ -15,11 +15,7 @@
#include "World/CExplosion.hpp" #include "World/CExplosion.hpp"
namespace urde { namespace urde {
float CCameraManager::sAspect = 1.42f;
float CCameraManager::sFarPlane = 750.f;
float CCameraManager::sNearPlane = 0.2f;
float CCameraManager::sFirstPersonFOV = 55.f; float CCameraManager::sFirstPersonFOV = 55.f;
float CCameraManager::sThirdPersonFOV = 60.f;
CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCameraId) { CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCameraId) {
CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::skZero3f, zeus::skZero3f, CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::skZero3f, zeus::skZero3f,
@ -135,13 +131,13 @@ void CCameraManager::CreateStandardCameras(CStateManager& stateMgr) {
TUniqueId fpId = stateMgr.AllocateUniqueId(); TUniqueId fpId = stateMgr.AllocateUniqueId();
x7c_fpCamera = x7c_fpCamera =
new CFirstPersonCamera(fpId, zeus::CTransform(), stateMgr.Player()->GetUniqueId(), new CFirstPersonCamera(fpId, zeus::CTransform(), stateMgr.Player()->GetUniqueId(),
g_tweakPlayer->GetOrbitCameraSpeed(), sFirstPersonFOV, sNearPlane, sFarPlane, sAspect); g_tweakPlayer->GetOrbitCameraSpeed(), sFirstPersonFOV, NearPlane(), FarPlane(), Aspect());
stateMgr.AddObject(x7c_fpCamera); stateMgr.AddObject(x7c_fpCamera);
stateMgr.Player()->SetCameraState(CPlayer::EPlayerCameraState::FirstPerson, stateMgr); stateMgr.Player()->SetCameraState(CPlayer::EPlayerCameraState::FirstPerson, stateMgr);
SetCurrentCameraId(fpId, stateMgr); SetCurrentCameraId(fpId, stateMgr);
x80_ballCamera = new CBallCamera(stateMgr.AllocateUniqueId(), stateMgr.Player()->GetUniqueId(), x80_ballCamera = new CBallCamera(stateMgr.AllocateUniqueId(), stateMgr.Player()->GetUniqueId(), zeus::CTransform(),
zeus::CTransform(), sThirdPersonFOV, sNearPlane, sFarPlane, sAspect); ThirdPersonFOV(), NearPlane(), FarPlane(), Aspect());
stateMgr.AddObject(x80_ballCamera); stateMgr.AddObject(x80_ballCamera);
x88_interpCamera = new CInterpolationCamera(stateMgr.AllocateUniqueId(), zeus::CTransform()); x88_interpCamera = new CInterpolationCamera(stateMgr.AllocateUniqueId(), zeus::CTransform());

View File

@ -17,11 +17,7 @@ class CScriptCameraHint;
class CCinematicCamera; class CCinematicCamera;
class CCameraManager { class CCameraManager {
static float sAspect;
static float sFarPlane;
static float sNearPlane;
static float sFirstPersonFOV; static float sFirstPersonFOV;
static float sThirdPersonFOV;
TUniqueId x0_curCameraId; TUniqueId x0_curCameraId;
std::vector<TUniqueId> x4_cineCameras; std::vector<TUniqueId> x4_cineCameras;
std::list<CCameraShakeData> x14_shakers; std::list<CCameraShakeData> x14_shakers;
@ -80,11 +76,11 @@ class CCameraManager {
public: public:
CCameraManager(TUniqueId curCameraId = kInvalidUniqueId); CCameraManager(TUniqueId curCameraId = kInvalidUniqueId);
static float Aspect() { return sAspect; } static float Aspect() { return 1.42f; }
static float FarPlane() { return sFarPlane; } static float FarPlane() { return 750.0f; }
static float NearPlane() { return sNearPlane; } static float NearPlane() { return 0.2f; }
static float FirstPersonFOV() { return sFirstPersonFOV; } static float FirstPersonFOV() { return sFirstPersonFOV; }
static float ThirdPersonFOV() { return sThirdPersonFOV; } static float ThirdPersonFOV() { return 60.0f; }
void ResetCameras(CStateManager& mgr); void ResetCameras(CStateManager& mgr);
void SetSpecialCameras(CFirstPersonCamera& fp, CBallCamera& ball); void SetSpecialCameras(CFirstPersonCamera& fp, CBallCamera& ball);