diff --git a/source/graphics/CameraController.cpp b/source/graphics/CameraController.cpp index e37f38dab6..374de29ac1 100644 --- a/source/graphics/CameraController.cpp +++ b/source/graphics/CameraController.cpp @@ -102,7 +102,7 @@ CCameraController::CCameraController(CCamera& camera) m_Camera.UpdateFrustum(); } -void CCameraController::Initialize() +void CCameraController::LoadConfig() { CFG_GET_VAL("view.scroll.speed", m_ViewScrollSpeed); CFG_GET_VAL("view.scroll.speed.modifier", m_ViewScrollSpeedModifier); @@ -516,7 +516,7 @@ void CCameraController::ResetCameraTarget(const CVector3D& target) m_FollowEntity = INVALID_ENTITY; } -void CCameraController::CameraFollow(entity_id_t entity, bool firstPerson) +void CCameraController::FollowEntity(entity_id_t entity, bool firstPerson) { m_FollowEntity = entity; m_FollowFirstPerson = firstPerson; diff --git a/source/graphics/CameraController.h b/source/graphics/CameraController.h index 567b4b8520..2c6a5e6d61 100644 --- a/source/graphics/CameraController.h +++ b/source/graphics/CameraController.h @@ -30,7 +30,7 @@ class CCameraController public: CCameraController(CCamera& camera); - void Initialize(); + void LoadConfig(); InReaction HandleEvent(const SDL_Event_* ev); @@ -42,12 +42,9 @@ public: void SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom); void MoveCameraTarget(const CVector3D& target); void ResetCameraTarget(const CVector3D& target); - void CameraFollow(entity_id_t entity, bool firstPerson); + void FollowEntity(entity_id_t entity, bool firstPerson); entity_id_t GetFollowedEntity(); - // Set projection of current camera using near, far, and FOV values - void SetCameraProjection(); - void Update(const float deltaRealTime); void SetViewport(const SViewPort& vp); @@ -69,6 +66,11 @@ private: void SetupCameraMatrixNonSmooth(CMatrix3D* orientation); void FocusHeight(bool smooth); + /** + * Set projection of current camera using near, far, and FOV values + */ + void SetCameraProjection(); + CCamera& m_Camera; /** diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp index f2f2d35d9e..c73a3bc819 100644 --- a/source/graphics/GameView.cpp +++ b/source/graphics/GameView.cpp @@ -206,7 +206,7 @@ CTerritoryTexture& CGameView::GetTerritoryTexture() int CGameView::Initialize() { - m->CameraController.Initialize(); + m->CameraController.LoadConfig(); return 0; } @@ -351,9 +351,9 @@ void CGameView::ResetCameraTarget(const CVector3D& target) m->CameraController.ResetCameraTarget(target); } -void CGameView::CameraFollow(entity_id_t entity, bool firstPerson) +void CGameView::FollowEntity(entity_id_t entity, bool firstPerson) { - m->CameraController.CameraFollow(entity, firstPerson); + m->CameraController.FollowEntity(entity, firstPerson); } entity_id_t CGameView::GetFollowedEntity() @@ -361,11 +361,6 @@ entity_id_t CGameView::GetFollowedEntity() return m->CameraController.GetFollowedEntity(); } -void CGameView::SetCameraProjection() -{ - m->CameraController.SetCameraProjection(); -} - InReaction game_view_handler(const SDL_Event_* ev) { // put any events that must be processed even if inactive here diff --git a/source/graphics/GameView.h b/source/graphics/GameView.h index 5c27187e9a..bc31df1ae8 100644 --- a/source/graphics/GameView.h +++ b/source/graphics/GameView.h @@ -65,12 +65,9 @@ public: void SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom); void MoveCameraTarget(const CVector3D& target); void ResetCameraTarget(const CVector3D& target); - void CameraFollow(entity_id_t entity, bool firstPerson); + void FollowEntity(entity_id_t entity, bool firstPerson); entity_id_t GetFollowedEntity(); - // Set projection of current camera using near, far, and FOV values - void SetCameraProjection(); - #define DECLARE_BOOLEAN_SETTING(NAME) \ bool Get##NAME##Enabled() const; \ void Set##NAME##Enabled(bool Enabled); diff --git a/source/graphics/scripting/JSInterface_GameView.cpp b/source/graphics/scripting/JSInterface_GameView.cpp index 32bd5cacb7..654a4cf666 100644 --- a/source/graphics/scripting/JSInterface_GameView.cpp +++ b/source/graphics/scripting/JSInterface_GameView.cpp @@ -141,7 +141,7 @@ void JSI_GameView::CameraFollow(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), if (!g_Game || !g_Game->GetView()) return; - g_Game->GetView()->CameraFollow(entityid, false); + g_Game->GetView()->FollowEntity(entityid, false); } /** @@ -153,7 +153,7 @@ void JSI_GameView::CameraFollowFPS(ScriptInterface::CxPrivate* UNUSED(pCxPrivate if (!g_Game || !g_Game->GetView()) return; - g_Game->GetView()->CameraFollow(entityid, true); + g_Game->GetView()->FollowEntity(entityid, true); } entity_id_t JSI_GameView::GetFollowedEntity(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) diff --git a/source/ps/TouchInput.cpp b/source/ps/TouchInput.cpp index 33b05bbf49..68b4620006 100644 --- a/source/ps/TouchInput.cpp +++ b/source/ps/TouchInput.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -128,7 +128,7 @@ void CTouchInput::OnFingerMotion(int id, int x, int y) { m_State = STATE_PANNING; - CCamera& camera = *(g_Game->GetView()->GetCamera()); + const CCamera& camera = *(g_Game->GetView()->GetCamera()); m_PanFocus = camera.GetWorldCoordinates(m_FirstTouchPos.X, m_FirstTouchPos.Y, true); m_PanDist = (m_PanFocus - camera.GetOrientation().GetTranslation()).Y; } diff --git a/source/ps/Util.cpp b/source/ps/Util.cpp index 190be76497..2446e91141 100644 --- a/source/ps/Util.cpp +++ b/source/ps/Util.cpp @@ -346,8 +346,7 @@ void WriteBigScreenshot(const VfsPath& extension, int tiles) { g_Renderer.Resize(tile_w, tile_h); SViewPort vp = { 0, 0, tile_w, tile_h }; - g_Game->GetView()->GetCamera()->SetViewPort(vp); - g_Game->GetView()->SetCameraProjection(); + g_Game->GetView()->SetViewport(vp); } #if !CONFIG2_GLES @@ -404,8 +403,7 @@ void WriteBigScreenshot(const VfsPath& extension, int tiles) { g_Renderer.Resize(g_xres, g_yres); SViewPort vp = { 0, 0, g_xres, g_yres }; - g_Game->GetView()->GetCamera()->SetViewPort(vp); - g_Game->GetView()->SetCameraProjection(); + g_Game->GetView()->SetViewport(vp); g_Game->GetView()->GetCamera()->SetPerspectiveProjectionTile(1, 0, 0); } diff --git a/source/renderer/PatchRData.cpp b/source/renderer/PatchRData.cpp index 9c7693ecbf..d62e00db40 100644 --- a/source/renderer/PatchRData.cpp +++ b/source/renderer/PatchRData.cpp @@ -1253,7 +1253,7 @@ void CPatchRData::RenderSides(CShaderProgramPtr& shader) void CPatchRData::RenderPriorities(CTextRenderer& textRenderer) { CTerrain* terrain = m_Patch->m_Parent; - CCamera* camera = g_Game->GetView()->GetCamera(); + const CCamera& camera = *(g_Game->GetView()->GetCamera()); for (ssize_t j = 0; j < PATCH_SIZE; ++j) { @@ -1270,7 +1270,7 @@ void CPatchRData::RenderPriorities(CTextRenderer& textRenderer) pos.Z += TERRAIN_TILE_SIZE/4.f; float x, y; - camera->GetScreenCoordinates(pos, x, y); + camera.GetScreenCoordinates(pos, x, y); textRenderer.PrintfAt(x, y, L"%d", m_Patch->m_MiniPatches[j][i].Priority); } diff --git a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp index c2684f6878..3006aab53a 100644 --- a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp @@ -62,8 +62,7 @@ QUERYHANDLER(CinemaRecord) { g_Renderer.Resize(w, h); SViewPort vp = { 0, 0, w, h }; - g_Game->GetView()->GetCamera()->SetViewPort(vp); - g_Game->GetView()->SetCameraProjection(); + g_Game->GetView()->SetViewport(vp); } unsigned char* img = new unsigned char [w*h*3]; @@ -114,8 +113,7 @@ QUERYHANDLER(CinemaRecord) { g_Renderer.Resize(g_xres, g_yres); SViewPort vp = { 0, 0, g_xres, g_yres }; - g_Game->GetView()->GetCamera()->SetViewPort(vp); - g_Game->GetView()->SetCameraProjection(); + g_Game->GetView()->SetViewport(vp); } }