From fe72458f48566850f0a330e2dae7b17fd64cd8be Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 5 Mar 2017 09:54:00 -0800 Subject: [PATCH] Restore CCameraManager::GetCurrentCamera's proper behavior (AKA, I'm an idiot) --- Runtime/Camera/CCameraManager.cpp | 8 ++++---- Runtime/Camera/CCameraManager.hpp | 4 ++-- Runtime/Collision/CCollisionActor.cpp | 16 +++++++++++++++- Runtime/Collision/CCollisionActor.hpp | 1 + Runtime/GuiSys/CCompoundTargetReticle.cpp | 5 +++-- Runtime/World/CScriptActor.cpp | 1 + 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Runtime/Camera/CCameraManager.cpp b/Runtime/Camera/CCameraManager.cpp index 908adab18..fcf1391ea 100644 --- a/Runtime/Camera/CCameraManager.cpp +++ b/Runtime/Camera/CCameraManager.cpp @@ -142,16 +142,16 @@ void CCameraManager::Update(float dt, CStateManager& stateMgr) #endif } -CEntity* CCameraManager::GetCurrentCamera(CStateManager& stateMgr) const +CGameCamera* CCameraManager::GetCurrentCamera(CStateManager& stateMgr) const { CObjectList* camList = stateMgr.ObjectListById(EGameObjectList::GameCamera); - return camList->GetObjectById(GetCurrentCameraId()); + return static_cast(camList->GetObjectById(GetCurrentCameraId())); } -const CEntity* CCameraManager::GetCurrentCamera(const CStateManager& stateMgr) const +const CGameCamera* CCameraManager::GetCurrentCamera(const CStateManager& stateMgr) const { const CObjectList* camList = stateMgr.GetObjectListById(EGameObjectList::GameCamera); - return camList->GetObjectById(GetCurrentCameraId()); + return static_cast(camList->GetObjectById(GetCurrentCameraId())); } void CCameraManager::SkipCinematic(CStateManager& stateMgr) diff --git a/Runtime/Camera/CCameraManager.hpp b/Runtime/Camera/CCameraManager.hpp index f5b0ef09c..f9d5cf7fa 100644 --- a/Runtime/Camera/CCameraManager.hpp +++ b/Runtime/Camera/CCameraManager.hpp @@ -81,8 +81,8 @@ public: void AddCinemaCamera(TUniqueId, CStateManager& stateMgr); void SetInsideFluid(bool, TUniqueId); void Update(float dt, CStateManager& stateMgr); - CEntity* GetCurrentCamera(CStateManager& stateMgr) const; - const CEntity* GetCurrentCamera(const CStateManager& stateMgr) const; + CGameCamera* GetCurrentCamera(CStateManager& stateMgr) const; + const CGameCamera* GetCurrentCamera(const CStateManager& stateMgr) const; void SetCurrentCameraId(TUniqueId id, CStateManager& stateMgr) {x0_curCameraId = id;} TUniqueId GetCurrentCameraId() const { diff --git a/Runtime/Collision/CCollisionActor.cpp b/Runtime/Collision/CCollisionActor.cpp index b56a54057..de92e85bf 100644 --- a/Runtime/Collision/CCollisionActor.cpp +++ b/Runtime/Collision/CCollisionActor.cpp @@ -82,7 +82,21 @@ void CCollisionActor::SetDamageVulnerability(const CDamageVulnerability& vuln) { zeus::CVector3f CCollisionActor::GetScanObjectIndicatorPosition(const CStateManager& mgr) { const CGameCamera* gameCamera = static_cast(mgr.GetCameraManager()->GetCurrentCamera(mgr)); - return {}; + + float scanScale; + if (x258_primitiveType == EPrimitiveType::Sphere) + scanScale = GetSphereRadius(); + else + { + const zeus::CVector3f v = GetBoxSize(); + float comp = (v.x < v.y ? v.y : v.z); + comp = (comp < v.z ? v.x : comp); + + scanScale = 0.5f * comp; + } + scanScale *= 3.0f; + zeus::CVector3f orbitPos = GetOrbitPosition(mgr); + return (scanScale * (orbitPos - gameCamera->GetTransform().origin).normalized()) - orbitPos; } const CCollisionPrimitive* CCollisionActor::GetCollisionPrimitive() const diff --git a/Runtime/Collision/CCollisionActor.hpp b/Runtime/Collision/CCollisionActor.hpp index 5e98e20af..ec1704cf3 100644 --- a/Runtime/Collision/CCollisionActor.hpp +++ b/Runtime/Collision/CCollisionActor.hpp @@ -56,6 +56,7 @@ public: TUniqueId GetLastTouchedObject() const { return x2fc_lastTouched; } zeus::CVector3f GetScanObjectIndicatorPosition(const CStateManager &); void SetExtendedTouchBounds(const zeus::CVector3f& boundExt) { x304_extendedTouchBounds = boundExt; } + float GetSphereRadius() const { return x288_sphereRadius; } }; } diff --git a/Runtime/GuiSys/CCompoundTargetReticle.cpp b/Runtime/GuiSys/CCompoundTargetReticle.cpp index 86db1c553..3d0c02d85 100644 --- a/Runtime/GuiSys/CCompoundTargetReticle.cpp +++ b/Runtime/GuiSys/CCompoundTargetReticle.cpp @@ -1,5 +1,6 @@ #include "CCompoundTargetReticle.hpp" #include "GameGlobalObjects.hpp" +#include "Camera/CGameCamera.hpp" #include "CSimplePool.hpp" #include "Graphics/CModel.hpp" #include "CStateManager.hpp" @@ -23,8 +24,8 @@ CTargetReticleRenderState::CTargetReticleRenderState(TUniqueId target, float f1, } CCompoundTargetReticle::CCompoundTargetReticle(const CStateManager& mgr) -: x0_(static_cast(mgr.GetCameraManager()->GetCurrentCamera(mgr))->GetTransform().buildMatrix3f()) -, x10_(static_cast(mgr.GetCameraManager()->GetCurrentCamera(mgr))->GetTransform().buildMatrix3f()) +: x0_(mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTransform().buildMatrix3f()) +, x10_(mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTransform().buildMatrix3f()) , x2c_overshootOffsetHalf(0.5f * g_tweakTargeting->GetOvershootOffset()) , x30_premultOvershootOffset(calculate_premultiplied_overshoot_offset(g_tweakTargeting->GetOvershootOffset())) , x34_crosshairs(g_SimplePool->GetObj(skCrosshairsReticleAssetName)) diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index 69ba6a391..578bd664e 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -1,6 +1,7 @@ #include "CScriptActor.hpp" #include "CStateManager.hpp" #include "CScriptTrigger.hpp" +#include "Camera/CGameCamera.hpp" #include "CDamageVulnerability.hpp" #include "CPlayerState.hpp" #include "CScriptColorModulate.hpp"