CCinematicCamera: Make use of const where applicable

Makes read-only intent explicit.
This commit is contained in:
Lioncash 2020-04-05 01:36:10 -04:00
parent 4e55edf0fe
commit 1b01b232e6
1 changed files with 134 additions and 88 deletions

View File

@ -14,7 +14,7 @@ namespace urde {
CCinematicCamera::CCinematicCamera(TUniqueId uid, std::string_view name, const CEntityInfo& info, CCinematicCamera::CCinematicCamera(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, bool active, float shotDuration, float fovy, float znear, const zeus::CTransform& xf, bool active, float shotDuration, float fovy, float znear,
float zfar, float aspect, u32 flags) float zfar, float aspect, u32 flags)
: CGameCamera(uid, active, name, info, xf, fovy, znear, zfar, aspect, kInvalidUniqueId, flags & 0x20, 0) : CGameCamera(uid, active, name, info, xf, fovy, znear, zfar, aspect, kInvalidUniqueId, (flags & 0x20) != 0, 0)
, x1e8_duration(shotDuration) , x1e8_duration(shotDuration)
, x1f0_origFovy(fovy) , x1f0_origFovy(fovy)
, x1fc_origOrientation(zeus::CQuaternion(xf.basis)) , x1fc_origOrientation(zeus::CQuaternion(xf.basis))
@ -35,8 +35,9 @@ void CCinematicCamera::Reset(const zeus::CTransform&, CStateManager& mgr) {
void CCinematicCamera::WasDeactivated(CStateManager& mgr) { void CCinematicCamera::WasDeactivated(CStateManager& mgr) {
mgr.GetCameraManager()->RemoveCinemaCamera(GetUniqueId(), mgr); mgr.GetCameraManager()->RemoveCinemaCamera(GetUniqueId(), mgr);
mgr.GetPlayer().GetMorphBall()->LoadMorphBallModel(mgr); mgr.GetPlayer().GetMorphBall()->LoadMorphBallModel(mgr);
if (x21c_flags & 0x100) if ((x21c_flags & 0x100) != 0) {
mgr.SetCinematicPause(false); mgr.SetCinematicPause(false);
}
x188_viewPoints.clear(); x188_viewPoints.clear();
x198_viewOrientations.clear(); x198_viewOrientations.clear();
x1a8_viewPointArrivals.clear(); x1a8_viewPointArrivals.clear();
@ -48,25 +49,28 @@ void CCinematicCamera::WasDeactivated(CStateManager& mgr) {
zeus::CVector3f CCinematicCamera::GetInterpolatedSplinePoint(const std::vector<zeus::CVector3f>& points, int& idxOut, zeus::CVector3f CCinematicCamera::GetInterpolatedSplinePoint(const std::vector<zeus::CVector3f>& points, int& idxOut,
float tin) const { float tin) const {
if (points.size() > 0) { if (points.size() > 0) {
float cycleT = std::fmod(tin, x1e8_duration); const float cycleT = std::fmod(tin, x1e8_duration);
float durPerPoint = x1e8_duration / float(points.size() - 1); const float durPerPoint = x1e8_duration / float(points.size() - 1);
idxOut = int(cycleT / durPerPoint); idxOut = int(cycleT / durPerPoint);
float t = (cycleT - idxOut * durPerPoint) / durPerPoint; const float t = (cycleT - float(idxOut) * durPerPoint) / durPerPoint;
if (points.size() == 1) if (points.size() == 1) {
return points.front(); return points.front();
else if (points.size() == 2) }
if (points.size() == 2) {
return (points[1] - points[0]) * t + points[0]; return (points[1] - points[0]) * t + points[0];
}
zeus::CVector3f ptA; zeus::CVector3f ptA;
if (idxOut > 0) if (idxOut > 0) {
ptA = points[idxOut - 1]; ptA = points[idxOut - 1];
else } else {
ptA = points[0] - (points[1] - points[0]); ptA = points[0] - (points[1] - points[0]);
}
zeus::CVector3f ptB = points[idxOut]; const zeus::CVector3f ptB = points[idxOut];
zeus::CVector3f ptC; zeus::CVector3f ptC;
if (idxOut + 1 >= points.size()) { if (size_t(idxOut + 1) >= points.size()) {
const zeus::CVector3f& tmpA = points[points.size() - 1]; const zeus::CVector3f& tmpA = points[points.size() - 1];
const zeus::CVector3f& tmpB = points[points.size() - 2]; const zeus::CVector3f& tmpB = points[points.size() - 2];
ptC = tmpA - (tmpB - tmpA); ptC = tmpA - (tmpB - tmpA);
@ -75,7 +79,7 @@ zeus::CVector3f CCinematicCamera::GetInterpolatedSplinePoint(const std::vector<z
} }
zeus::CVector3f ptD; zeus::CVector3f ptD;
if (idxOut + 2 >= points.size()) { if (size_t(idxOut + 2) >= points.size()) {
const zeus::CVector3f& tmpA = points[points.size() - 1]; const zeus::CVector3f& tmpA = points[points.size() - 1];
const zeus::CVector3f& tmpB = points[points.size() - 2]; const zeus::CVector3f& tmpB = points[points.size() - 2];
ptD = tmpA - (tmpB - tmpA); ptD = tmpA - (tmpB - tmpA);
@ -91,39 +95,50 @@ zeus::CVector3f CCinematicCamera::GetInterpolatedSplinePoint(const std::vector<z
zeus::CQuaternion CCinematicCamera::GetInterpolatedOrientation(const std::vector<zeus::CQuaternion>& rotations, zeus::CQuaternion CCinematicCamera::GetInterpolatedOrientation(const std::vector<zeus::CQuaternion>& rotations,
float tin) const { float tin) const {
if (rotations.size() == 0) if (rotations.empty()) {
return x1fc_origOrientation; return x1fc_origOrientation;
else if (rotations.size() == 1) }
return rotations.front();
float cycleT = std::fmod(tin, x1e8_duration); if (rotations.size() == 1) {
float durPerPoint = x1e8_duration / float(rotations.size() - 1); return rotations.front();
int idx = int(cycleT / durPerPoint); }
float t = (cycleT - idx * durPerPoint) / durPerPoint;
const float cycleT = std::fmod(tin, x1e8_duration);
const float durPerPoint = x1e8_duration / float(rotations.size() - 1);
const int idx = int(cycleT / durPerPoint);
const float t = (cycleT - float(idx) * durPerPoint) / durPerPoint;
return zeus::CQuaternion::slerp(rotations[idx], rotations[idx + 1], t); return zeus::CQuaternion::slerp(rotations[idx], rotations[idx + 1], t);
} }
float CCinematicCamera::GetInterpolatedHFov(const std::vector<float>& fovs, float tin) const { float CCinematicCamera::GetInterpolatedHFov(const std::vector<float>& fovs, float tin) const {
if (fovs.size() == 0) if (fovs.empty()) {
return x1f0_origFovy; return x1f0_origFovy;
else if (fovs.size() == 1) }
return fovs.front();
float cycleT = std::fmod(tin, x1e8_duration); if (fovs.size() == 1) {
float durPerPoint = x1e8_duration / float(fovs.size() - 1); return fovs.front();
int idx = int(cycleT / durPerPoint); }
float t = (cycleT - idx * durPerPoint) / durPerPoint;
const float cycleT = std::fmod(tin, x1e8_duration);
const float durPerPoint = x1e8_duration / float(fovs.size() - 1);
const int idx = int(cycleT / durPerPoint);
const float t = (cycleT - float(idx) * durPerPoint) / durPerPoint;
return (fovs[idx + 1] - fovs[idx]) * t + fovs[idx]; return (fovs[idx + 1] - fovs[idx]) * t + fovs[idx];
} }
float CCinematicCamera::GetMoveOutofIntoAlpha() const { float CCinematicCamera::GetMoveOutofIntoAlpha() const {
float startDist = 0.25f + x160_znear; const float startDist = 0.25f + x160_znear;
float endDist = 1.f * startDist; const float endDist = 1.f * startDist;
float deltaMag = (GetTranslation() - x210_moveIntoEyePos).magnitude(); const float deltaMag = (GetTranslation() - x210_moveIntoEyePos).magnitude();
if (deltaMag >= startDist && deltaMag <= endDist)
if (deltaMag >= startDist && deltaMag <= endDist) {
return (deltaMag - startDist) / (endDist - startDist); return (deltaMag - startDist) / (endDist - startDist);
if (deltaMag > endDist) }
if (deltaMag > endDist) {
return 1.f; return 1.f;
}
return 0.f; return 0.f;
} }
@ -136,7 +151,7 @@ void CCinematicCamera::DeactivateSelf(CStateManager& mgr) {
void CCinematicCamera::Think(float dt, CStateManager& mgr) { void CCinematicCamera::Think(float dt, CStateManager& mgr) {
if (GetActive()) { if (GetActive()) {
zeus::CVector3f viewPoint = GetTranslation(); zeus::CVector3f viewPoint = GetTranslation();
if (x188_viewPoints.size() > 0) { if (!x188_viewPoints.empty()) {
int idx = 0; int idx = 0;
viewPoint = GetInterpolatedSplinePoint(x188_viewPoints, idx, x1ec_t); viewPoint = GetInterpolatedSplinePoint(x188_viewPoints, idx, x1ec_t);
if (idx > x1f4_passedViewPoint) { if (idx > x1f4_passedViewPoint) {
@ -145,58 +160,67 @@ void CCinematicCamera::Think(float dt, CStateManager& mgr) {
} }
} }
zeus::CQuaternion orientation = GetInterpolatedOrientation(x198_viewOrientations, x1ec_t); const zeus::CQuaternion orientation = GetInterpolatedOrientation(x198_viewOrientations, x1ec_t);
if ((x21c_flags & 0x1) == 0) { if ((x21c_flags & 0x1) == 0) {
if (x1b8_targets.size() > 0) { if (!x1b8_targets.empty()) {
int idx = 0; int idx = 0;
zeus::CVector3f target = GetInterpolatedSplinePoint(x1b8_targets, idx, x1ec_t); zeus::CVector3f target = GetInterpolatedSplinePoint(x1b8_targets, idx, x1ec_t);
if (x1b8_targets.size() == 1) { if (x1b8_targets.size() == 1) {
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(x1c8_targetArrivals.front())) if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(x1c8_targetArrivals.front())) {
target = act->GetTranslation(); target = act->GetTranslation();
else } else {
x1ec_t = x1e8_duration; x1ec_t = x1e8_duration;
} }
}
if (idx > x1f8_passedTarget) { if (idx > x1f8_passedTarget) {
x1f8_passedTarget = idx; x1f8_passedTarget = idx;
SendArrivedMsg(x1c8_targetArrivals[x1f8_passedTarget], mgr); SendArrivedMsg(x1c8_targetArrivals[x1f8_passedTarget], mgr);
} }
zeus::CVector3f upVec = orientation.transform(zeus::skUp); const zeus::CVector3f upVec = orientation.transform(zeus::skUp);
if ((target - viewPoint).toVec2f().magnitude() < 0.0011920929f) if ((target - viewPoint).toVec2f().magnitude() < 0.0011920929f) {
SetTranslation(target); SetTranslation(target);
else } else {
SetTransform(zeus::lookAt(viewPoint, target, upVec)); SetTransform(zeus::lookAt(viewPoint, target, upVec));
}
} else { } else {
SetTransform(zeus::CTransform(orientation, viewPoint)); SetTransform(zeus::CTransform(orientation, viewPoint));
} }
} else { } else {
zeus::CVector3f target = mgr.GetPlayer().GetTranslation(); zeus::CVector3f target = mgr.GetPlayer().GetTranslation();
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed) if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed) {
target.z() += mgr.GetPlayer().GetMorphBall()->GetBallRadius(); target.z() += mgr.GetPlayer().GetMorphBall()->GetBallRadius();
else } else {
target.z() += mgr.GetPlayer().GetEyeHeight(); target.z() += mgr.GetPlayer().GetEyeHeight();
}
zeus::CVector3f upVec = orientation.transform(zeus::skUp); const zeus::CVector3f upVec = orientation.transform(zeus::skUp);
if ((target - viewPoint).toVec2f().magnitude() < 0.0011920929f) if ((target - viewPoint).toVec2f().magnitude() < 0.0011920929f) {
SetTranslation(target); SetTranslation(target);
else } else {
SetTransform(zeus::lookAt(viewPoint, target, upVec)); SetTransform(zeus::lookAt(viewPoint, target, upVec));
} }
}
x15c_currentFov = GetInterpolatedHFov(x1d8_viewHFovs, x1ec_t) / x168_aspect; x15c_currentFov = GetInterpolatedHFov(x1d8_viewHFovs, x1ec_t) / x168_aspect;
x170_24_perspDirty = true; x170_24_perspDirty = true;
if (x20c_lookAtId != kInvalidUniqueId) if (x20c_lookAtId != kInvalidUniqueId) {
if (TCastToPtr<CScriptActor> act = mgr.ObjectById(x20c_lookAtId)) if (const TCastToPtr<CScriptActor> act = mgr.ObjectById(x20c_lookAtId)) {
if (act->IsPlayerActor()) if (act->IsPlayerActor()) {
act->SetDrawFlags({5, 0, 3, zeus::CColor(1.f, GetMoveOutofIntoAlpha())}); act->SetDrawFlags({5, 0, 3, zeus::CColor(1.f, GetMoveOutofIntoAlpha())});
}
}
}
x1ec_t += dt; x1ec_t += dt;
if (x1ec_t > x1e8_duration) { if (x1ec_t > x1e8_duration) {
for (size_t i = x1f4_passedViewPoint + 1; i < x1a8_viewPointArrivals.size(); ++i) for (size_t i = x1f4_passedViewPoint + 1; i < x1a8_viewPointArrivals.size(); ++i) {
SendArrivedMsg(x1a8_viewPointArrivals[i], mgr); SendArrivedMsg(x1a8_viewPointArrivals[i], mgr);
for (size_t i = x1f8_passedTarget + 1; i < x1c8_targetArrivals.size(); ++i) }
for (size_t i = x1f8_passedTarget + 1; i < x1c8_targetArrivals.size(); ++i) {
SendArrivedMsg(x1c8_targetArrivals[i], mgr); SendArrivedMsg(x1c8_targetArrivals[i], mgr);
}
DeactivateSelf(mgr); DeactivateSelf(mgr);
} }
} }
@ -206,34 +230,39 @@ void CCinematicCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid,
CGameCamera::AcceptScriptMsg(msg, uid, mgr); CGameCamera::AcceptScriptMsg(msg, uid, mgr);
switch (msg) { switch (msg) {
case EScriptObjectMessage::InitializedInArea: case EScriptObjectMessage::InitializedInArea:
if (x21c_flags & 0x4 || x21c_flags & 0x2) { if ((x21c_flags & 0x4) != 0 || (x21c_flags & 0x2) != 0) {
for (const SConnection& conn : x20_conns) { for (const SConnection& conn : x20_conns) {
TUniqueId id = mgr.GetIdForScript(conn.x8_objId); const TUniqueId id = mgr.GetIdForScript(conn.x8_objId);
if (TCastToPtr<CScriptActor> act = mgr.ObjectById(id)) { if (const TCastToConstPtr<CScriptActor> act = mgr.ObjectById(id)) {
if (act->IsPlayerActor()) { if (act->IsPlayerActor()) {
x20c_lookAtId = id; x20c_lookAtId = id;
if (conn.x4_msg != EScriptObjectMessage::Deactivate && conn.x4_msg != EScriptObjectMessage::Reset) if (conn.x4_msg != EScriptObjectMessage::Deactivate && conn.x4_msg != EScriptObjectMessage::Reset) {
break; break;
} }
} }
} }
} }
}
break; break;
case EScriptObjectMessage::Activate: case EScriptObjectMessage::Activate:
CalculateWaypoints(mgr); CalculateWaypoints(mgr);
if ((x21c_flags & 1) == 0 && x220_24_ && x1b8_targets.empty()) if ((x21c_flags & 1) == 0 && x220_24_ && x1b8_targets.empty()) {
break; break;
}
x1ec_t = 0.f; x1ec_t = 0.f;
Think(0.f, mgr); Think(0.f, mgr);
mgr.GetCameraManager()->AddCinemaCamera(GetUniqueId(), mgr); mgr.GetCameraManager()->AddCinemaCamera(GetUniqueId(), mgr);
x1f4_passedViewPoint = 0; x1f4_passedViewPoint = 0;
if (x1a8_viewPointArrivals.size() > 0) if (!x1a8_viewPointArrivals.empty()) {
SendArrivedMsg(x1a8_viewPointArrivals[x1f4_passedViewPoint], mgr); SendArrivedMsg(x1a8_viewPointArrivals[x1f4_passedViewPoint], mgr);
}
x1f8_passedTarget = 0; x1f8_passedTarget = 0;
if (x1c8_targetArrivals.size() > 0) if (!x1c8_targetArrivals.empty()) {
SendArrivedMsg(x1c8_targetArrivals[x1f8_passedTarget], mgr); SendArrivedMsg(x1c8_targetArrivals[x1f8_passedTarget], mgr);
if (x21c_flags & 0x100) }
if ((x21c_flags & 0x100) != 0) {
mgr.SetCinematicPause(true); mgr.SetCinematicPause(true);
}
break; break;
case EScriptObjectMessage::Deactivate: case EScriptObjectMessage::Deactivate:
WasDeactivated(mgr); WasDeactivated(mgr);
@ -247,7 +276,7 @@ void CCinematicCamera::CalculateMoveOutofIntoEyePosition(bool outOfEye, CStateMa
zeus::CQuaternion q(mgr.GetPlayer().GetTransform().basis); zeus::CQuaternion q(mgr.GetPlayer().GetTransform().basis);
zeus::CVector3f eyePos = mgr.GetPlayer().GetEyePosition(); zeus::CVector3f eyePos = mgr.GetPlayer().GetEyePosition();
if (x20c_lookAtId != kInvalidUniqueId) { if (x20c_lookAtId != kInvalidUniqueId) {
if (TCastToConstPtr<CScriptActor> act = mgr.GetObjectById(x20c_lookAtId)) { if (const TCastToConstPtr<CScriptActor> act = mgr.GetObjectById(x20c_lookAtId)) {
if (act->IsPlayerActor()) { if (act->IsPlayerActor()) {
if (const CModelData* mData = act->GetModelData()) { if (const CModelData* mData = act->GetModelData()) {
if (const CAnimData* aData = mData->GetAnimationData()) { if (const CAnimData* aData = mData->GetAnimationData()) {
@ -255,8 +284,9 @@ void CCinematicCamera::CalculateMoveOutofIntoEyePosition(bool outOfEye, CStateMa
const CSegId lEye = aData->GetLocatorSegId("L_eye"sv); const CSegId lEye = aData->GetLocatorSegId("L_eye"sv);
const CSegId rEye = aData->GetLocatorSegId("R_eye"sv); const CSegId rEye = aData->GetLocatorSegId("R_eye"sv);
if (lEye.IsValid() && rEye.IsValid()) { if (lEye.IsValid() && rEye.IsValid()) {
CCharAnimTime time = outOfEye ? CCharAnimTime(0.f) : root->VGetSteadyStateAnimInfo().GetDuration(); const CCharAnimTime time =
CCharAnimTime* pTime = outOfEye ? nullptr : &time; outOfEye ? CCharAnimTime(0.f) : root->VGetSteadyStateAnimInfo().GetDuration();
const CCharAnimTime* pTime = outOfEye ? nullptr : &time;
eyePos = ((act->GetTransform() * mData->GetScaledLocatorTransformDynamic("L_eye"sv, pTime)).origin + eyePos = ((act->GetTransform() * mData->GetScaledLocatorTransformDynamic("L_eye"sv, pTime)).origin +
(act->GetTransform() * mData->GetScaledLocatorTransformDynamic("R_eye"sv, pTime)).origin) * (act->GetTransform() * mData->GetScaledLocatorTransformDynamic("R_eye"sv, pTime)).origin) *
0.5f; 0.5f;
@ -287,8 +317,8 @@ void CCinematicCamera::CalculateMoveOutofIntoEyePosition(bool outOfEye, CStateMa
} }
void CCinematicCamera::GenerateMoveOutofIntoPoints(bool outOfEye, CStateManager& mgr) { void CCinematicCamera::GenerateMoveOutofIntoPoints(bool outOfEye, CStateManager& mgr) {
zeus::CQuaternion q(mgr.GetPlayer().GetTransform().basis); const zeus::CQuaternion q(mgr.GetPlayer().GetTransform().basis);
zeus::CVector3f eyePos = mgr.GetPlayer().GetEyePosition(); const zeus::CVector3f eyePos = mgr.GetPlayer().GetEyePosition();
zeus::CVector3f behindDelta = q.transform({0.f, -g_tweakPlayerRes->xf0_cinematicMoveOutofIntoPlayerDistance, 0.f}); zeus::CVector3f behindDelta = q.transform({0.f, -g_tweakPlayerRes->xf0_cinematicMoveOutofIntoPlayerDistance, 0.f});
zeus::CVector3f behindPos = eyePos; zeus::CVector3f behindPos = eyePos;
if (!outOfEye) { if (!outOfEye) {
@ -309,20 +339,25 @@ void CCinematicCamera::GenerateMoveOutofIntoPoints(bool outOfEye, CStateManager&
bool CCinematicCamera::PickRandomActiveConnection(const std::vector<SConnection>& conns, SConnection& randConn, bool CCinematicCamera::PickRandomActiveConnection(const std::vector<SConnection>& conns, SConnection& randConn,
CStateManager& mgr) { CStateManager& mgr) {
int count = 0; int count = 0;
for (const SConnection& conn : conns) for (const SConnection& conn : conns) {
if (conn.x0_state == EScriptObjectState::Arrived && conn.x4_msg == EScriptObjectMessage::Next) if (conn.x0_state == EScriptObjectState::Arrived && conn.x4_msg == EScriptObjectMessage::Next) {
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))) if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))) {
if (act->GetActive()) if (act->GetActive()) {
++count; ++count;
}
}
}
}
if (!count) if (count == 0) {
return false; return false;
}
int randIdx = mgr.GetActiveRandom()->Next() % count; const int randIdx = mgr.GetActiveRandom()->Next() % count;
int idx = 0; int idx = 0;
for (const SConnection& conn : conns) for (const SConnection& conn : conns) {
if (conn.x0_state == EScriptObjectState::Arrived && conn.x4_msg == EScriptObjectMessage::Next) if (conn.x0_state == EScriptObjectState::Arrived && conn.x4_msg == EScriptObjectMessage::Next) {
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))) if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId))) {
if (act->GetActive()) { if (act->GetActive()) {
if (randIdx == idx) { if (randIdx == idx) {
randConn = conn; randConn = conn;
@ -330,6 +365,9 @@ bool CCinematicCamera::PickRandomActiveConnection(const std::vector<SConnection>
} }
++idx; ++idx;
} }
}
}
}
return true; return true;
} }
@ -338,11 +376,12 @@ void CCinematicCamera::CalculateWaypoints(CStateManager& mgr) {
const SConnection* firstVP = nullptr; const SConnection* firstVP = nullptr;
const SConnection* firstTarget = nullptr; const SConnection* firstTarget = nullptr;
for (const SConnection& conn : x20_conns) { for (const SConnection& conn : x20_conns) {
if (conn.x0_state == EScriptObjectState::CameraPath && conn.x4_msg == EScriptObjectMessage::Activate) if (conn.x0_state == EScriptObjectState::CameraPath && conn.x4_msg == EScriptObjectMessage::Activate) {
firstVP = &conn; firstVP = &conn;
else if (conn.x0_state == EScriptObjectState::CameraTarget && conn.x4_msg == EScriptObjectMessage::Activate) } else if (conn.x0_state == EScriptObjectState::CameraTarget && conn.x4_msg == EScriptObjectMessage::Activate) {
firstTarget = &conn; firstTarget = &conn;
} }
}
x188_viewPoints.clear(); x188_viewPoints.clear();
x188_viewPoints.reserve(3); x188_viewPoints.reserve(3);
@ -359,50 +398,57 @@ void CCinematicCamera::CalculateWaypoints(CStateManager& mgr) {
x220_24_ = false; x220_24_ = false;
if ((x21c_flags & 0x2) != 0 && (x21c_flags & 0x200) == 0) if ((x21c_flags & 0x2) != 0 && (x21c_flags & 0x200) == 0) {
GenerateMoveOutofIntoPoints(true, mgr); GenerateMoveOutofIntoPoints(true, mgr);
}
if (firstVP) { if (firstVP) {
TCastToConstPtr<CActor> wp = mgr.GetObjectById(mgr.GetIdForScript(firstVP->x8_objId)); TCastToConstPtr<CActor> wp = mgr.GetObjectById(mgr.GetIdForScript(firstVP->x8_objId));
while (wp) { while (wp) {
x188_viewPoints.push_back(wp->GetTranslation()); x188_viewPoints.push_back(wp->GetTranslation());
x198_viewOrientations.emplace_back(wp->GetTransform().basis); x198_viewOrientations.emplace_back(wp->GetTransform().basis);
if (TCastToConstPtr<CScriptCameraWaypoint> cwp = wp.GetPtr()) if (const TCastToConstPtr<CScriptCameraWaypoint> cwp = wp.GetPtr()) {
x1d8_viewHFovs.push_back(cwp->GetHFov()); x1d8_viewHFovs.push_back(cwp->GetHFov());
auto search = std::find_if(x1a8_viewPointArrivals.begin(), x1a8_viewPointArrivals.end(), }
[&](TUniqueId id) { return id == wp->GetUniqueId(); }); const auto search = std::find_if(x1a8_viewPointArrivals.cbegin(), x1a8_viewPointArrivals.cend(),
if (search == x1a8_viewPointArrivals.end()) { [&wp](TUniqueId id) { return id == wp->GetUniqueId(); });
if (search == x1a8_viewPointArrivals.cend()) {
x1a8_viewPointArrivals.push_back(wp->GetUniqueId()); x1a8_viewPointArrivals.push_back(wp->GetUniqueId());
SConnection randConn; SConnection randConn;
if (PickRandomActiveConnection(wp->GetConnectionList(), randConn, mgr)) if (PickRandomActiveConnection(wp->GetConnectionList(), randConn, mgr)) {
wp = mgr.GetObjectById(mgr.GetIdForScript(randConn.x8_objId)); wp = mgr.GetObjectById(mgr.GetIdForScript(randConn.x8_objId));
else } else {
break; break;
} else }
} else {
break; break;
} }
} }
}
if (firstTarget) { if (firstTarget) {
TCastToConstPtr<CActor> tgt = mgr.GetObjectById(mgr.GetIdForScript(firstTarget->x8_objId)); TCastToConstPtr<CActor> tgt = mgr.GetObjectById(mgr.GetIdForScript(firstTarget->x8_objId));
while (tgt) { while (tgt) {
x1b8_targets.push_back(tgt->GetTranslation()); x1b8_targets.push_back(tgt->GetTranslation());
auto search = std::find_if(x1c8_targetArrivals.begin(), x1c8_targetArrivals.end(), const auto search = std::find_if(x1c8_targetArrivals.cbegin(), x1c8_targetArrivals.cend(),
[&](TUniqueId id) { return id == tgt->GetUniqueId(); }); [&tgt](TUniqueId id) { return id == tgt->GetUniqueId(); });
if (search == x1c8_targetArrivals.end()) { if (search == x1c8_targetArrivals.cend()) {
x1c8_targetArrivals.push_back(tgt->GetUniqueId()); x1c8_targetArrivals.push_back(tgt->GetUniqueId());
SConnection randConn; SConnection randConn;
if (PickRandomActiveConnection(tgt->GetConnectionList(), randConn, mgr)) if (PickRandomActiveConnection(tgt->GetConnectionList(), randConn, mgr)) {
tgt = mgr.GetObjectById(mgr.GetIdForScript(randConn.x8_objId)); tgt = mgr.GetObjectById(mgr.GetIdForScript(randConn.x8_objId));
else } else {
break; break;
} else }
} else {
break; break;
} }
} }
}
if ((x21c_flags & 0x4) != 0 && (x21c_flags & 0x200) == 0) if ((x21c_flags & 0x4) != 0 && (x21c_flags & 0x200) == 0) {
GenerateMoveOutofIntoPoints(false, mgr); GenerateMoveOutofIntoPoints(false, mgr);
}
} }
void CCinematicCamera::SendArrivedMsg(TUniqueId reciever, CStateManager& mgr) { void CCinematicCamera::SendArrivedMsg(TUniqueId reciever, CStateManager& mgr) {