From 0322b5c6b923369a0e2a6b0b64bcdbb1e6a5fafc Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Thu, 15 Nov 2018 16:03:52 +0100 Subject: [PATCH] Grab currentCutscene as const ref --- rwengine/src/data/CutsceneData.hpp | 8 ++++---- rwgame/states/IngameState.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rwengine/src/data/CutsceneData.hpp b/rwengine/src/data/CutsceneData.hpp index 2d620139..d3526321 100644 --- a/rwengine/src/data/CutsceneData.hpp +++ b/rwengine/src/data/CutsceneData.hpp @@ -39,7 +39,7 @@ struct CutsceneTracks { float duration{0.f}; - glm::vec3 getPositionAt(float time) { + glm::vec3 getPositionAt(float time) const { glm::vec3 p = position.rbegin()->second; for (auto it = position.begin(); it != position.end(); ++it) { if (it->first <= time) { @@ -62,7 +62,7 @@ struct CutsceneTracks { return p; } - glm::vec3 getTargetAt(float time) { + glm::vec3 getTargetAt(float time) const { glm::vec3 p = position.rbegin()->second; for (auto it = target.begin(); it != target.end(); ++it) { if (it->first <= time) { @@ -85,7 +85,7 @@ struct CutsceneTracks { return p; } - float getZoomAt(float time) { + float getZoomAt(float time) const { float r = zoom.rbegin()->second; for (auto it = zoom.begin(); it != zoom.end(); ++it) { if (it->first <= time) { @@ -108,7 +108,7 @@ struct CutsceneTracks { return r; } - float getRotationAt(float time) { + float getRotationAt(float time) const { float r = rotation.rbegin()->second; for (auto it = rotation.begin(); it != rotation.end(); ++it) { if (it->first <= time) { diff --git a/rwgame/states/IngameState.cpp b/rwgame/states/IngameState.cpp index cdafb522..08f81611 100644 --- a/rwgame/states/IngameState.cpp +++ b/rwgame/states/IngameState.cpp @@ -379,8 +379,8 @@ const ViewCamera& IngameState::getCamera(float alpha) { auto player = game->getWorld()->getPlayer(); auto world = getWorld(); - if (state->currentCutscene && state->cutsceneStartTime >= 0.f) { - auto& cutscene = state->currentCutscene; + if (const auto& cutscene = state->currentCutscene; + cutscene && state->cutsceneStartTime >= 0.f) { float cutsceneTime = std::min(world->getGameTime() - state->cutsceneStartTime, cutscene->tracks.duration);