Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/GameView.cpp
Show All 29 Lines | |||||
#include "graphics/Patch.h" | #include "graphics/Patch.h" | ||||
#include "graphics/SkeletonAnimManager.h" | #include "graphics/SkeletonAnimManager.h" | ||||
#include "graphics/SmoothedValue.h" | #include "graphics/SmoothedValue.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/TerrainTextureManager.h" | #include "graphics/TerrainTextureManager.h" | ||||
#include "graphics/TerritoryTexture.h" | #include "graphics/TerritoryTexture.h" | ||||
#include "graphics/Unit.h" | #include "graphics/Unit.h" | ||||
#include "graphics/UnitManager.h" | #include "graphics/UnitManager.h" | ||||
#include "graphics/WaterManager.h" | |||||
#include "graphics/scripting/JSInterface_GameView.h" | #include "graphics/scripting/JSInterface_GameView.h" | ||||
#include "lib/input.h" | #include "lib/input.h" | ||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "lobby/IXmppClient.h" | #include "lobby/IXmppClient.h" | ||||
#include "maths/BoundingBoxAligned.h" | #include "maths/BoundingBoxAligned.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "maths/Matrix3D.h" | #include "maths/Matrix3D.h" | ||||
#include "maths/Quaternion.h" | #include "maths/Quaternion.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/Globals.h" | #include "ps/Globals.h" | ||||
#include "ps/Hotkey.h" | #include "ps/Hotkey.h" | ||||
#include "ps/Joystick.h" | #include "ps/Joystick.h" | ||||
#include "ps/Loader.h" | #include "ps/Loader.h" | ||||
#include "ps/LoaderThunks.h" | #include "ps/LoaderThunks.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/Pyrogenesis.h" | #include "ps/Pyrogenesis.h" | ||||
#include "ps/TouchInput.h" | #include "ps/TouchInput.h" | ||||
#include "ps/World.h" | #include "ps/World.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/WaterManager.h" | |||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/components/ICmpPosition.h" | #include "simulation2/components/ICmpPosition.h" | ||||
#include "simulation2/components/ICmpRangeManager.h" | #include "simulation2/components/ICmpRangeManager.h" | ||||
#include <memory> | #include <memory> | ||||
class CGameViewImpl | class CGameViewImpl | ||||
{ | { | ||||
Show All 15 Lines | public: | ||||
CGame* Game; | CGame* Game; | ||||
CColladaManager ColladaManager; | CColladaManager ColladaManager; | ||||
CMeshManager MeshManager; | CMeshManager MeshManager; | ||||
CSkeletonAnimManager SkeletonAnimManager; | CSkeletonAnimManager SkeletonAnimManager; | ||||
CObjectManager ObjectManager; | CObjectManager ObjectManager; | ||||
CLOSTexture LOSTexture; | CLOSTexture LOSTexture; | ||||
CTerritoryTexture TerritoryTexture; | CTerritoryTexture TerritoryTexture; | ||||
WaterManager WaterManager; | |||||
/** | /** | ||||
* this camera controls the eye position when rendering | * this camera controls the eye position when rendering | ||||
*/ | */ | ||||
CCamera ViewCamera; | CCamera ViewCamera; | ||||
/** | /** | ||||
* this camera controls the frustum that is used for culling | * this camera controls the frustum that is used for culling | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
CCinemaManager* CGameView::GetCinema() | CCinemaManager* CGameView::GetCinema() | ||||
{ | { | ||||
return &m->CinemaManager; | return &m->CinemaManager; | ||||
}; | }; | ||||
CLOSTexture& CGameView::GetLOSTexture() | CLOSTexture& CGameView::GetLOSTexture() | ||||
{ | { | ||||
return m->LOSTexture; | return m->LOSTexture; | ||||
} | } | ||||
CTerritoryTexture& CGameView::GetTerritoryTexture() | CTerritoryTexture& CGameView::GetTerritoryTexture() | ||||
wraitii: I haven't done the legwork, but I don't think there's really much sense to a GameView without a… | |||||
{ | { | ||||
return m->TerritoryTexture; | return m->TerritoryTexture; | ||||
} | } | ||||
const WaterManager& CGameView::GetWaterManager() const | |||||
{ | |||||
return m->WaterManager; | |||||
} | |||||
WaterManager& CGameView::GetMutableWaterManager() | |||||
{ | |||||
return m->WaterManager; | |||||
} | |||||
int CGameView::Initialize() | int CGameView::Initialize() | ||||
{ | { | ||||
m->CameraController->LoadConfig(); | m->CameraController->LoadConfig(); | ||||
return 0; | return 0; | ||||
} | } | ||||
void CGameView::RegisterInit() | void CGameView::RegisterInit() | ||||
{ | { | ||||
// CGameView init | // CGameView init | ||||
RegMemFun(this, &CGameView::Initialize, L"CGameView init", 1); | RegMemFun(this, &CGameView::Initialize, L"CGameView init", 1); | ||||
RegMemFun(g_TexMan.GetSingletonPtr(), &CTerrainTextureManager::LoadTerrainTextures, L"LoadTerrainTextures", 60); | RegMemFun(g_TexMan.GetSingletonPtr(), &CTerrainTextureManager::LoadTerrainTextures, L"LoadTerrainTextures", 60); | ||||
RegMemFun(g_Renderer.GetSingletonPtr(), &CRenderer::LoadAlphaMaps, L"LoadAlphaMaps", 5); | RegMemFun(g_Renderer.GetSingletonPtr(), &CRenderer::LoadAlphaMaps, L"LoadAlphaMaps", 5); | ||||
Done Inline ActionsRegMemFun. vladislavbelov: `RegMemFun`. | |||||
} | } | ||||
Done Inline ActionsI believe it should be in RegMemFun, because it loads a bunch of textures inside. vladislavbelov: I believe it should be in `RegMemFun`, because it loads a bunch of textures inside. | |||||
void CGameView::BeginFrame() | void CGameView::BeginFrame() | ||||
{ | { | ||||
if (m->LockCullCamera == false) | if (m->LockCullCamera == false) | ||||
{ | { | ||||
// Set up cull camera | // Set up cull camera | ||||
m->CullCamera = m->ViewCamera; | m->CullCamera = m->ViewCamera; | ||||
} | } | ||||
g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera); | g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera); | ||||
CheckLightEnv(); | CheckLightEnv(); | ||||
m->WaterManager.RecomputeWaterDataIfNeeded(); | |||||
m->Game->CachePlayerColors(); | m->Game->CachePlayerColors(); | ||||
} | } | ||||
void CGameView::Render() | void CGameView::Render() | ||||
{ | { | ||||
g_Renderer.RenderScene(*this); | g_Renderer.RenderScene(*this); | ||||
} | } | ||||
/////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////// | ||||
// This callback is part of the Scene interface | // This callback is part of the Scene interface | ||||
// Submit all objects visible in the given frustum | // Submit all objects visible in the given frustum | ||||
void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c) | void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c) | ||||
{ | { | ||||
{ | { | ||||
PROFILE3("submit terrain"); | PROFILE3("submit terrain"); | ||||
CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain(); | CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain(); | ||||
float waterHeight = g_Renderer.GetWaterManager()->m_WaterHeight + 0.001f; | float waterHeight = g_Game->GetView()->GetWaterManager().GetWaterHeight() + 0.001f; | ||||
Done Inline ActionsMaybe Could Be GetHeight since the previous call is water Stan: Maybe Could Be `GetHeight` since the previous call is water | |||||
Done Inline ActionsAlso const while at it. vladislavbelov: Also `const` while at it. | |||||
const ssize_t patchesPerSide = pTerrain->GetPatchesPerSide(); | const ssize_t patchesPerSide = pTerrain->GetPatchesPerSide(); | ||||
// find out which patches will be drawn | // find out which patches will be drawn | ||||
for (ssize_t j=0; j<patchesPerSide; ++j) | for (ssize_t j=0; j<patchesPerSide; ++j) | ||||
{ | { | ||||
for (ssize_t i=0; i<patchesPerSide; ++i) | for (ssize_t i=0; i<patchesPerSide; ++i) | ||||
{ | { | ||||
CPatch* patch=pTerrain->GetPatch(i,j); // can't fail | CPatch* patch=pTerrain->GetPatch(i,j); // can't fail | ||||
Show All 32 Lines | for (size_t i = 0; i < units.size(); ++i) | ||||
units[i]->GetModel().SetDirtyRec(RENDERDATA_UPDATE_COLOR); | units[i]->GetModel().SetDirtyRec(RENDERDATA_UPDATE_COLOR); | ||||
} | } | ||||
void CGameView::UnloadResources() | void CGameView::UnloadResources() | ||||
{ | { | ||||
g_TexMan.UnloadTerrainTextures(); | g_TexMan.UnloadTerrainTextures(); | ||||
g_Renderer.UnloadAlphaMaps(); | g_Renderer.UnloadAlphaMaps(); | ||||
g_Renderer.GetWaterManager()->UnloadWaterTextures(); | |||||
} | } | ||||
void CGameView::Update(const float deltaRealTime) | void CGameView::Update(const float deltaRealTime) | ||||
{ | { | ||||
// If camera movement is being handled by the touch-input system, | // If camera movement is being handled by the touch-input system, | ||||
// then we should stop to avoid conflicting with it | // then we should stop to avoid conflicting with it | ||||
if (g_TouchInput.IsEnabled()) | if (g_TouchInput.IsEnabled()) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
I haven't done the legwork, but I don't think there's really much sense to a GameView without a CWorld.