2023-06-14 09:06:22 +02:00
|
|
|
/* Copyright (C) 2023 Wildfire Games.
|
2023-12-03 01:30:12 +01:00
|
|
|
* This file is part of 0 A.D.
|
2009-04-18 19:00:33 +02:00
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2009-04-18 19:00:33 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2009-04-18 19:00:33 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-12-03 01:30:12 +01:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2009-04-18 19:00:33 +02:00
|
|
|
*/
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "GameView.h"
|
|
|
|
|
2019-10-02 22:55:43 +02:00
|
|
|
#include "graphics/CameraController.h"
|
2015-12-30 22:16:35 +01:00
|
|
|
#include "graphics/CinemaManager.h"
|
2007-03-01 19:52:53 +01:00
|
|
|
#include "graphics/ColladaManager.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "graphics/HFTracer.h"
|
2011-02-03 02:12:24 +01:00
|
|
|
#include "graphics/LOSTexture.h"
|
2014-11-18 00:29:49 +01:00
|
|
|
#include "graphics/LightEnv.h"
|
2021-06-01 20:55:35 +02:00
|
|
|
#include "graphics/MiniMapTexture.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "graphics/Model.h"
|
|
|
|
#include "graphics/ObjectManager.h"
|
|
|
|
#include "graphics/Patch.h"
|
2007-03-01 19:52:53 +01:00
|
|
|
#include "graphics/SkeletonAnimManager.h"
|
2019-10-02 00:42:54 +02:00
|
|
|
#include "graphics/SmoothedValue.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "graphics/Terrain.h"
|
2010-09-04 23:26:52 +02:00
|
|
|
#include "graphics/TerrainTextureManager.h"
|
2011-07-20 21:48:06 +02:00
|
|
|
#include "graphics/TerritoryTexture.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "graphics/Unit.h"
|
|
|
|
#include "graphics/UnitManager.h"
|
|
|
|
#include "lib/input.h"
|
|
|
|
#include "lib/timer.h"
|
2014-11-18 00:29:49 +01:00
|
|
|
#include "lobby/IXmppClient.h"
|
2011-11-25 07:36:13 +01:00
|
|
|
#include "maths/BoundingBoxAligned.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "maths/MathUtil.h"
|
|
|
|
#include "maths/Matrix3D.h"
|
|
|
|
#include "maths/Quaternion.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/ConfigDB.h"
|
2012-02-19 04:30:59 +01:00
|
|
|
#include "ps/Filesystem.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "ps/Game.h"
|
|
|
|
#include "ps/Globals.h"
|
|
|
|
#include "ps/Hotkey.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/Loader.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "ps/Profile.h"
|
|
|
|
#include "ps/Pyrogenesis.h"
|
2012-02-25 18:29:27 +01:00
|
|
|
#include "ps/TouchInput.h"
|
2010-05-20 20:09:23 +02:00
|
|
|
#include "ps/World.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "renderer/Renderer.h"
|
2022-01-04 14:29:01 +01:00
|
|
|
#include "renderer/SceneRenderer.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "renderer/WaterManager.h"
|
2010-01-09 20:20:14 +01:00
|
|
|
#include "simulation2/Simulation2.h"
|
2010-09-27 01:05:25 +02:00
|
|
|
#include "simulation2/components/ICmpPosition.h"
|
2011-03-04 21:02:05 +01:00
|
|
|
#include "simulation2/components/ICmpRangeManager.h"
|
2004-12-12 20:43:55 +01:00
|
|
|
|
2019-12-21 01:44:18 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2013-09-12 14:40:05 +02:00
|
|
|
class CGameViewImpl
|
2007-01-08 02:56:46 +01:00
|
|
|
{
|
2009-01-03 19:40:28 +01:00
|
|
|
NONCOPYABLE(CGameViewImpl);
|
2007-01-08 02:56:46 +01:00
|
|
|
public:
|
2023-06-14 09:06:22 +02:00
|
|
|
CGameViewImpl(Renderer::Backend::IDevice* device, CGame* game)
|
2007-03-01 19:52:53 +01:00
|
|
|
: Game(game),
|
2012-02-19 04:30:59 +01:00
|
|
|
ColladaManager(g_VFS), MeshManager(ColladaManager), SkeletonAnimManager(ColladaManager),
|
2010-06-03 03:29:43 +02:00
|
|
|
ObjectManager(MeshManager, SkeletonAnimManager, *game->GetSimulation2()),
|
2011-04-05 22:32:03 +02:00
|
|
|
LOSTexture(*game->GetSimulation2()),
|
2011-07-20 21:48:06 +02:00
|
|
|
TerritoryTexture(*game->GetSimulation2()),
|
2023-06-14 09:06:22 +02:00
|
|
|
MiniMapTexture(device, *game->GetSimulation2()),
|
2007-01-08 02:56:46 +01:00
|
|
|
ViewCamera(),
|
|
|
|
CullCamera(),
|
|
|
|
LockCullCamera(false),
|
|
|
|
Culling(true),
|
2019-12-21 01:44:18 +01:00
|
|
|
CameraController(new CCameraController(ViewCamera))
|
2007-01-08 02:56:46 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CGame* Game;
|
2007-03-01 19:52:53 +01:00
|
|
|
CColladaManager ColladaManager;
|
2007-01-08 02:56:46 +01:00
|
|
|
CMeshManager MeshManager;
|
2007-03-01 19:52:53 +01:00
|
|
|
CSkeletonAnimManager SkeletonAnimManager;
|
2007-01-08 02:56:46 +01:00
|
|
|
CObjectManager ObjectManager;
|
2011-02-03 02:12:24 +01:00
|
|
|
CLOSTexture LOSTexture;
|
2011-07-20 21:48:06 +02:00
|
|
|
CTerritoryTexture TerritoryTexture;
|
2021-06-01 20:55:35 +02:00
|
|
|
CMiniMapTexture MiniMapTexture;
|
2007-01-08 02:56:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* this camera controls the eye position when rendering
|
|
|
|
*/
|
|
|
|
CCamera ViewCamera;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* this camera controls the frustum that is used for culling
|
|
|
|
* and shadow calculations
|
|
|
|
*
|
|
|
|
* Note that all code that works with camera movements should only change
|
|
|
|
* m_ViewCamera. The render functions automatically sync the cull camera to
|
|
|
|
* the view camera depending on the value of m_LockCullCamera.
|
|
|
|
*/
|
|
|
|
CCamera CullCamera;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When @c true, the cull camera is locked in place.
|
|
|
|
* When @c false, the cull camera follows the view camera.
|
|
|
|
*
|
|
|
|
* Exposed to JS as gameView.lockCullCamera
|
|
|
|
*/
|
|
|
|
bool LockCullCamera;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When @c true, culling is enabled so that only models that have a chance of
|
|
|
|
* being visible are sent to the renderer.
|
|
|
|
* Otherwise, the entire world is sent to the renderer.
|
|
|
|
*
|
|
|
|
* Exposed to JS as gameView.culling
|
|
|
|
*/
|
|
|
|
bool Culling;
|
|
|
|
|
2015-12-30 22:16:35 +01:00
|
|
|
CCinemaManager CinemaManager;
|
2007-01-08 02:56:46 +01:00
|
|
|
|
2019-12-21 01:44:18 +01:00
|
|
|
/**
|
|
|
|
* Controller of the view's camera. We use a std::unique_ptr for an easy
|
|
|
|
* on the fly replacement. It's guaranteed that the pointer is never nulllptr.
|
|
|
|
*/
|
|
|
|
std::unique_ptr<ICameraController> CameraController;
|
2007-01-08 02:56:46 +01:00
|
|
|
};
|
|
|
|
|
2013-09-12 14:40:05 +02:00
|
|
|
#define IMPLEMENT_BOOLEAN_SETTING(NAME) \
|
2019-04-23 00:12:08 +02:00
|
|
|
bool CGameView::Get##NAME##Enabled() const \
|
2013-09-12 14:40:05 +02:00
|
|
|
{ \
|
|
|
|
return m->NAME; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void CGameView::Set##NAME##Enabled(bool Enabled) \
|
|
|
|
{ \
|
|
|
|
m->NAME = Enabled; \
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPLEMENT_BOOLEAN_SETTING(Culling);
|
|
|
|
IMPLEMENT_BOOLEAN_SETTING(LockCullCamera);
|
|
|
|
|
2019-10-02 22:55:43 +02:00
|
|
|
bool CGameView::GetConstrainCameraEnabled() const
|
2010-08-13 15:26:29 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
return m->CameraController->GetConstrainCamera();
|
2010-08-13 15:26:29 +02:00
|
|
|
}
|
|
|
|
|
2019-10-02 22:55:43 +02:00
|
|
|
void CGameView::SetConstrainCameraEnabled(bool enabled)
|
2011-03-04 21:02:05 +01:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
m->CameraController->SetConstrainCamera(enabled);
|
2011-03-04 21:02:05 +01:00
|
|
|
}
|
|
|
|
|
2019-10-02 22:55:43 +02:00
|
|
|
#undef IMPLEMENT_BOOLEAN_SETTING
|
2011-03-04 21:02:05 +01:00
|
|
|
|
2023-06-14 09:06:22 +02:00
|
|
|
CGameView::CGameView(Renderer::Backend::IDevice* device, CGame *pGame):
|
|
|
|
m(new CGameViewImpl(device, pGame))
|
2004-07-31 17:57:18 +02:00
|
|
|
{
|
2007-01-08 02:56:46 +01:00
|
|
|
m->CullCamera = m->ViewCamera;
|
2022-01-04 14:29:01 +01:00
|
|
|
g_Renderer.GetSceneRenderer().SetSceneCamera(m->ViewCamera, m->CullCamera);
|
2004-09-28 18:01:11 +02:00
|
|
|
}
|
|
|
|
|
2004-12-16 13:41:54 +01:00
|
|
|
CGameView::~CGameView()
|
|
|
|
{
|
|
|
|
UnloadResources();
|
2007-01-08 02:56:46 +01:00
|
|
|
|
|
|
|
delete m;
|
2004-12-16 13:41:54 +01:00
|
|
|
}
|
|
|
|
|
2010-06-03 21:07:59 +02:00
|
|
|
void CGameView::SetViewport(const SViewPort& vp)
|
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
m->CameraController->SetViewport(vp);
|
2010-06-03 21:07:59 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 00:12:08 +02:00
|
|
|
CObjectManager& CGameView::GetObjectManager()
|
2005-05-18 07:32:09 +02:00
|
|
|
{
|
2007-01-08 02:56:46 +01:00
|
|
|
return m->ObjectManager;
|
|
|
|
}
|
2005-05-18 07:32:09 +02:00
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
CCamera* CGameView::GetCamera()
|
|
|
|
{
|
|
|
|
return &m->ViewCamera;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCinemaManager* CGameView::GetCinema()
|
2004-09-28 18:01:11 +02:00
|
|
|
{
|
2015-12-30 22:16:35 +01:00
|
|
|
return &m->CinemaManager;
|
2021-06-01 20:55:35 +02:00
|
|
|
}
|
2004-07-31 17:57:18 +02:00
|
|
|
|
2011-02-03 02:12:24 +01:00
|
|
|
CLOSTexture& CGameView::GetLOSTexture()
|
2007-01-08 02:56:46 +01:00
|
|
|
{
|
2011-02-03 02:12:24 +01:00
|
|
|
return m->LOSTexture;
|
2007-01-08 02:56:46 +01:00
|
|
|
}
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2011-07-20 21:48:06 +02:00
|
|
|
CTerritoryTexture& CGameView::GetTerritoryTexture()
|
|
|
|
{
|
|
|
|
return m->TerritoryTexture;
|
|
|
|
}
|
|
|
|
|
2021-06-01 20:55:35 +02:00
|
|
|
CMiniMapTexture& CGameView::GetMiniMapTexture()
|
|
|
|
{
|
|
|
|
return m->MiniMapTexture;
|
|
|
|
}
|
|
|
|
|
2010-06-30 23:41:04 +02:00
|
|
|
void CGameView::RegisterInit()
|
2005-03-22 03:17:55 +01:00
|
|
|
{
|
2005-03-22 22:00:56 +01:00
|
|
|
// CGameView init
|
2023-06-26 20:35:34 +02:00
|
|
|
LDR_Register([this](const double)
|
|
|
|
{
|
|
|
|
m->CameraController->LoadConfig();
|
|
|
|
return 0;
|
|
|
|
}, L"CGameView init", 1);
|
2005-03-22 22:00:56 +01:00
|
|
|
|
2023-06-26 20:35:34 +02:00
|
|
|
LDR_Register([](const double)
|
|
|
|
{
|
|
|
|
return g_TexMan.LoadTerrainTextures();
|
|
|
|
}, L"LoadTerrainTextures", 60);
|
2005-03-22 03:17:55 +01:00
|
|
|
}
|
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
void CGameView::BeginFrame()
|
2004-07-27 23:00:53 +02:00
|
|
|
{
|
2007-01-08 02:56:46 +01:00
|
|
|
if (m->LockCullCamera == false)
|
2006-12-06 03:52:14 +01:00
|
|
|
{
|
2006-12-09 03:30:19 +01:00
|
|
|
// Set up cull camera
|
2007-01-08 02:56:46 +01:00
|
|
|
m->CullCamera = m->ViewCamera;
|
2006-12-06 03:52:14 +01:00
|
|
|
}
|
2022-01-04 14:29:01 +01:00
|
|
|
g_Renderer.GetSceneRenderer().SetSceneCamera(m->ViewCamera, m->CullCamera);
|
2004-08-05 15:07:51 +02:00
|
|
|
|
2015-03-16 00:59:48 +01:00
|
|
|
m->Game->CachePlayerColors();
|
2011-03-26 21:17:21 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 20:59:18 +01:00
|
|
|
void CGameView::Prepare(
|
|
|
|
Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
|
2011-03-26 21:17:21 +01:00
|
|
|
{
|
2022-11-18 20:59:18 +01:00
|
|
|
g_Renderer.GetSceneRenderer().PrepareScene(deviceCommandContext, *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameView::Render(
|
|
|
|
Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
|
|
|
|
{
|
|
|
|
g_Renderer.GetSceneRenderer().RenderScene(deviceCommandContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameView::RenderOverlays(
|
|
|
|
Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
|
|
|
|
{
|
|
|
|
g_Renderer.GetSceneRenderer().RenderSceneOverlays(deviceCommandContext);
|
2004-07-27 23:00:53 +02:00
|
|
|
}
|
|
|
|
|
2006-09-24 13:25:11 +02:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// This callback is part of the Scene interface
|
|
|
|
// Submit all objects visible in the given frustum
|
|
|
|
void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c)
|
2004-07-27 23:00:53 +02:00
|
|
|
{
|
2011-11-04 02:35:50 +01:00
|
|
|
{
|
|
|
|
PROFILE3("submit terrain");
|
|
|
|
|
2023-09-26 22:10:40 +02:00
|
|
|
const CTerrain& terrain = m->Game->GetWorld()->GetTerrain();
|
2022-01-04 14:29:01 +01:00
|
|
|
float waterHeight = g_Renderer.GetSceneRenderer().GetWaterManager().m_WaterHeight + 0.001f;
|
2023-09-26 22:10:40 +02:00
|
|
|
const ssize_t patchesPerSide = terrain.GetPatchesPerSide();
|
2007-05-06 09:58:16 +02:00
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
// find out which patches will be drawn
|
2015-12-28 17:27:31 +01:00
|
|
|
for (ssize_t j=0; j<patchesPerSide; ++j)
|
|
|
|
{
|
|
|
|
for (ssize_t i=0; i<patchesPerSide; ++i)
|
|
|
|
{
|
2023-09-26 22:10:40 +02:00
|
|
|
CPatch* const patch = terrain.GetPatch(i,j); // can't fail
|
2006-05-29 02:49:09 +02:00
|
|
|
|
|
|
|
// If the patch is underwater, calculate a bounding box that also contains the water plane
|
2011-11-25 07:36:13 +01:00
|
|
|
CBoundingBoxAligned bounds = patch->GetWorldBounds();
|
2015-12-28 17:27:31 +01:00
|
|
|
if(bounds[1].Y < waterHeight)
|
2006-05-29 02:49:09 +02:00
|
|
|
bounds[1].Y = waterHeight;
|
2012-04-18 22:39:00 +02:00
|
|
|
|
2015-12-28 17:27:31 +01:00
|
|
|
if (!m->Culling || frustum.IsBoxVisible(bounds))
|
2006-09-24 13:25:11 +02:00
|
|
|
c->Submit(patch);
|
2004-07-27 23:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
2011-11-04 02:35:50 +01:00
|
|
|
}
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2010-05-20 20:09:23 +02:00
|
|
|
m->Game->GetSimulation2()->RenderSubmit(*c, frustum, m->Culling);
|
2004-07-27 23:00:53 +02:00
|
|
|
}
|
|
|
|
|
2004-12-16 13:41:54 +01:00
|
|
|
void CGameView::UnloadResources()
|
|
|
|
{
|
2005-11-06 06:05:07 +01:00
|
|
|
g_TexMan.UnloadTerrainTextures();
|
2022-01-04 14:29:01 +01:00
|
|
|
g_Renderer.GetSceneRenderer().GetWaterManager().UnloadWaterTextures();
|
2004-12-16 13:41:54 +01:00
|
|
|
}
|
|
|
|
|
2012-06-06 21:37:03 +02:00
|
|
|
void CGameView::Update(const float deltaRealTime)
|
2004-07-31 17:57:18 +02:00
|
|
|
{
|
2021-06-01 20:55:35 +02:00
|
|
|
m->MiniMapTexture.Update(deltaRealTime);
|
|
|
|
|
2012-02-25 18:29:27 +01:00
|
|
|
// If camera movement is being handled by the touch-input system,
|
|
|
|
// then we should stop to avoid conflicting with it
|
|
|
|
if (g_TouchInput.IsEnabled())
|
|
|
|
return;
|
|
|
|
|
2005-10-31 19:36:36 +01:00
|
|
|
if (!g_app_has_focus)
|
2004-07-31 17:57:18 +02:00
|
|
|
return;
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2017-04-05 05:59:20 +02:00
|
|
|
m->CinemaManager.Update(deltaRealTime);
|
|
|
|
if (m->CinemaManager.IsEnabled())
|
2007-01-08 02:56:46 +01:00
|
|
|
return;
|
2006-01-07 02:04:26 +01:00
|
|
|
|
2019-12-21 01:44:18 +01:00
|
|
|
m->CameraController->Update(deltaRealTime);
|
2004-07-31 17:57:18 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 00:12:08 +02:00
|
|
|
CVector3D CGameView::GetCameraPivot() const
|
2014-04-06 18:27:57 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
return m->CameraController->GetCameraPivot();
|
2014-04-06 18:27:57 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 00:12:08 +02:00
|
|
|
CVector3D CGameView::GetCameraPosition() const
|
2014-04-06 18:27:57 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
return m->CameraController->GetCameraPosition();
|
2014-04-06 18:27:57 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 00:12:08 +02:00
|
|
|
CVector3D CGameView::GetCameraRotation() const
|
2014-04-06 18:27:57 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
return m->CameraController->GetCameraRotation();
|
2014-04-06 18:27:57 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 00:12:08 +02:00
|
|
|
float CGameView::GetCameraZoom() const
|
2014-04-06 18:27:57 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
return m->CameraController->GetCameraZoom();
|
2014-04-06 18:27:57 +02:00
|
|
|
}
|
|
|
|
|
2019-08-22 22:49:58 +02:00
|
|
|
void CGameView::SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom)
|
2014-04-06 18:27:57 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
m->CameraController->SetCamera(pos, rotX, rotY, zoom);
|
2014-04-06 18:27:57 +02:00
|
|
|
}
|
|
|
|
|
2011-12-10 08:07:04 +01:00
|
|
|
void CGameView::MoveCameraTarget(const CVector3D& target)
|
2004-07-31 17:57:18 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
m->CameraController->MoveCameraTarget(target);
|
2004-07-31 17:57:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-13 15:26:29 +02:00
|
|
|
void CGameView::ResetCameraTarget(const CVector3D& target)
|
2004-07-31 17:57:18 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
m->CameraController->ResetCameraTarget(target);
|
2010-08-14 02:52:19 +02:00
|
|
|
}
|
|
|
|
|
2019-10-03 14:58:47 +02:00
|
|
|
void CGameView::FollowEntity(entity_id_t entity, bool firstPerson)
|
2010-09-27 01:05:25 +02:00
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
m->CameraController->FollowEntity(entity, firstPerson);
|
2010-09-27 01:05:25 +02:00
|
|
|
}
|
|
|
|
|
2011-07-05 23:29:11 +02:00
|
|
|
entity_id_t CGameView::GetFollowedEntity()
|
|
|
|
{
|
2019-12-21 01:44:18 +01:00
|
|
|
return m->CameraController->GetFollowedEntity();
|
2011-07-05 23:29:11 +02:00
|
|
|
}
|
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
InReaction game_view_handler(const SDL_Event_* ev)
|
2004-07-31 17:57:18 +02:00
|
|
|
{
|
|
|
|
// put any events that must be processed even if inactive here
|
2017-08-12 12:32:07 +02:00
|
|
|
if (!g_app_has_focus || !g_Game || !g_Game->IsGameStarted() || g_Game->GetView()->GetCinema()->IsEnabled())
|
2005-10-20 19:44:56 +02:00
|
|
|
return IN_PASS;
|
2004-07-31 17:57:18 +02:00
|
|
|
|
2004-08-05 15:07:51 +02:00
|
|
|
CGameView *pView=g_Game->GetView();
|
|
|
|
|
2005-09-29 01:57:55 +02:00
|
|
|
return pView->HandleEvent(ev);
|
|
|
|
}
|
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
InReaction CGameView::HandleEvent(const SDL_Event_* ev)
|
2005-09-29 01:57:55 +02:00
|
|
|
{
|
2006-08-26 23:52:18 +02:00
|
|
|
switch(ev->ev.type)
|
2004-07-31 17:57:18 +02:00
|
|
|
{
|
2020-05-26 23:47:03 +02:00
|
|
|
case SDL_HOTKEYPRESS:
|
|
|
|
{
|
2010-10-23 04:37:00 +02:00
|
|
|
std::string hotkey = static_cast<const char*>(ev->ev.user.data1);
|
2022-01-04 14:29:01 +01:00
|
|
|
CSceneRenderer& sceneRenderer = g_Renderer.GetSceneRenderer();
|
2010-10-23 04:37:00 +02:00
|
|
|
if (hotkey == "wireframe")
|
2004-07-31 17:57:18 +02:00
|
|
|
{
|
2014-04-28 07:02:20 +02:00
|
|
|
if (g_XmppClient && g_rankedGame == true)
|
|
|
|
break;
|
2022-01-04 14:29:01 +01:00
|
|
|
else if (sceneRenderer.GetModelRenderMode() == SOLID)
|
2005-10-26 03:43:49 +02:00
|
|
|
{
|
2022-01-04 14:29:01 +01:00
|
|
|
sceneRenderer.SetTerrainRenderMode(EDGED_FACES);
|
|
|
|
sceneRenderer.SetWaterRenderMode(EDGED_FACES);
|
|
|
|
sceneRenderer.SetModelRenderMode(EDGED_FACES);
|
|
|
|
sceneRenderer.SetOverlayRenderMode(EDGED_FACES);
|
2005-10-26 03:43:49 +02:00
|
|
|
}
|
2022-01-04 14:29:01 +01:00
|
|
|
else if (sceneRenderer.GetModelRenderMode() == EDGED_FACES)
|
2005-10-26 03:43:49 +02:00
|
|
|
{
|
2022-01-04 14:29:01 +01:00
|
|
|
sceneRenderer.SetTerrainRenderMode(WIREFRAME);
|
|
|
|
sceneRenderer.SetWaterRenderMode(WIREFRAME);
|
|
|
|
sceneRenderer.SetModelRenderMode(WIREFRAME);
|
|
|
|
sceneRenderer.SetOverlayRenderMode(WIREFRAME);
|
2005-10-26 03:43:49 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-04 14:29:01 +01:00
|
|
|
sceneRenderer.SetTerrainRenderMode(SOLID);
|
|
|
|
sceneRenderer.SetWaterRenderMode(SOLID);
|
|
|
|
sceneRenderer.SetModelRenderMode(SOLID);
|
|
|
|
sceneRenderer.SetOverlayRenderMode(SOLID);
|
2004-07-31 17:57:18 +02:00
|
|
|
}
|
2010-08-13 15:26:29 +02:00
|
|
|
return IN_HANDLED;
|
2010-10-23 04:37:00 +02:00
|
|
|
}
|
2004-07-31 17:57:18 +02:00
|
|
|
}
|
2020-05-26 23:47:03 +02:00
|
|
|
}
|
2004-07-31 17:57:18 +02:00
|
|
|
|
2019-12-21 01:44:18 +01:00
|
|
|
return m->CameraController->HandleEvent(ev);
|
2004-07-31 17:57:18 +02:00
|
|
|
}
|