mirror of https://github.com/AxioDL/metaforce.git
CCameraManager: Make use of TCastToConstPtr where applicable
Makes the read-only behavior explicit.
This commit is contained in:
parent
75cd9b6cf3
commit
7d8bcfbd5e
|
@ -71,10 +71,10 @@ void CCameraManager::EnterCinematic(CStateManager& mgr) {
|
||||||
mgr.GetPlayer().GetPlayerGun()->CancelFiring(mgr);
|
mgr.GetPlayer().GetPlayerGun()->CancelFiring(mgr);
|
||||||
mgr.GetPlayer().UnFreeze(mgr);
|
mgr.GetPlayer().UnFreeze(mgr);
|
||||||
|
|
||||||
for (CEntity* ent : mgr.GetAllObjectList()) {
|
for (const CEntity* ent : mgr.GetAllObjectList()) {
|
||||||
if (TCastToPtr<CExplosion> explo = ent) {
|
if (const TCastToConstPtr<CExplosion> explo = ent) {
|
||||||
mgr.FreeScriptObject(explo->GetUniqueId());
|
mgr.FreeScriptObject(explo->GetUniqueId());
|
||||||
} else if (TCastToPtr<CWeapon> weap = ent) {
|
} else if (const TCastToConstPtr<CWeapon> weap = ent) {
|
||||||
if (weap->GetActive()) {
|
if (weap->GetActive()) {
|
||||||
if (False(weap->GetAttribField() & EProjectileAttrib::KeepInCinematic)) {
|
if (False(weap->GetAttribField() & EProjectileAttrib::KeepInCinematic)) {
|
||||||
if (TCastToConstPtr<CAi>(mgr.GetObjectById(weap->GetOwnerId())) ||
|
if (TCastToConstPtr<CAi>(mgr.GetObjectById(weap->GetOwnerId())) ||
|
||||||
|
@ -87,13 +87,16 @@ void CCameraManager::EnterCinematic(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::AddCinemaCamera(TUniqueId id, CStateManager& stateMgr) {
|
void CCameraManager::AddCinemaCamera(TUniqueId id, CStateManager& stateMgr) {
|
||||||
if (x4_cineCameras.empty())
|
if (x4_cineCameras.empty()) {
|
||||||
EnterCinematic(stateMgr);
|
EnterCinematic(stateMgr);
|
||||||
|
}
|
||||||
|
|
||||||
RemoveCinemaCamera(id, stateMgr);
|
RemoveCinemaCamera(id, stateMgr);
|
||||||
x4_cineCameras.push_back(id);
|
x4_cineCameras.push_back(id);
|
||||||
if (TCastToPtr<CCinematicCamera> cam = stateMgr.ObjectById(id)) {
|
|
||||||
if (cam->GetFlags() & 0x4) // into player eye
|
if (const TCastToPtr<CCinematicCamera> cam = stateMgr.ObjectById(id)) {
|
||||||
{
|
// Into player eye
|
||||||
|
if ((cam->GetFlags() & 0x4) != 0) {
|
||||||
float time = 4.f;
|
float time = 4.f;
|
||||||
float delayTime = cam->GetDuration() - 4.f;
|
float delayTime = cam->GetDuration() - 4.f;
|
||||||
if (delayTime < 0.f) {
|
if (delayTime < 0.f) {
|
||||||
|
@ -150,8 +153,8 @@ void CCameraManager::CreateStandardCameras(CStateManager& stateMgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::SkipCinematic(CStateManager& stateMgr) {
|
void CCameraManager::SkipCinematic(CStateManager& stateMgr) {
|
||||||
TUniqueId camId = GetCurrentCameraId();
|
const TUniqueId camId = GetCurrentCameraId();
|
||||||
CCinematicCamera* ent = static_cast<CCinematicCamera*>(stateMgr.ObjectById(camId));
|
auto* ent = static_cast<CCinematicCamera*>(stateMgr.ObjectById(camId));
|
||||||
while (ent) {
|
while (ent) {
|
||||||
ent->SetActive(false);
|
ent->SetActive(false);
|
||||||
ent->WasDeactivated(stateMgr);
|
ent->WasDeactivated(stateMgr);
|
||||||
|
@ -163,7 +166,7 @@ void CCameraManager::SkipCinematic(CStateManager& stateMgr) {
|
||||||
|
|
||||||
void CCameraManager::SetPathCamera(TUniqueId id, CStateManager& mgr) {
|
void CCameraManager::SetPathCamera(TUniqueId id, CStateManager& mgr) {
|
||||||
xa4_pathCamId = id;
|
xa4_pathCamId = id;
|
||||||
if (TCastToPtr<CPathCamera> cam = mgr.ObjectById(id)) {
|
if (const TCastToPtr<CPathCamera> cam = mgr.ObjectById(id)) {
|
||||||
cam->Reset(GetCurrentCameraTransform(mgr), mgr);
|
cam->Reset(GetCurrentCameraTransform(mgr), mgr);
|
||||||
x80_ballCamera->TeleportCamera(cam->GetTransform(), mgr);
|
x80_ballCamera->TeleportCamera(cam->GetTransform(), mgr);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +174,7 @@ void CCameraManager::SetPathCamera(TUniqueId id, CStateManager& mgr) {
|
||||||
|
|
||||||
void CCameraManager::SetSpindleCamera(TUniqueId id, CStateManager& mgr) {
|
void CCameraManager::SetSpindleCamera(TUniqueId id, CStateManager& mgr) {
|
||||||
xa2_spindleCamId = id;
|
xa2_spindleCamId = id;
|
||||||
if (TCastToPtr<CScriptSpindleCamera> cam = mgr.ObjectById(id)) {
|
if (const TCastToPtr<CScriptSpindleCamera> cam = mgr.ObjectById(id)) {
|
||||||
cam->Reset(GetCurrentCameraTransform(mgr), mgr);
|
cam->Reset(GetCurrentCameraTransform(mgr), mgr);
|
||||||
x80_ballCamera->TeleportCamera(cam->GetTransform(), mgr);
|
x80_ballCamera->TeleportCamera(cam->GetTransform(), mgr);
|
||||||
}
|
}
|
||||||
|
@ -188,32 +191,37 @@ void CCameraManager::InterpolateToBallCamera(const zeus::CTransform& xf, TUnique
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::RestoreHintlessCamera(CStateManager& mgr) {
|
void CCameraManager::RestoreHintlessCamera(CStateManager& mgr) {
|
||||||
TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId);
|
const TCastToConstPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId);
|
||||||
zeus::CTransform ballCamXf = x80_ballCamera->GetTransform();
|
const zeus::CTransform ballCamXf = x80_ballCamera->GetTransform();
|
||||||
|
|
||||||
xa6_camHintId = kInvalidUniqueId;
|
xa6_camHintId = kInvalidUniqueId;
|
||||||
xa8_hintPriority = 1000;
|
xa8_hintPriority = 1000;
|
||||||
if (hint) {
|
|
||||||
zeus::CVector3f camToPlayerFlat = mgr.GetPlayer().GetTranslation() - ballCamXf.origin;
|
|
||||||
camToPlayerFlat.z() = 0.f;
|
|
||||||
if (camToPlayerFlat.canBeNormalized())
|
|
||||||
camToPlayerFlat.normalize();
|
|
||||||
else
|
|
||||||
camToPlayerFlat = mgr.GetPlayer().GetMoveDir();
|
|
||||||
|
|
||||||
x80_ballCamera->ResetToTweaks(mgr);
|
if (!hint) {
|
||||||
x80_ballCamera->UpdateLookAtPosition(0.f, mgr);
|
return;
|
||||||
if (!mgr.GetPlayer().IsMorphBallTransitioning() &&
|
}
|
||||||
hint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Default) {
|
|
||||||
if ((hint->GetHint().GetOverrideFlags() & 0x1000) != 0) {
|
zeus::CVector3f camToPlayerFlat = mgr.GetPlayer().GetTranslation() - ballCamXf.origin;
|
||||||
x80_ballCamera->SetClampVelRange(hint->GetHint().GetClampVelRange());
|
camToPlayerFlat.z() = 0.f;
|
||||||
x80_ballCamera->SetClampVelTimer(hint->GetHint().GetClampVelTime());
|
if (camToPlayerFlat.canBeNormalized()) {
|
||||||
} else {
|
camToPlayerFlat.normalize();
|
||||||
x80_ballCamera->TeleportCamera(x80_ballCamera->UpdateLookDirection(camToPlayerFlat, mgr), mgr);
|
} else {
|
||||||
InterpolateToBallCamera(ballCamXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
|
camToPlayerFlat = mgr.GetPlayer().GetMoveDir();
|
||||||
hint->GetHint().GetClampVelTime(), hint->GetHint().GetClampVelRange(),
|
}
|
||||||
hint->GetHint().GetClampRotRange(), (hint->GetHint().GetOverrideFlags() & 0x800) != 0,
|
|
||||||
mgr);
|
x80_ballCamera->ResetToTweaks(mgr);
|
||||||
}
|
x80_ballCamera->UpdateLookAtPosition(0.f, mgr);
|
||||||
|
if (!mgr.GetPlayer().IsMorphBallTransitioning() &&
|
||||||
|
hint->GetHint().GetBehaviourType() != CBallCamera::EBallCameraBehaviour::Default) {
|
||||||
|
if ((hint->GetHint().GetOverrideFlags() & 0x1000) != 0) {
|
||||||
|
x80_ballCamera->SetClampVelRange(hint->GetHint().GetClampVelRange());
|
||||||
|
x80_ballCamera->SetClampVelTimer(hint->GetHint().GetClampVelTime());
|
||||||
|
} else {
|
||||||
|
x80_ballCamera->TeleportCamera(x80_ballCamera->UpdateLookDirection(camToPlayerFlat, mgr), mgr);
|
||||||
|
InterpolateToBallCamera(ballCamXf, x80_ballCamera->GetUniqueId(), x80_ballCamera->GetLookPos(),
|
||||||
|
hint->GetHint().GetClampVelTime(), hint->GetHint().GetClampVelRange(),
|
||||||
|
hint->GetHint().GetClampRotRange(), (hint->GetHint().GetOverrideFlags() & 0x800) != 0,
|
||||||
|
mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,15 +241,16 @@ void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManage
|
||||||
mgr.GetPlayer().SetCameraState(CPlayer::EPlayerCameraState::Ball, mgr);
|
mgr.GetPlayer().SetCameraState(CPlayer::EPlayerCameraState::Ball, mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TCastToPtr<CScriptCameraHint> oldHint = mgr.ObjectById(xa6_camHintId);
|
const TCastToConstPtr<CScriptCameraHint> oldHint = mgr.ObjectById(xa6_camHintId);
|
||||||
xa6_camHintId = hint.GetUniqueId();
|
xa6_camHintId = hint.GetUniqueId();
|
||||||
xa8_hintPriority = hint.GetPriority();
|
xa8_hintPriority = hint.GetPriority();
|
||||||
|
|
||||||
zeus::CTransform camXf = GetCurrentCameraTransform(mgr);
|
const zeus::CTransform camXf = GetCurrentCameraTransform(mgr);
|
||||||
x80_ballCamera->ApplyCameraHint(mgr);
|
x80_ballCamera->ApplyCameraHint(mgr);
|
||||||
|
|
||||||
if ((hint.GetHint().GetOverrideFlags() & 0x20) != 0)
|
if ((hint.GetHint().GetOverrideFlags() & 0x20) != 0) {
|
||||||
x80_ballCamera->ResetPosition(mgr);
|
x80_ballCamera->ResetPosition(mgr);
|
||||||
|
}
|
||||||
|
|
||||||
switch (hint.GetHint().GetBehaviourType()) {
|
switch (hint.GetHint().GetBehaviourType()) {
|
||||||
case CBallCamera::EBallCameraBehaviour::PathCameraDesiredPos:
|
case CBallCamera::EBallCameraBehaviour::PathCameraDesiredPos:
|
||||||
|
@ -257,8 +266,9 @@ void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManage
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hint.GetHint().GetOverrideFlags() & 0x2000) != 0)
|
if ((hint.GetHint().GetOverrideFlags() & 0x2000) != 0) {
|
||||||
SkipBallCameraCinematic(mgr);
|
SkipBallCameraCinematic(mgr);
|
||||||
|
}
|
||||||
|
|
||||||
x80_ballCamera->UpdateLookAtPosition(0.f, mgr);
|
x80_ballCamera->UpdateLookAtPosition(0.f, mgr);
|
||||||
|
|
||||||
|
@ -274,7 +284,7 @@ void CCameraManager::ApplyCameraHint(const CScriptCameraHint& hint, CStateManage
|
||||||
void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
||||||
bool invalidHintRemoved = false;
|
bool invalidHintRemoved = false;
|
||||||
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end();) {
|
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end();) {
|
||||||
if (!TCastToPtr<CScriptCameraHint>(mgr.ObjectById(it->second))) {
|
if (!TCastToConstPtr<CScriptCameraHint>(mgr.ObjectById(it->second))) {
|
||||||
invalidHintRemoved = true;
|
invalidHintRemoved = true;
|
||||||
it = xac_cameraHints.erase(it);
|
it = xac_cameraHints.erase(it);
|
||||||
continue;
|
continue;
|
||||||
|
@ -283,8 +293,8 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inactiveHintRemoved = false;
|
bool inactiveHintRemoved = false;
|
||||||
for (TUniqueId id : x2b0_inactiveCameraHints) {
|
for (const TUniqueId id : x2b0_inactiveCameraHints) {
|
||||||
if (TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) {
|
||||||
if (hint->GetHelperCount() == 0 || hint->GetInactive()) {
|
if (hint->GetHelperCount() == 0 || hint->GetInactive()) {
|
||||||
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) {
|
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) {
|
||||||
if (it->second == id) {
|
if (it->second == id) {
|
||||||
|
@ -303,8 +313,8 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
||||||
x2b0_inactiveCameraHints.clear();
|
x2b0_inactiveCameraHints.clear();
|
||||||
|
|
||||||
bool activeHintAdded = false;
|
bool activeHintAdded = false;
|
||||||
for (TUniqueId id : x334_activeCameraHints) {
|
for (const TUniqueId id : x334_activeCameraHints) {
|
||||||
if (TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) {
|
||||||
bool activeHintPresent = false;
|
bool activeHintPresent = false;
|
||||||
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) {
|
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) {
|
||||||
if (it->second == id) {
|
if (it->second == id) {
|
||||||
|
@ -330,16 +340,17 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool foundHint = false;
|
bool foundHint = false;
|
||||||
CScriptCameraHint* bestHint = nullptr;
|
const CScriptCameraHint* bestHint = nullptr;
|
||||||
for (auto& h : xac_cameraHints) {
|
for (auto& h : xac_cameraHints) {
|
||||||
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(h.second)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.ObjectById(h.second)) {
|
||||||
bestHint = hint.GetPtr();
|
bestHint = hint.GetPtr();
|
||||||
foundHint = true;
|
foundHint = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundHint)
|
if (!foundHint) {
|
||||||
RestoreHintlessCamera(mgr);
|
RestoreHintlessCamera(mgr);
|
||||||
|
}
|
||||||
|
|
||||||
bool changeHint = false;
|
bool changeHint = false;
|
||||||
if (bestHint && foundHint) {
|
if (bestHint && foundHint) {
|
||||||
|
@ -347,33 +358,37 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
||||||
zeus::CVector3f ballPos = mgr.GetPlayer().GetBallPosition();
|
zeus::CVector3f ballPos = mgr.GetPlayer().GetBallPosition();
|
||||||
if ((bestHint->GetHint().GetOverrideFlags() & 0x100) != 0) {
|
if ((bestHint->GetHint().GetOverrideFlags() & 0x100) != 0) {
|
||||||
zeus::CVector3f camToBall = ballPos - ballCamXf.origin;
|
zeus::CVector3f camToBall = ballPos - ballCamXf.origin;
|
||||||
if (camToBall.canBeNormalized())
|
if (camToBall.canBeNormalized()) {
|
||||||
camToBall.normalize();
|
camToBall.normalize();
|
||||||
else
|
} else {
|
||||||
camToBall = ballCamXf.basis[1];
|
camToBall = ballCamXf.basis[1];
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = xac_cameraHints.begin() + 1; it != xac_cameraHints.end(); ++it) {
|
for (auto it = xac_cameraHints.begin() + 1; it != xac_cameraHints.end(); ++it) {
|
||||||
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(it->second)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.ObjectById(it->second)) {
|
||||||
if ((hint->GetHint().GetOverrideFlags() & 0x80) != 0 && hint->GetPriority() == bestHint->GetPriority() &&
|
if ((hint->GetHint().GetOverrideFlags() & 0x80) != 0 && hint->GetPriority() == bestHint->GetPriority() &&
|
||||||
hint->GetAreaIdAlways() == bestHint->GetAreaIdAlways()) {
|
hint->GetAreaIdAlways() == bestHint->GetAreaIdAlways()) {
|
||||||
zeus::CVector3f hintToBall = ballPos - bestHint->GetTranslation();
|
zeus::CVector3f hintToBall = ballPos - bestHint->GetTranslation();
|
||||||
if (hintToBall.canBeNormalized())
|
if (hintToBall.canBeNormalized()) {
|
||||||
hintToBall.normalize();
|
hintToBall.normalize();
|
||||||
else
|
} else {
|
||||||
hintToBall = bestHint->GetTransform().basis[1];
|
hintToBall = bestHint->GetTransform().basis[1];
|
||||||
|
}
|
||||||
|
|
||||||
float camHintDot = zeus::clamp(-1.f, camToBall.dot(hintToBall), 1.f);
|
const float camHintDot = zeus::clamp(-1.f, camToBall.dot(hintToBall), 1.f);
|
||||||
|
|
||||||
zeus::CVector3f thisHintToBall = ballPos - hint->GetTranslation();
|
zeus::CVector3f thisHintToBall = ballPos - hint->GetTranslation();
|
||||||
if (thisHintToBall.canBeNormalized())
|
if (thisHintToBall.canBeNormalized()) {
|
||||||
thisHintToBall.normalize();
|
thisHintToBall.normalize();
|
||||||
else
|
} else {
|
||||||
thisHintToBall = hint->GetTransform().basis[1];
|
thisHintToBall = hint->GetTransform().basis[1];
|
||||||
|
}
|
||||||
|
|
||||||
float camThisHintDot = zeus::clamp(-1.f, camToBall.dot(thisHintToBall), 1.f);
|
const float camThisHintDot = zeus::clamp(-1.f, camToBall.dot(thisHintToBall), 1.f);
|
||||||
|
|
||||||
if (camThisHintDot > camHintDot)
|
if (camThisHintDot > camHintDot) {
|
||||||
bestHint = hint.GetPtr();
|
bestHint = hint.GetPtr();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -382,44 +397,49 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(bestHint->GetFirstHelper())) {
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(bestHint->GetFirstHelper())) {
|
||||||
zeus::CVector3f ballPos = mgr.GetPlayer().GetBallPosition();
|
zeus::CVector3f ballPos = mgr.GetPlayer().GetBallPosition();
|
||||||
zeus::CVector3f f26 = act->GetTranslation() - ballPos;
|
zeus::CVector3f f26 = act->GetTranslation() - ballPos;
|
||||||
zeus::CVector3f ballToHelper = f26;
|
zeus::CVector3f ballToHelper = f26;
|
||||||
if (ballToHelper.canBeNormalized())
|
if (ballToHelper.canBeNormalized()) {
|
||||||
ballToHelper.normalize();
|
ballToHelper.normalize();
|
||||||
else
|
} else {
|
||||||
ballToHelper = bestHint->GetTransform().basis[1];
|
ballToHelper = bestHint->GetTransform().basis[1];
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = xac_cameraHints.begin() + 1; it != xac_cameraHints.end(); ++it) {
|
for (auto it = xac_cameraHints.begin() + 1; it != xac_cameraHints.end(); ++it) {
|
||||||
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(it->second)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.ObjectById(it->second)) {
|
||||||
if ((hint->GetHint().GetOverrideFlags() & 0x80) != 0 &&
|
if ((hint->GetHint().GetOverrideFlags() & 0x80) != 0 &&
|
||||||
hint->GetPriority() == bestHint->GetPriority() &&
|
hint->GetPriority() == bestHint->GetPriority() &&
|
||||||
hint->GetAreaIdAlways() == bestHint->GetAreaIdAlways()) {
|
hint->GetAreaIdAlways() == bestHint->GetAreaIdAlways()) {
|
||||||
zeus::CVector3f hintToHelper = act->GetTranslation() - bestHint->GetTranslation();
|
zeus::CVector3f hintToHelper = act->GetTranslation() - bestHint->GetTranslation();
|
||||||
if (hintToHelper.canBeNormalized())
|
if (hintToHelper.canBeNormalized()) {
|
||||||
hintToHelper.normalize();
|
hintToHelper.normalize();
|
||||||
else
|
} else {
|
||||||
hintToHelper = bestHint->GetTransform().basis[1];
|
hintToHelper = bestHint->GetTransform().basis[1];
|
||||||
|
}
|
||||||
|
|
||||||
float ballHintDot = zeus::clamp(-1.f, ballToHelper.dot(hintToHelper), 1.f);
|
const float ballHintDot = zeus::clamp(-1.f, ballToHelper.dot(hintToHelper), 1.f);
|
||||||
|
|
||||||
zeus::CVector3f thisBallToHelper = f26;
|
zeus::CVector3f thisBallToHelper = f26;
|
||||||
if (thisBallToHelper.canBeNormalized())
|
if (thisBallToHelper.canBeNormalized()) {
|
||||||
thisBallToHelper.normalize();
|
thisBallToHelper.normalize();
|
||||||
else
|
} else {
|
||||||
thisBallToHelper = hint->GetTransform().basis[1];
|
thisBallToHelper = hint->GetTransform().basis[1];
|
||||||
|
}
|
||||||
|
|
||||||
zeus::CVector3f thisHintToHelper = act->GetTranslation() - hint->GetTranslation();
|
zeus::CVector3f thisHintToHelper = act->GetTranslation() - hint->GetTranslation();
|
||||||
if (thisHintToHelper.canBeNormalized())
|
if (thisHintToHelper.canBeNormalized()) {
|
||||||
thisHintToHelper.normalize();
|
thisHintToHelper.normalize();
|
||||||
else
|
} else {
|
||||||
thisHintToHelper = hint->GetTransform().basis[1];
|
thisHintToHelper = hint->GetTransform().basis[1];
|
||||||
|
}
|
||||||
|
|
||||||
float thisBallHintDot = zeus::clamp(-1.f, thisBallToHelper.dot(thisHintToHelper), 1.f);
|
const float thisBallHintDot = zeus::clamp(-1.f, thisBallToHelper.dot(thisHintToHelper), 1.f);
|
||||||
|
|
||||||
if (thisBallHintDot > ballHintDot)
|
if (thisBallHintDot > ballHintDot) {
|
||||||
bestHint = hint.GetPtr();
|
bestHint = hint.GetPtr();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -430,24 +450,27 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bestHint->GetUniqueId() != xa6_camHintId)
|
if (bestHint->GetUniqueId() != xa6_camHintId) {
|
||||||
changeHint = true;
|
changeHint = true;
|
||||||
|
}
|
||||||
} else if (xa6_camHintId != bestHint->GetUniqueId()) {
|
} else if (xa6_camHintId != bestHint->GetUniqueId()) {
|
||||||
if (bestHint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::HintInitializePosition) {
|
if (bestHint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::HintInitializePosition) {
|
||||||
if ((bestHint->GetHint().GetOverrideFlags() & 0x20) != 0) {
|
if ((bestHint->GetHint().GetOverrideFlags() & 0x20) != 0) {
|
||||||
x80_ballCamera->TeleportCamera(zeus::lookAt(bestHint->GetTranslation(), x80_ballCamera->GetLookPos()), mgr);
|
x80_ballCamera->TeleportCamera(zeus::lookAt(bestHint->GetTranslation(), x80_ballCamera->GetLookPos()), mgr);
|
||||||
}
|
}
|
||||||
DeleteCameraHint(bestHint->GetUniqueId(), mgr);
|
DeleteCameraHint(bestHint->GetUniqueId(), mgr);
|
||||||
if ((bestHint->GetHint().GetOverrideFlags() & 0x2000) != 0)
|
if ((bestHint->GetHint().GetOverrideFlags() & 0x2000) != 0) {
|
||||||
SkipBallCameraCinematic(mgr);
|
SkipBallCameraCinematic(mgr);
|
||||||
|
}
|
||||||
changeHint = false;
|
changeHint = false;
|
||||||
} else {
|
} else {
|
||||||
changeHint = true;
|
changeHint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeHint)
|
if (changeHint) {
|
||||||
ApplyCameraHint(*bestHint, mgr);
|
ApplyCameraHint(*bestHint, mgr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,18 +479,20 @@ void CCameraManager::ThinkCameras(float dt, CStateManager& mgr) {
|
||||||
CGameCameraList gcList = mgr.GetCameraObjectList();
|
CGameCameraList gcList = mgr.GetCameraObjectList();
|
||||||
|
|
||||||
for (CEntity* ent : gcList) {
|
for (CEntity* ent : gcList) {
|
||||||
if (TCastToPtr<CGameCamera> gc = ent) {
|
if (const TCastToPtr<CGameCamera> gc = ent) {
|
||||||
gc->Think(dt, mgr);
|
gc->Think(dt, mgr);
|
||||||
gc->UpdatePerspective(dt);
|
gc->UpdatePerspective(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsInCinematicCamera())
|
if (IsInCinematicCamera()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TUniqueId camId = GetLastCameraId();
|
const TUniqueId camId = GetLastCameraId();
|
||||||
if (const CGameCamera* cam = TCastToConstPtr<CGameCamera>(mgr.GetObjectById(camId)))
|
if (const CGameCamera* cam = TCastToConstPtr<CGameCamera>(mgr.GetObjectById(camId))) {
|
||||||
x3bc_curFov = cam->GetFov();
|
x3bc_curFov = cam->GetFov();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::UpdateFog(float dt, CStateManager& mgr) {
|
void CCameraManager::UpdateFog(float dt, CStateManager& mgr) {
|
||||||
|
@ -481,14 +506,16 @@ void CCameraManager::UpdateFog(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x74_fluidCounter) {
|
if (x74_fluidCounter) {
|
||||||
if (TCastToConstPtr<CScriptWater> water = mgr.GetObjectById(x78_fluidId)) {
|
if (const TCastToConstPtr<CScriptWater> water = mgr.GetObjectById(x78_fluidId)) {
|
||||||
zeus::CVector2f zRange(GetCurrentCamera(mgr)->GetNearClipDistance(), CalculateFogDensity(mgr, water.GetPtr()));
|
const zeus::CVector2f zRange(GetCurrentCamera(mgr)->GetNearClipDistance(),
|
||||||
|
CalculateFogDensity(mgr, water.GetPtr()));
|
||||||
x3c_fog.SetFogExplicit(ERglFogMode::PerspExp, water->GetInsideFogColor(), zRange);
|
x3c_fog.SetFogExplicit(ERglFogMode::PerspExp, water->GetInsideFogColor(), zRange);
|
||||||
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal)
|
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal) {
|
||||||
mgr.GetCameraFilterPass(4).DisableFilter(0.f);
|
mgr.GetCameraFilterPass(4).DisableFilter(0.f);
|
||||||
else
|
} else {
|
||||||
mgr.GetCameraFilterPass(4).SetFilter(EFilterType::Multiply, EFilterShape::Fullscreen, 0.f,
|
mgr.GetCameraFilterPass(4).SetFilter(EFilterType::Multiply, EFilterShape::Fullscreen, 0.f,
|
||||||
water->GetInsideFogColor(), {});
|
water->GetInsideFogColor(), {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xa0_26_inWater = true;
|
xa0_26_inWater = true;
|
||||||
} else if (xa0_26_inWater) {
|
} else if (xa0_26_inWater) {
|
||||||
|
@ -525,8 +552,9 @@ void CCameraManager::UpdateRumble(float dt, CStateManager& mgr) {
|
||||||
xa0_25_rumbling = false;
|
xa0_25_rumbling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mgr.GetPlayer().GetCameraState() != CPlayer::EPlayerCameraState::FirstPerson && !IsInCinematicCamera())
|
if (mgr.GetPlayer().GetCameraState() != CPlayer::EPlayerCameraState::FirstPerson && !IsInCinematicCamera()) {
|
||||||
x30_shakeOffset = zeus::skZero3f;
|
x30_shakeOffset = zeus::skZero3f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::UpdateListener(CStateManager& mgr) {
|
void CCameraManager::UpdateListener(CStateManager& mgr) {
|
||||||
|
@ -535,13 +563,14 @@ void CCameraManager::UpdateListener(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float CCameraManager::CalculateFogDensity(CStateManager& mgr, const CScriptWater* water) const {
|
float CCameraManager::CalculateFogDensity(CStateManager& mgr, const CScriptWater* water) const {
|
||||||
float distanceFactor = 1.f - water->GetFluidPlane().GetAlpha();
|
const float distanceFactor = 1.f - water->GetFluidPlane().GetAlpha();
|
||||||
float distance = 0;
|
float distance = 0;
|
||||||
if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit))
|
if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit)) {
|
||||||
distance =
|
distance =
|
||||||
g_tweakGame->GetGravityWaterFogDistanceRange() * distanceFactor + g_tweakGame->GetGravityWaterFogDistanceBase();
|
g_tweakGame->GetGravityWaterFogDistanceRange() * distanceFactor + g_tweakGame->GetGravityWaterFogDistanceBase();
|
||||||
else
|
} else {
|
||||||
distance = g_tweakGame->GetWaterFogDistanceRange() * distanceFactor + g_tweakGame->GetWaterFogDistanceBase();
|
distance = g_tweakGame->GetWaterFogDistanceRange() * distanceFactor + g_tweakGame->GetWaterFogDistanceBase();
|
||||||
|
}
|
||||||
|
|
||||||
return distance * x94_fogDensityFactor;
|
return distance * x94_fogDensityFactor;
|
||||||
}
|
}
|
||||||
|
@ -551,7 +580,7 @@ void CCameraManager::ResetCameras(CStateManager& mgr) {
|
||||||
xf.origin = mgr.GetPlayer().GetEyePosition();
|
xf.origin = mgr.GetPlayer().GetEyePosition();
|
||||||
|
|
||||||
for (CEntity* ent : mgr.GetCameraObjectList()) {
|
for (CEntity* ent : mgr.GetCameraObjectList()) {
|
||||||
TCastToPtr<CGameCamera> camObj(ent);
|
const TCastToPtr<CGameCamera> camObj(ent);
|
||||||
camObj->Reset(xf, mgr);
|
camObj->Reset(xf, mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,11 +592,13 @@ void CCameraManager::SetSpecialCameras(CFirstPersonCamera& fp, CBallCamera& ball
|
||||||
|
|
||||||
void CCameraManager::ProcessInput(const CFinalInput& input, CStateManager& stateMgr) {
|
void CCameraManager::ProcessInput(const CFinalInput& input, CStateManager& stateMgr) {
|
||||||
for (CEntity* ent : stateMgr.GetCameraObjectList()) {
|
for (CEntity* ent : stateMgr.GetCameraObjectList()) {
|
||||||
if (ent == nullptr)
|
if (ent == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
auto& cam = static_cast<CGameCamera&>(*ent);
|
auto& cam = static_cast<CGameCamera&>(*ent);
|
||||||
if (input.ControllerIdx() != cam.x16c_controllerIdx)
|
if (input.ControllerIdx() != cam.x16c_controllerIdx) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
cam.ProcessInput(input, stateMgr);
|
cam.ProcessInput(input, stateMgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,10 +609,11 @@ void CCameraManager::RenderCameras(const CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::SetupBallCamera(CStateManager& mgr) {
|
void CCameraManager::SetupBallCamera(CStateManager& mgr) {
|
||||||
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.ObjectById(xa6_camHintId)) {
|
||||||
if (hint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::HintInitializePosition) {
|
if (hint->GetHint().GetBehaviourType() == CBallCamera::EBallCameraBehaviour::HintInitializePosition) {
|
||||||
if ((hint->GetHint().GetOverrideFlags() & 0x20) != 0)
|
if ((hint->GetHint().GetOverrideFlags() & 0x20) != 0) {
|
||||||
x80_ballCamera->TeleportCamera(hint->GetTransform(), mgr);
|
x80_ballCamera->TeleportCamera(hint->GetTransform(), mgr);
|
||||||
|
}
|
||||||
AddInactiveCameraHint(xa6_camHintId, mgr);
|
AddInactiveCameraHint(xa6_camHintId, mgr);
|
||||||
} else {
|
} else {
|
||||||
ApplyCameraHint(*hint, mgr);
|
ApplyCameraHint(*hint, mgr);
|
||||||
|
@ -623,45 +655,60 @@ bool CCameraManager::HasBallCameraInitialPositionHint(CStateManager& mgr) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::RemoveCinemaCamera(TUniqueId uid, CStateManager& mgr) {
|
void CCameraManager::RemoveCinemaCamera(TUniqueId uid, CStateManager& mgr) {
|
||||||
auto search = std::find(x4_cineCameras.begin(), x4_cineCameras.end(), uid);
|
const auto search = std::find(x4_cineCameras.begin(), x4_cineCameras.end(), uid);
|
||||||
if (search != x4_cineCameras.end())
|
|
||||||
x4_cineCameras.erase(search);
|
if (search == x4_cineCameras.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x4_cineCameras.erase(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::DeleteCameraHint(TUniqueId id, CStateManager& mgr) {
|
void CCameraManager::DeleteCameraHint(TUniqueId id, CStateManager& mgr) {
|
||||||
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(id)) {
|
const TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(id);
|
||||||
auto search = std::find_if(x2b0_inactiveCameraHints.begin(), x2b0_inactiveCameraHints.end(),
|
|
||||||
[id](TUniqueId tid) { return tid == id; });
|
if (!hint) {
|
||||||
if (search == x2b0_inactiveCameraHints.end()) {
|
return;
|
||||||
hint->ClearIdList();
|
}
|
||||||
hint->SetInactive(true);
|
|
||||||
if (x2b0_inactiveCameraHints.size() != 64)
|
const auto search = std::find_if(x2b0_inactiveCameraHints.begin(), x2b0_inactiveCameraHints.end(),
|
||||||
x2b0_inactiveCameraHints.push_back(id);
|
[id](TUniqueId tid) { return tid == id; });
|
||||||
}
|
|
||||||
|
if (search != x2b0_inactiveCameraHints.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hint->ClearIdList();
|
||||||
|
hint->SetInactive(true);
|
||||||
|
if (x2b0_inactiveCameraHints.size() != 64) {
|
||||||
|
x2b0_inactiveCameraHints.push_back(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::AddInactiveCameraHint(TUniqueId id, CStateManager& mgr) {
|
void CCameraManager::AddInactiveCameraHint(TUniqueId id, CStateManager& mgr) {
|
||||||
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(id)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.ObjectById(id)) {
|
||||||
auto search = std::find_if(x2b0_inactiveCameraHints.begin(), x2b0_inactiveCameraHints.end(),
|
const auto search = std::find_if(x2b0_inactiveCameraHints.begin(), x2b0_inactiveCameraHints.end(),
|
||||||
[id](TUniqueId tid) { return tid == id; });
|
[id](TUniqueId tid) { return tid == id; });
|
||||||
if (search == x2b0_inactiveCameraHints.end() && x2b0_inactiveCameraHints.size() != 64)
|
if (search == x2b0_inactiveCameraHints.end() && x2b0_inactiveCameraHints.size() != 64) {
|
||||||
x2b0_inactiveCameraHints.push_back(id);
|
x2b0_inactiveCameraHints.push_back(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCameraManager::AddActiveCameraHint(TUniqueId id, CStateManager& mgr) {
|
void CCameraManager::AddActiveCameraHint(TUniqueId id, CStateManager& mgr) {
|
||||||
if (TCastToPtr<CScriptCameraHint> hint = mgr.ObjectById(id)) {
|
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.ObjectById(id)) {
|
||||||
auto search = std::find_if(x334_activeCameraHints.begin(), x334_activeCameraHints.end(),
|
const auto search = std::find_if(x334_activeCameraHints.begin(), x334_activeCameraHints.end(),
|
||||||
[id](TUniqueId tid) { return tid == id; });
|
[id](TUniqueId tid) { return tid == id; });
|
||||||
if (search == x334_activeCameraHints.end() && xac_cameraHints.size() != 64 && x334_activeCameraHints.size() != 64)
|
if (search == x334_activeCameraHints.end() && xac_cameraHints.size() != 64 && x334_activeCameraHints.size() != 64) {
|
||||||
x334_activeCameraHints.push_back(id);
|
x334_activeCameraHints.push_back(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TUniqueId CCameraManager::GetLastCineCameraId() const {
|
TUniqueId CCameraManager::GetLastCineCameraId() const {
|
||||||
if (x4_cineCameras.empty())
|
if (x4_cineCameras.empty()) {
|
||||||
return kInvalidUniqueId;
|
return kInvalidUniqueId;
|
||||||
|
}
|
||||||
return x4_cineCameras.back();
|
return x4_cineCameras.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue