mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Makes GameView returning reference on camera
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
#include "CinemaManager.h"
|
#include "CinemaManager.h"
|
||||||
|
|
||||||
#include "graphics/Color.h"
|
#include "graphics/Color.h"
|
||||||
#include "graphics/GameView.h"
|
|
||||||
#include "graphics/Terrain.h"
|
#include "graphics/Terrain.h"
|
||||||
#include "maths/FixedVector3D.h"
|
#include "maths/FixedVector3D.h"
|
||||||
#include "maths/NUSpline.h"
|
#include "maths/NUSpline.h"
|
||||||
@@ -40,7 +39,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
void CCinemaManager::Update(const float deltaRealTime)
|
void CCinemaManager::Update(const float deltaRealTime, CCamera& camera)
|
||||||
{
|
{
|
||||||
CmpPtr<ICmpCinemaManager> cmpCinemaManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
|
CmpPtr<ICmpCinemaManager> cmpCinemaManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
|
||||||
if (!cmpCinemaManager)
|
if (!cmpCinemaManager)
|
||||||
@@ -53,7 +52,7 @@ void CCinemaManager::Update(const float deltaRealTime)
|
|||||||
g_RenderingOptions.SetSmoothLOS(false);
|
g_RenderingOptions.SetSmoothLOS(false);
|
||||||
m_SmoothLosOverridden = true;
|
m_SmoothLosOverridden = true;
|
||||||
}
|
}
|
||||||
cmpCinemaManager->UpdateActivePath(deltaRealTime, g_Game->GetView()->GetCamera());
|
cmpCinemaManager->UpdateActivePath(deltaRealTime, camera);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#ifndef INCLUDED_CINEMAMANAGER
|
#ifndef INCLUDED_CINEMAMANAGER
|
||||||
#define INCLUDED_CINEMAMANAGER
|
#define INCLUDED_CINEMAMANAGER
|
||||||
|
|
||||||
|
class CCamera;
|
||||||
class RNSpline;
|
class RNSpline;
|
||||||
|
|
||||||
namespace Renderer::Backend { class IDeviceCommandContext; }
|
namespace Renderer::Backend { class IDeviceCommandContext; }
|
||||||
@@ -40,8 +41,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Updates CCinemManager and current path
|
* Updates CCinemManager and current path
|
||||||
* @param deltaRealTime Elapsed real time since the last frame.
|
* @param deltaRealTime Elapsed real time since the last frame.
|
||||||
|
* @param camera To which camera apply the current path is playing.
|
||||||
*/
|
*/
|
||||||
void Update(const float deltaRealTime);
|
void Update(const float deltaRealTime, CCamera& camera);
|
||||||
|
|
||||||
bool GetPathsDrawing() const;
|
bool GetPathsDrawing() const;
|
||||||
void SetPathsDrawing(const bool drawPath);
|
void SetPathsDrawing(const bool drawPath);
|
||||||
|
|||||||
@@ -191,9 +191,9 @@ CObjectManager& CGameView::GetObjectManager()
|
|||||||
return m->ObjectManager;
|
return m->ObjectManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCamera* CGameView::GetCamera()
|
CCamera& CGameView::GetCamera()
|
||||||
{
|
{
|
||||||
return &m->ViewCamera;
|
return m->ViewCamera;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCinemaManager* CGameView::GetCinema()
|
CCinemaManager* CGameView::GetCinema()
|
||||||
@@ -304,7 +304,7 @@ void CGameView::Update(const float deltaRealTime)
|
|||||||
{
|
{
|
||||||
m->MiniMapTexture.Update(deltaRealTime);
|
m->MiniMapTexture.Update(deltaRealTime);
|
||||||
|
|
||||||
m->CinemaManager.Update(deltaRealTime);
|
m->CinemaManager.Update(deltaRealTime, m->ViewCamera);
|
||||||
if (m->CinemaManager.IsPlaying())
|
if (m->CinemaManager.IsPlaying())
|
||||||
return;
|
return;
|
||||||
// If camera movement is being handled by the touch-input system,
|
// If camera movement is being handled by the touch-input system,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
#undef DECLARE_BOOLEAN_SETTING
|
#undef DECLARE_BOOLEAN_SETTING
|
||||||
|
|
||||||
CCamera* GetCamera();
|
CCamera& GetCamera();
|
||||||
CCinemaManager* GetCinema();
|
CCinemaManager* GetCinema();
|
||||||
CObjectManager& GetObjectManager();
|
CObjectManager& GetObjectManager();
|
||||||
|
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ int CMapReader::ApplyData()
|
|||||||
if (pGameView && cmpPlayerManager)
|
if (pGameView && cmpPlayerManager)
|
||||||
{
|
{
|
||||||
// Default to global camera (with constraints)
|
// Default to global camera (with constraints)
|
||||||
pGameView->ResetCameraTarget(pGameView->GetCamera()->GetFocus());
|
pGameView->ResetCameraTarget(pGameView->GetCamera().GetFocus());
|
||||||
|
|
||||||
// TODO: Starting rotation?
|
// TODO: Starting rotation?
|
||||||
CmpPtr<ICmpPlayer> cmpPlayer(*pSimContext, cmpPlayerManager->GetPlayerByID(m_PlayerID));
|
CmpPtr<ICmpPlayer> cmpPlayer(*pSimContext, cmpPlayerManager->GetPlayerByID(m_PlayerID));
|
||||||
@@ -867,10 +867,10 @@ void CXMLReader::ReadCamera(XMBElement parent)
|
|||||||
|
|
||||||
if (m_MapReader.pGameView)
|
if (m_MapReader.pGameView)
|
||||||
{
|
{
|
||||||
m_MapReader.pGameView->GetCamera()->m_Orientation.SetXRotation(declination);
|
m_MapReader.pGameView->GetCamera().m_Orientation.SetXRotation(declination);
|
||||||
m_MapReader.pGameView->GetCamera()->m_Orientation.RotateY(rotation);
|
m_MapReader.pGameView->GetCamera().m_Orientation.RotateY(rotation);
|
||||||
m_MapReader.pGameView->GetCamera()->m_Orientation.Translate(translation);
|
m_MapReader.pGameView->GetCamera().m_Orientation.Translate(translation);
|
||||||
m_MapReader.pGameView->GetCamera()->UpdateFrustum();
|
m_MapReader.pGameView->GetCamera().UpdateFrustum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1631,10 +1631,10 @@ int CMapReader::ParseCamera()
|
|||||||
|
|
||||||
if (pGameView)
|
if (pGameView)
|
||||||
{
|
{
|
||||||
pGameView->GetCamera()->m_Orientation.SetXRotation(declination);
|
pGameView->GetCamera().m_Orientation.SetXRotation(declination);
|
||||||
pGameView->GetCamera()->m_Orientation.RotateY(rotation);
|
pGameView->GetCamera().m_Orientation.RotateY(rotation);
|
||||||
pGameView->GetCamera()->m_Orientation.Translate(translation);
|
pGameView->GetCamera().m_Orientation.Translate(translation);
|
||||||
pGameView->GetCamera()->UpdateFrustum();
|
pGameView->GetCamera().UpdateFrustum();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ CMapWriter::CMapWriter()
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// SaveMap: try to save the current map to the given file
|
// SaveMap: try to save the current map to the given file
|
||||||
void CMapWriter::SaveMap(const VfsPath& pathname, CTerrain* pTerrain, WaterManager* pWaterMan,
|
void CMapWriter::SaveMap(const VfsPath& pathname, CTerrain* pTerrain, WaterManager* pWaterMan,
|
||||||
SkyManager* pSkyMan, CLightEnv* pLightEnv, CCamera* pCamera, CCinemaManager*,
|
SkyManager* pSkyMan, CLightEnv* pLightEnv, const CCamera& camera, CCinemaManager*,
|
||||||
CPostprocManager* pPostproc, CSimulation2* pSimulation2)
|
CPostprocManager* pPostproc, CSimulation2* pSimulation2)
|
||||||
{
|
{
|
||||||
CFilePacker packer(FILE_VERSION, "PSMP");
|
CFilePacker packer(FILE_VERSION, "PSMP");
|
||||||
@@ -96,7 +96,7 @@ void CMapWriter::SaveMap(const VfsPath& pathname, CTerrain* pTerrain, WaterManag
|
|||||||
}
|
}
|
||||||
|
|
||||||
VfsPath pathnameXML = pathname.ChangeExtension(L".xml");
|
VfsPath pathnameXML = pathname.ChangeExtension(L".xml");
|
||||||
WriteXML(pathnameXML, pWaterMan, pSkyMan, pLightEnv, pCamera, pPostproc, pSimulation2);
|
WriteXML(pathnameXML, pWaterMan, pSkyMan, pLightEnv, camera, pPostproc, pSimulation2);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -204,7 +204,7 @@ void CMapWriter::PackTerrain(CFilePacker& packer, CTerrain* pTerrain)
|
|||||||
|
|
||||||
void CMapWriter::WriteXML(const VfsPath& filename,
|
void CMapWriter::WriteXML(const VfsPath& filename,
|
||||||
WaterManager* pWaterMan, SkyManager* pSkyMan,
|
WaterManager* pWaterMan, SkyManager* pSkyMan,
|
||||||
CLightEnv* pLightEnv, CCamera* pCamera,
|
CLightEnv* pLightEnv, const CCamera& camera,
|
||||||
CPostprocManager* pPostproc,
|
CPostprocManager* pPostproc,
|
||||||
CSimulation2* pSimulation2)
|
CSimulation2* pSimulation2)
|
||||||
{
|
{
|
||||||
@@ -299,13 +299,13 @@ void CMapWriter::WriteXML(const VfsPath& filename,
|
|||||||
XMLWriter_Element cameraTag(xmlMapFile, "Camera");
|
XMLWriter_Element cameraTag(xmlMapFile, "Camera");
|
||||||
{
|
{
|
||||||
XMLWriter_Element positionTag(xmlMapFile, "Position");
|
XMLWriter_Element positionTag(xmlMapFile, "Position");
|
||||||
CVector3D pos = pCamera->GetOrientation().GetTranslation();
|
const CVector3D pos{camera.GetOrientation().GetTranslation()};
|
||||||
positionTag.Attribute("x", pos.X);
|
positionTag.Attribute("x", pos.X);
|
||||||
positionTag.Attribute("y", pos.Y);
|
positionTag.Attribute("y", pos.Y);
|
||||||
positionTag.Attribute("z", pos.Z);
|
positionTag.Attribute("z", pos.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector3D in = pCamera->GetOrientation().GetIn();
|
const CVector3D in{camera.GetOrientation().GetIn()};
|
||||||
// Convert to spherical coordinates
|
// Convert to spherical coordinates
|
||||||
float rotation = atan2(in.X, in.Z);
|
float rotation = atan2(in.X, in.Z);
|
||||||
float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - std::numbers::pi_v<float> / 2.f;
|
float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - std::numbers::pi_v<float> / 2.f;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
// SaveMap: try to save the current map to the given file
|
// SaveMap: try to save the current map to the given file
|
||||||
void SaveMap(const VfsPath& pathname, CTerrain* pTerr,
|
void SaveMap(const VfsPath& pathname, CTerrain* pTerr,
|
||||||
WaterManager* pWaterMan, SkyManager* pSkyMan,
|
WaterManager* pWaterMan, SkyManager* pSkyMan,
|
||||||
CLightEnv* pLightEnv, CCamera* pCamera,
|
CLightEnv* pLightEnv, const CCamera& camera,
|
||||||
CCinemaManager* pCinema, CPostprocManager* pPostproc,
|
CCinemaManager* pCinema, CPostprocManager* pPostproc,
|
||||||
CSimulation2* pSimulation2);
|
CSimulation2* pSimulation2);
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ private:
|
|||||||
|
|
||||||
// WriteXML: output some other data (entities, etc) in XML format
|
// WriteXML: output some other data (entities, etc) in XML format
|
||||||
void WriteXML(const VfsPath& pathname, WaterManager* pWaterMan,
|
void WriteXML(const VfsPath& pathname, WaterManager* pWaterMan,
|
||||||
SkyManager* pSkyMan, CLightEnv* pLightEnv, CCamera* pCamera,
|
SkyManager* pSkyMan, CLightEnv* pLightEnv, const CCamera& camera,
|
||||||
CPostprocManager* pPostproc,
|
CPostprocManager* pPostproc,
|
||||||
CSimulation2* pSimulation2);
|
CSimulation2* pSimulation2);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ entity_id_t GetFollowedEntity()
|
|||||||
|
|
||||||
CFixedVector3D GetTerrainAtScreenPoint(int x, int y)
|
CFixedVector3D GetTerrainAtScreenPoint(int x, int y)
|
||||||
{
|
{
|
||||||
CVector3D pos = g_Game->GetView()->GetCamera()->GetWorldCoordinates(x, y, true);
|
CVector3D pos = g_Game->GetView()->GetCamera().GetWorldCoordinates(x, y, true);
|
||||||
return CFixedVector3D(fixed::FromFloat(pos.X), fixed::FromFloat(pos.Y), fixed::FromFloat(pos.Z));
|
return CFixedVector3D(fixed::FromFloat(pos.X), fixed::FromFloat(pos.Y), fixed::FromFloat(pos.Z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ void CMiniMap::SetCameraPositionFromMousePosition()
|
|||||||
|
|
||||||
float CMiniMap::GetAngle() const
|
float CMiniMap::GetAngle() const
|
||||||
{
|
{
|
||||||
CVector3D cameraIn = g_Game->GetView()->GetCamera()->GetOrientation().GetIn();
|
CVector3D cameraIn = g_Game->GetView()->GetCamera().GetOrientation().GetIn();
|
||||||
return -atan2(cameraIn.X, cameraIn.Z);
|
return -atan2(cameraIn.X, cameraIn.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,12 +288,12 @@ void CMiniMap::DrawViewRect(CCanvas2D& canvas) const
|
|||||||
// Use the water height as a fixed base height, which should be the lowest we can go
|
// Use the water height as a fixed base height, which should be the lowest we can go
|
||||||
const float sampleHeight = g_Renderer.GetSceneRenderer().GetWaterManager().m_WaterHeight;
|
const float sampleHeight = g_Renderer.GetSceneRenderer().GetWaterManager().m_WaterHeight;
|
||||||
|
|
||||||
const CCamera* camera = g_Game->GetView()->GetCamera();
|
const CCamera& camera{g_Game->GetView()->GetCamera()};
|
||||||
const std::array<CVector3D, 4> hitPoints = {
|
const std::array<CVector3D, 4> hitPoints = {
|
||||||
camera->GetWorldCoordinates(0, g_Renderer.GetHeight(), sampleHeight),
|
camera.GetWorldCoordinates(0, g_Renderer.GetHeight(), sampleHeight),
|
||||||
camera->GetWorldCoordinates(g_Renderer.GetWidth(), g_Renderer.GetHeight(), sampleHeight),
|
camera.GetWorldCoordinates(g_Renderer.GetWidth(), g_Renderer.GetHeight(), sampleHeight),
|
||||||
camera->GetWorldCoordinates(g_Renderer.GetWidth(), 0, sampleHeight),
|
camera.GetWorldCoordinates(g_Renderer.GetWidth(), 0, sampleHeight),
|
||||||
camera->GetWorldCoordinates(0, 0, sampleHeight)
|
camera.GetWorldCoordinates(0, 0, sampleHeight)
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<CVector3D> worldSpaceLines;
|
std::vector<CVector3D> worldSpaceLines;
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ void CTouchInput::OnFingerMotion(int id, int x, int y)
|
|||||||
{
|
{
|
||||||
m_State = STATE_PANNING;
|
m_State = STATE_PANNING;
|
||||||
|
|
||||||
const 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_PanFocus = camera.GetWorldCoordinates(m_FirstTouchPos.X, m_FirstTouchPos.Y, true);
|
||||||
m_PanDist = (m_PanFocus - camera.GetOrientation().GetTranslation()).Y;
|
m_PanDist = (m_PanFocus - camera.GetOrientation().GetTranslation()).Y;
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ void CTouchInput::OnFingerMotion(int id, int x, int y)
|
|||||||
|
|
||||||
if (m_State == STATE_PANNING && id == 0)
|
if (m_State == STATE_PANNING && id == 0)
|
||||||
{
|
{
|
||||||
CCamera& camera = *(g_Game->GetView()->GetCamera());
|
CCamera& camera{g_Game->GetView()->GetCamera()};
|
||||||
auto [origin, dir] = camera.BuildCameraRay(x, y);
|
auto [origin, dir] = camera.BuildCameraRay(x, y);
|
||||||
dir *= m_PanDist / dir.Y;
|
dir *= m_PanDist / dir.Y;
|
||||||
camera.GetOrientation().Translate(m_PanFocus - dir - origin);
|
camera.GetOrientation().Translate(m_PanFocus - dir - origin);
|
||||||
@@ -154,7 +154,7 @@ void CTouchInput::OnFingerMotion(int id, int x, int y)
|
|||||||
float newDist = (m_Pos[id] - m_Pos[1 - id]).Length();
|
float newDist = (m_Pos[id] - m_Pos[1 - id]).Length();
|
||||||
float zoomDist = (newDist - oldDist) * -0.005f * m_PanDist;
|
float zoomDist = (newDist - oldDist) * -0.005f * m_PanDist;
|
||||||
|
|
||||||
CCamera& camera = *(g_Game->GetView()->GetCamera());
|
CCamera& camera{g_Game->GetView()->GetCamera()};
|
||||||
CVector3D dir{camera.BuildCameraRay(m_Pos[0].X, m_Pos[0].Y).direction};
|
CVector3D dir{camera.BuildCameraRay(m_Pos[0].X, m_Pos[0].Y).direction};
|
||||||
dir *= zoomDist;
|
dir *= zoomDist;
|
||||||
camera.GetOrientation().Translate(dir);
|
camera.GetOrientation().Translate(dir);
|
||||||
|
|||||||
@@ -1380,7 +1380,7 @@ void CPatchRData::RenderSides(
|
|||||||
void CPatchRData::RenderPriorities(CTextRenderer& textRenderer)
|
void CPatchRData::RenderPriorities(CTextRenderer& textRenderer)
|
||||||
{
|
{
|
||||||
CTerrain* terrain = m_Patch->m_Parent;
|
CTerrain* terrain = m_Patch->m_Parent;
|
||||||
const CCamera& camera = *(g_Game->GetView()->GetCamera());
|
const CCamera& camera{g_Game->GetView()->GetCamera()};
|
||||||
|
|
||||||
for (ssize_t j = 0; j < PATCH_SIZE; ++j)
|
for (ssize_t j = 0; j < PATCH_SIZE; ++j)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -863,7 +863,7 @@ void CRenderer::RenderBigScreenShot(const bool needsPresent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCamera oldCamera = *g_Game->GetView()->GetCamera();
|
const CCamera oldCamera{g_Game->GetView()->GetCamera()};
|
||||||
|
|
||||||
// Resize various things so that the sizes and aspect ratios are correct
|
// Resize various things so that the sizes and aspect ratios are correct
|
||||||
{
|
{
|
||||||
@@ -887,7 +887,7 @@ void CRenderer::RenderBigScreenShot(const bool needsPresent)
|
|||||||
oldCamera.GetFOV(), aspectRatio, oldCamera.GetNearPlane(), oldCamera.GetFarPlane(),
|
oldCamera.GetFOV(), aspectRatio, oldCamera.GetNearPlane(), oldCamera.GetFarPlane(),
|
||||||
tiles, tileX, tileY);
|
tiles, tileX, tileY);
|
||||||
}
|
}
|
||||||
g_Game->GetView()->GetCamera()->SetProjection(projection);
|
g_Game->GetView()->GetCamera().SetProjection(projection);
|
||||||
|
|
||||||
Renderer::Backend::ISwapChain* swapChain{g_VideoMode.GetOrCreateSwapChain()};
|
Renderer::Backend::ISwapChain* swapChain{g_VideoMode.GetOrCreateSwapChain()};
|
||||||
if (!swapChain || !swapChain->IsValid())
|
if (!swapChain || !swapChain->IsValid())
|
||||||
@@ -919,7 +919,7 @@ void CRenderer::RenderBigScreenShot(const bool needsPresent)
|
|||||||
g_Renderer.Resize(g_xres, g_yres);
|
g_Renderer.Resize(g_xres, g_yres);
|
||||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
SViewPort vp = { 0, 0, g_xres, g_yres };
|
||||||
g_Game->GetView()->SetViewport(vp);
|
g_Game->GetView()->SetViewport(vp);
|
||||||
g_Game->GetView()->GetCamera()->SetProjectionFromCamera(oldCamera);
|
g_Game->GetView()->GetCamera().SetProjectionFromCamera(oldCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tex_write(&t, filename) == INFO::OK)
|
if (tex_write(&t, filename) == INFO::OK)
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ public:
|
|||||||
return m_IsPlayingPathQueue;
|
return m_IsPlayingPathQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateActivePath(const float deltaRealTime, CCamera* camera) override
|
void UpdateActivePath(const float deltaRealTime, CCamera& camera) override
|
||||||
{
|
{
|
||||||
if (m_IsPlayingPathQueue)
|
if (m_IsPlayingPathQueue)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public:
|
|||||||
* Send an update to the path currently playing for it to determine the new camera position.
|
* Send an update to the path currently playing for it to determine the new camera position.
|
||||||
* Called every frame.
|
* Called every frame.
|
||||||
*/
|
*/
|
||||||
virtual void UpdateActivePath(const float deltaRealTime, CCamera* camera) = 0;
|
virtual void UpdateActivePath(const float deltaRealTime, CCamera& camera) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the path currently playing, if any.
|
* Get the name of the path currently playing, if any.
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ void CCinemaPath::SetTimescale(fixed scale)
|
|||||||
m_Timescale = scale;
|
m_Timescale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera* camera) const
|
void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera& camera) const
|
||||||
{
|
{
|
||||||
t = (this->*DistModePtr)(t);
|
t = (this->*DistModePtr)(t);
|
||||||
|
|
||||||
@@ -122,9 +122,9 @@ void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRota
|
|||||||
if (m_LookAtTarget)
|
if (m_LookAtTarget)
|
||||||
{
|
{
|
||||||
if (m_TimeElapsed <= m_TargetSpline.MaxDistance.ToFloat())
|
if (m_TimeElapsed <= m_TargetSpline.MaxDistance.ToFloat())
|
||||||
camera->LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.MaxDistance.ToFloat()), CVector3D(0, 1, 0));
|
camera.LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.MaxDistance.ToFloat()), CVector3D(0, 1, 0));
|
||||||
else
|
else
|
||||||
camera->LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
|
camera.LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -134,11 +134,11 @@ void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRota
|
|||||||
end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
|
end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
|
||||||
start.Slerp(start, end, nodet);
|
start.Slerp(start, end, nodet);
|
||||||
|
|
||||||
camera->m_Orientation.SetIdentity();
|
camera.m_Orientation.SetIdentity();
|
||||||
camera->m_Orientation.Rotate(start);
|
camera.m_Orientation.Rotate(start);
|
||||||
camera->m_Orientation.Translate(pos);
|
camera.m_Orientation.Translate(pos);
|
||||||
}
|
}
|
||||||
camera->UpdateFrustum();
|
camera.UpdateFrustum();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distortion mode functions
|
// Distortion mode functions
|
||||||
@@ -236,7 +236,7 @@ bool CCinemaPath::Validate()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCinemaPath::Play(const float deltaRealTime, CCamera* camera)
|
bool CCinemaPath::Play(const float deltaRealTime, CCamera& camera)
|
||||||
{
|
{
|
||||||
m_TimeElapsed += m_Timescale.ToFloat() * deltaRealTime;
|
m_TimeElapsed += m_Timescale.ToFloat() * deltaRealTime;
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline);
|
CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline);
|
||||||
|
|
||||||
// Sets camera position to calculated point on spline
|
// Sets camera position to calculated point on spline
|
||||||
void MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera* camera) const;
|
void MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera& camera) const;
|
||||||
|
|
||||||
// Distortion mode functions-change how ratio is passed to distortion style functions
|
// Distortion mode functions-change how ratio is passed to distortion style functions
|
||||||
float EaseIn(float t) const;
|
float EaseIn(float t) const;
|
||||||
@@ -108,7 +108,7 @@ public:
|
|||||||
* @param deltaRealTime Elapsed real time since the last frame.
|
* @param deltaRealTime Elapsed real time since the last frame.
|
||||||
* @param camera An affected camera
|
* @param camera An affected camera
|
||||||
*/
|
*/
|
||||||
bool Play(const float deltaRealTime, CCamera* camera);
|
bool Play(const float deltaRealTime, CCamera& camera);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the path
|
* Validate the path
|
||||||
|
|||||||
@@ -108,22 +108,22 @@ void DumpSimState()
|
|||||||
|
|
||||||
entity_id_t PickEntityAtPoint(int x, int y)
|
entity_id_t PickEntityAtPoint(int x, int y)
|
||||||
{
|
{
|
||||||
return EntitySelection::PickEntityAtPoint(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x, y, g_Game->GetViewedPlayerID(), false);
|
return EntitySelection::PickEntityAtPoint(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), x, y, g_Game->GetViewedPlayerID(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<entity_id_t> PickPlayerEntitiesInRect(int x0, int y0, int x1, int y1, int player)
|
std::vector<entity_id_t> PickPlayerEntitiesInRect(int x0, int y0, int x1, int y1, int player)
|
||||||
{
|
{
|
||||||
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x0, y0, x1, y1, player, false);
|
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), x0, y0, x1, y1, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<entity_id_t> PickPlayerEntitiesOnScreen(int player)
|
std::vector<entity_id_t> PickPlayerEntitiesOnScreen(int player)
|
||||||
{
|
{
|
||||||
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, player, false);
|
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<entity_id_t> PickNonGaiaEntitiesOnScreen()
|
std::vector<entity_id_t> PickNonGaiaEntitiesOnScreen()
|
||||||
{
|
{
|
||||||
return EntitySelection::PickNonGaiaEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, false);
|
return EntitySelection::PickNonGaiaEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen()
|
std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen()
|
||||||
@@ -136,7 +136,7 @@ std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen()
|
|||||||
return cmpObstruction->GetObstructionType() == ICmpObstruction::STATIC;
|
return cmpObstruction->GetObstructionType() == ICmpObstruction::STATIC;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return EntitySelection::GetEntitiesWithComponentInRect<StaticObstructionFilter>(*g_Game->GetSimulation2(), IID_Obstruction, *g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres);
|
return EntitySelection::GetEntitiesWithComponentInRect<StaticObstructionFilter>(*g_Game->GetSimulation2(), IID_Obstruction, g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const Script::Interface& scriptInterface, entity_pos_t x, entity_pos_t z)
|
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const Script::Interface& scriptInterface, entity_pos_t x, entity_pos_t z)
|
||||||
@@ -209,7 +209,7 @@ JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(const Script::Interface& sc
|
|||||||
|
|
||||||
std::vector<entity_id_t> PickSimilarPlayerEntities(const std::string& templateName, bool includeOffScreen, bool matchRank, bool allowFoundations)
|
std::vector<entity_id_t> PickSimilarPlayerEntities(const std::string& templateName, bool includeOffScreen, bool matchRank, bool allowFoundations)
|
||||||
{
|
{
|
||||||
return EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), templateName, g_Game->GetViewedPlayerID(), includeOffScreen, matchRank, false, allowFoundations);
|
return EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), templateName, g_Game->GetViewedPlayerID(), includeOffScreen, matchRank, false, allowFoundations);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value GetAIs(const Script::Interface& scriptInterface)
|
JS::Value GetAIs(const Script::Interface& scriptInterface)
|
||||||
|
|||||||
@@ -150,13 +150,13 @@ float CSoundGroup::RadiansOffCenter([[maybe_unused]] const CVector3D& position,
|
|||||||
#if !CONFIG2_AUDIO
|
#if !CONFIG2_AUDIO
|
||||||
return 0.f;
|
return 0.f;
|
||||||
#else
|
#else
|
||||||
const int screenWidth = g_Game->GetView()->GetCamera()->GetViewPort().m_Width;
|
const int screenWidth = g_Game->GetView()->GetCamera().GetViewPort().m_Width;
|
||||||
const int screenHeight = g_Game->GetView()->GetCamera()->GetViewPort().m_Height;
|
const int screenHeight = g_Game->GetView()->GetCamera().GetViewPort().m_Height;
|
||||||
const float xBufferSize = screenWidth * 0.1f;
|
const float xBufferSize = screenWidth * 0.1f;
|
||||||
const float yBufferSize = 15.f;
|
const float yBufferSize = 15.f;
|
||||||
const float radianCap = m_MaxStereoAngle;
|
const float radianCap = m_MaxStereoAngle;
|
||||||
|
|
||||||
const CVector2D screenPos{g_Game->GetView()->GetCamera()->GetScreenCoordinates(position)};
|
const CVector2D screenPos{g_Game->GetView()->GetCamera().GetScreenCoordinates(position)};
|
||||||
|
|
||||||
onScreen = true;
|
onScreen = true;
|
||||||
float answer = 0.f;
|
float answer = 0.f;
|
||||||
@@ -225,7 +225,7 @@ void CSoundGroup::UploadPropertiesAndPlay([[maybe_unused]] size_t index,
|
|||||||
|
|
||||||
if (!TestFlag(eOmnipresent))
|
if (!TestFlag(eOmnipresent))
|
||||||
{
|
{
|
||||||
CVector3D origin = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation();
|
CVector3D origin = g_Game->GetView()->GetCamera().GetOrientation().GetTranslation();
|
||||||
float itemDist = (position - origin).Length();
|
float itemDist = (position - origin).Length();
|
||||||
|
|
||||||
if (TestFlag(eDistanceless))
|
if (TestFlag(eDistanceless))
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ MESSAGEHANDLER(CameraReset)
|
|||||||
if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying())
|
if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus();
|
CVector3D focus = g_Game->GetView()->GetCamera().GetFocus();
|
||||||
|
|
||||||
CVector3D target;
|
CVector3D target;
|
||||||
if (!g_Game->GetWorld()->GetTerrain().IsOnMap(focus.X, focus.Z))
|
if (!g_Game->GetWorld()->GetTerrain().IsOnMap(focus.X, focus.Z))
|
||||||
@@ -95,7 +95,7 @@ MESSAGEHANDLER(Scroll)
|
|||||||
static CVector3D targetPos;
|
static CVector3D targetPos;
|
||||||
static float targetDistance = 0.f;
|
static float targetDistance = 0.f;
|
||||||
|
|
||||||
CMatrix3D& camera = g_Game->GetView()->GetCamera()->m_Orientation;
|
CMatrix3D& camera = g_Game->GetView()->GetCamera().m_Orientation;
|
||||||
|
|
||||||
static CVector3D lastCameraPos = camera.GetTranslation();
|
static CVector3D lastCameraPos = camera.GetTranslation();
|
||||||
|
|
||||||
@@ -124,10 +124,10 @@ MESSAGEHANDLER(Scroll)
|
|||||||
{
|
{
|
||||||
float x, y;
|
float x, y;
|
||||||
msg->pos->GetScreenSpace(x, y);
|
msg->pos->GetScreenSpace(x, y);
|
||||||
auto [origin, dir] = g_Game->GetView()->GetCamera()->BuildCameraRay((int)x, (int)y);
|
auto [origin, dir] = g_Game->GetView()->GetCamera().BuildCameraRay((int)x, (int)y);
|
||||||
dir *= targetDistance;
|
dir *= targetDistance;
|
||||||
camera.Translate(targetPos - dir - origin);
|
camera.Translate(targetPos - dir - origin);
|
||||||
g_Game->GetView()->GetCamera()->UpdateFrustum();
|
g_Game->GetView()->GetCamera().UpdateFrustum();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -152,7 +152,7 @@ MESSAGEHANDLER(RotateAround)
|
|||||||
static CVector3D focusPos;
|
static CVector3D focusPos;
|
||||||
static float lastX = 0.f, lastY = 0.f;
|
static float lastX = 0.f, lastY = 0.f;
|
||||||
|
|
||||||
CMatrix3D& camera = g_Game->GetView()->GetCamera()->m_Orientation;
|
CMatrix3D& camera = g_Game->GetView()->GetCamera().m_Orientation;
|
||||||
|
|
||||||
if (msg->type == eRotateAroundType::FROM)
|
if (msg->type == eRotateAroundType::FROM)
|
||||||
{
|
{
|
||||||
@@ -186,7 +186,7 @@ MESSAGEHANDLER(RotateAround)
|
|||||||
camera._21 = 0.f; // (_21 = Y component returned by GetLeft())
|
camera._21 = 0.f; // (_21 = Y component returned by GetLeft())
|
||||||
|
|
||||||
camera.Translate(focusPos + offset);
|
camera.Translate(focusPos + offset);
|
||||||
g_Game->GetView()->GetCamera()->UpdateFrustum();
|
g_Game->GetView()->GetCamera().UpdateFrustum();
|
||||||
|
|
||||||
lastX = x;
|
lastX = x;
|
||||||
lastY = y;
|
lastY = y;
|
||||||
@@ -232,14 +232,14 @@ QUERYHANDLER(GetView)
|
|||||||
if (!g_Game)
|
if (!g_Game)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus();
|
CVector3D focus = g_Game->GetView()->GetCamera().GetFocus();
|
||||||
sCameraInfo info;
|
sCameraInfo info;
|
||||||
|
|
||||||
info.pX = focus.X;
|
info.pX = focus.X;
|
||||||
info.pY = focus.Y;
|
info.pY = focus.Y;
|
||||||
info.pZ = focus.Z;
|
info.pZ = focus.Z;
|
||||||
|
|
||||||
CQuaternion quatRot = g_Game->GetView()->GetCamera()->GetOrientation().GetRotation();
|
CQuaternion quatRot = g_Game->GetView()->GetCamera().GetOrientation().GetRotation();
|
||||||
quatRot.Normalize();
|
quatRot.Normalize();
|
||||||
CVector3D rotation = quatRot.ToEulerAngles();
|
CVector3D rotation = quatRot.ToEulerAngles();
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ MESSAGEHANDLER(SetView)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CGameView* view = g_Game->GetView();
|
CGameView* view = g_Game->GetView();
|
||||||
view->ResetCameraTarget(view->GetCamera()->GetFocus());
|
view->ResetCameraTarget(view->GetCamera().GetFocus());
|
||||||
|
|
||||||
sCameraInfo cam = msg->info;
|
sCameraInfo cam = msg->info;
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ void SetCurrentPaths(const std::vector<sCinemaPath>& atlasPaths)
|
|||||||
QUERYHANDLER(GetCameraInfo)
|
QUERYHANDLER(GetCameraInfo)
|
||||||
{
|
{
|
||||||
sCameraInfo info;
|
sCameraInfo info;
|
||||||
const CMatrix3D& cameraOrientation = g_Game->GetView()->GetCamera()->GetOrientation();
|
const CMatrix3D& cameraOrientation = g_Game->GetView()->GetCamera().GetOrientation();
|
||||||
|
|
||||||
CQuaternion quatRot = cameraOrientation.GetRotation();
|
CQuaternion quatRot = cameraOrientation.GetRotation();
|
||||||
quatRot.Normalize();
|
quatRot.Normalize();
|
||||||
@@ -214,14 +214,14 @@ BEGIN_COMMAND(AddCinemaPath)
|
|||||||
pathData.m_Mode = L"ease_inout";
|
pathData.m_Mode = L"ease_inout";
|
||||||
pathData.m_Style = L"default";
|
pathData.m_Style = L"default";
|
||||||
|
|
||||||
CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus();
|
CVector3D focus = g_Game->GetView()->GetCamera().GetFocus();
|
||||||
CFixedVector3D target(
|
CFixedVector3D target(
|
||||||
fixed::FromFloat(focus.X),
|
fixed::FromFloat(focus.X),
|
||||||
fixed::FromFloat(focus.Y),
|
fixed::FromFloat(focus.Y),
|
||||||
fixed::FromFloat(focus.Z)
|
fixed::FromFloat(focus.Z)
|
||||||
);
|
);
|
||||||
|
|
||||||
CVector3D camera = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation();
|
CVector3D camera = g_Game->GetView()->GetCamera().GetOrientation().GetTranslation();
|
||||||
CFixedVector3D position(
|
CFixedVector3D position(
|
||||||
fixed::FromFloat(camera.X),
|
fixed::FromFloat(camera.X),
|
||||||
fixed::FromFloat(camera.Y),
|
fixed::FromFloat(camera.Y),
|
||||||
@@ -310,8 +310,8 @@ static CVector3D GetNearestPointToScreenCoords(const CVector3D& base, const CVec
|
|||||||
float delta = (upper - lower) / 3.0;
|
float delta = (upper - lower) / 3.0;
|
||||||
float middle1 = lower + delta, middle2 = lower + 2.0f * delta;
|
float middle1 = lower + delta, middle2 = lower + 2.0f * delta;
|
||||||
CVector3D p1 = base + dir * middle1, p2 = base + dir * middle2;
|
CVector3D p1 = base + dir * middle1, p2 = base + dir * middle2;
|
||||||
const CVector2D s1{g_Game->GetView()->GetCamera()->GetScreenCoordinates(p1)};
|
const CVector2D s1{g_Game->GetView()->GetCamera().GetScreenCoordinates(p1)};
|
||||||
const CVector2D s2{g_Game->GetView()->GetCamera()->GetScreenCoordinates(p2)};
|
const CVector2D s2{g_Game->GetView()->GetCamera().GetScreenCoordinates(p2)};
|
||||||
if ((s1 - screen).Length() < (s2 - screen).Length())
|
if ((s1 - screen).Length() < (s2 - screen).Length())
|
||||||
upper = middle2;
|
upper = middle2;
|
||||||
else
|
else
|
||||||
@@ -351,7 +351,7 @@ BEGIN_COMMAND(AddPathNode)
|
|||||||
TNSpline targetSpline = path.GetTargetSpline();
|
TNSpline targetSpline = path.GetTargetSpline();
|
||||||
TNSpline& spline = msg->node->targetNode ? targetSpline : positionSpline;
|
TNSpline& spline = msg->node->targetNode ? targetSpline : positionSpline;
|
||||||
|
|
||||||
CVector3D focus = g_Game->GetView()->GetCamera()->GetFocus();
|
CVector3D focus = g_Game->GetView()->GetCamera().GetFocus();
|
||||||
CFixedVector3D target(
|
CFixedVector3D target(
|
||||||
fixed::FromFloat(focus.X),
|
fixed::FromFloat(focus.X),
|
||||||
fixed::FromFloat(focus.Y),
|
fixed::FromFloat(focus.Y),
|
||||||
@@ -479,7 +479,7 @@ static bool isPathNodePicked(const TNSpline& spline, const CVector2D& cursor, At
|
|||||||
data.Position.Y.ToFloat(),
|
data.Position.Y.ToFloat(),
|
||||||
data.Position.Z.ToFloat()
|
data.Position.Z.ToFloat()
|
||||||
);
|
);
|
||||||
const CVector2D screenPos{g_Game->GetView()->GetCamera()->GetScreenCoordinates(position)};
|
const CVector2D screenPos{g_Game->GetView()->GetCamera().GetScreenCoordinates(position)};
|
||||||
if ((screenPos - cursor).Length() < MINIMAL_SCREEN_DISTANCE)
|
if ((screenPos - cursor).Length() < MINIMAL_SCREEN_DISTANCE)
|
||||||
{
|
{
|
||||||
node.index = i;
|
node.index = i;
|
||||||
@@ -524,7 +524,7 @@ QUERYHANDLER(PickPathNode)
|
|||||||
static bool isAxisPicked(const CVector3D& base, const CVector3D& direction, float length, const CVector2D& cursor)
|
static bool isAxisPicked(const CVector3D& base, const CVector3D& direction, float length, const CVector2D& cursor)
|
||||||
{
|
{
|
||||||
CVector3D position = GetNearestPointToScreenCoords(base, direction, cursor, 0, length);
|
CVector3D position = GetNearestPointToScreenCoords(base, direction, cursor, 0, length);
|
||||||
const CVector2D screenPos{g_Game->GetView()->GetCamera()->GetScreenCoordinates(position)};
|
const CVector2D screenPos{g_Game->GetView()->GetCamera().GetScreenCoordinates(position)};
|
||||||
return (cursor - screenPos).Length() < MINIMAL_SCREEN_DISTANCE;
|
return (cursor - screenPos).Length() < MINIMAL_SCREEN_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +537,7 @@ QUERYHANDLER(PickAxis)
|
|||||||
const TNSpline& spline = msg->node->targetNode ? path.GetTargetSpline() : path;
|
const TNSpline& spline = msg->node->targetNode ? path.GetTargetSpline() : path;
|
||||||
CFixedVector3D pos = spline.GetAllNodes()[index].Position;
|
CFixedVector3D pos = spline.GetAllNodes()[index].Position;
|
||||||
CVector3D position(pos.X.ToFloat(), pos.Y.ToFloat(), pos.Z.ToFloat());
|
CVector3D position(pos.X.ToFloat(), pos.Y.ToFloat(), pos.Z.ToFloat());
|
||||||
CVector3D camera = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation();
|
CVector3D camera = g_Game->GetView()->GetCamera().GetOrientation().GetTranslation();
|
||||||
float scale = (position - camera).Length() / 10.0;
|
float scale = (position - camera).Length() / 10.0;
|
||||||
|
|
||||||
CVector2D cursor;
|
CVector2D cursor;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -667,7 +667,7 @@ QUERYHANDLER(PickObject)
|
|||||||
|
|
||||||
// Normally this function would be called with a player ID to check LOS,
|
// Normally this function would be called with a player ID to check LOS,
|
||||||
// but in Atlas the entire map is revealed, so just pass INVALID_PLAYER
|
// but in Atlas the entire map is revealed, so just pass INVALID_PLAYER
|
||||||
entity_id_t ent = EntitySelection::PickEntityAtPoint(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x, y, INVALID_PLAYER, msg->selectActors);;
|
entity_id_t ent = EntitySelection::PickEntityAtPoint(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), x, y, INVALID_PLAYER, msg->selectActors);;
|
||||||
|
|
||||||
if (ent == INVALID_ENTITY)
|
if (ent == INVALID_ENTITY)
|
||||||
msg->id = INVALID_ENTITY;
|
msg->id = INVALID_ENTITY;
|
||||||
@@ -687,7 +687,7 @@ QUERYHANDLER(PickObject)
|
|||||||
CFixedVector3D fixed = cmpPosition->GetPosition();
|
CFixedVector3D fixed = cmpPosition->GetPosition();
|
||||||
CVector3D centre = CVector3D(fixed.X.ToFloat(), fixed.Y.ToFloat(), fixed.Z.ToFloat());
|
CVector3D centre = CVector3D(fixed.X.ToFloat(), fixed.Y.ToFloat(), fixed.Z.ToFloat());
|
||||||
|
|
||||||
const CVector2D screenPos{g_Game->GetView()->GetCamera()->GetScreenCoordinates(centre)};
|
const CVector2D screenPos{g_Game->GetView()->GetCamera().GetScreenCoordinates(centre)};
|
||||||
|
|
||||||
msg->offsetx = static_cast<int>(screenPos.X - x);
|
msg->offsetx = static_cast<int>(screenPos.X - x);
|
||||||
msg->offsety = static_cast<int>(screenPos.Y - y);
|
msg->offsety = static_cast<int>(screenPos.Y - y);
|
||||||
@@ -703,7 +703,7 @@ QUERYHANDLER(PickObjectsInRect)
|
|||||||
msg->end->GetScreenSpace(x1, y1);
|
msg->end->GetScreenSpace(x1, y1);
|
||||||
|
|
||||||
// Since owner selections are meaningless in Atlas, use INVALID_PLAYER
|
// Since owner selections are meaningless in Atlas, use INVALID_PLAYER
|
||||||
msg->ids = EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x0, y0, x1, y1, INVALID_PLAYER, msg->selectActors);
|
msg->ids = EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), x0, y0, x1, y1, INVALID_PLAYER, msg->selectActors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -721,7 +721,7 @@ QUERYHANDLER(PickSimilarObjects)
|
|||||||
if (cmpOwnership)
|
if (cmpOwnership)
|
||||||
owner = cmpOwnership->GetOwner();
|
owner = cmpOwnership->GetOwner();
|
||||||
|
|
||||||
msg->ids = EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), templateName, owner, false, true, true, false);
|
msg->ids = EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), g_Game->GetView()->GetCamera(), templateName, owner, false, true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MESSAGEHANDLER(ResetSelectionColor)
|
MESSAGEHANDLER(ResetSelectionColor)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -52,11 +52,11 @@ bool InputProcessor::ProcessInput(GameLoopState* state)
|
|||||||
if (! g_Game)
|
if (! g_Game)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CCamera* camera = g_Game->GetView()->GetCamera();
|
CCamera& camera{g_Game->GetView()->GetCamera()};
|
||||||
|
|
||||||
CVector3D leftwards = camera->m_Orientation.GetLeft();
|
CVector3D leftwards = camera.m_Orientation.GetLeft();
|
||||||
|
|
||||||
CVector3D inwards = camera->m_Orientation.GetIn();
|
CVector3D inwards = camera.m_Orientation.GetIn();
|
||||||
|
|
||||||
// Calculate a vector pointing forwards, parallel to the ground
|
// Calculate a vector pointing forwards, parallel to the ground
|
||||||
CVector3D forwards = inwards;
|
CVector3D forwards = inwards;
|
||||||
@@ -72,44 +72,44 @@ bool InputProcessor::ProcessInput(GameLoopState* state)
|
|||||||
|
|
||||||
if (state->input.scrollSpeed[0] != 0.0f)
|
if (state->input.scrollSpeed[0] != 0.0f)
|
||||||
{
|
{
|
||||||
camera->m_Orientation.Translate(forwards * (input.scrollSpeed[0] * state->realFrameLength));
|
camera.m_Orientation.Translate(forwards * (input.scrollSpeed[0] * state->realFrameLength));
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->input.scrollSpeed[1] != 0.0f)
|
if (state->input.scrollSpeed[1] != 0.0f)
|
||||||
{
|
{
|
||||||
camera->m_Orientation.Translate(forwards * (-input.scrollSpeed[1] * state->realFrameLength));
|
camera.m_Orientation.Translate(forwards * (-input.scrollSpeed[1] * state->realFrameLength));
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->input.scrollSpeed[2] != 0.0f)
|
if (state->input.scrollSpeed[2] != 0.0f)
|
||||||
{
|
{
|
||||||
camera->m_Orientation.Translate(leftwards * (input.scrollSpeed[2] * state->realFrameLength));
|
camera.m_Orientation.Translate(leftwards * (input.scrollSpeed[2] * state->realFrameLength));
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->input.scrollSpeed[3] != 0.0f)
|
if (state->input.scrollSpeed[3] != 0.0f)
|
||||||
{
|
{
|
||||||
camera->m_Orientation.Translate(leftwards * (-input.scrollSpeed[3] * state->realFrameLength));
|
camera.m_Orientation.Translate(leftwards * (-input.scrollSpeed[3] * state->realFrameLength));
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->input.scrollSpeed[4] != 0.0f)
|
if (state->input.scrollSpeed[4] != 0.0f)
|
||||||
{
|
{
|
||||||
Rotate(*camera, input.scrollSpeed[4] * state->realFrameLength * g_ViewRotateScale);
|
Rotate(camera, input.scrollSpeed[4] * state->realFrameLength * g_ViewRotateScale);
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->input.scrollSpeed[5] != 0.0f)
|
if (state->input.scrollSpeed[5] != 0.0f)
|
||||||
{
|
{
|
||||||
Rotate(*camera, -input.scrollSpeed[5] * state->realFrameLength * g_ViewRotateScale);
|
Rotate(camera, -input.scrollSpeed[5] * state->realFrameLength * g_ViewRotateScale);
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->input.zoomDelta != 0.0f)
|
if (state->input.zoomDelta != 0.0f)
|
||||||
{
|
{
|
||||||
float zoom_proportion = powf(g_ViewZoomSmoothness, state->realFrameLength);
|
float zoom_proportion = powf(g_ViewZoomSmoothness, state->realFrameLength);
|
||||||
camera->m_Orientation.Translate(inwards * (input.zoomDelta * (1.0f - zoom_proportion)));
|
camera.m_Orientation.Translate(inwards * (input.zoomDelta * (1.0f - zoom_proportion)));
|
||||||
input.zoomDelta *= zoom_proportion;
|
input.zoomDelta *= zoom_proportion;
|
||||||
|
|
||||||
if (fabsf(input.zoomDelta) < 0.1f)
|
if (fabsf(input.zoomDelta) < 0.1f)
|
||||||
@@ -119,7 +119,7 @@ bool InputProcessor::ProcessInput(GameLoopState* state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (moved)
|
if (moved)
|
||||||
camera->UpdateFrustum();
|
camera.UpdateFrustum();
|
||||||
|
|
||||||
return moved;
|
return moved;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -36,7 +36,7 @@ CVector3D AtlasMessage::Position::GetWorldSpace(bool floating) const
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return g_Game->GetView()->GetCamera()->GetWorldCoordinates(type1.x, type1.y, floating);
|
return g_Game->GetView()->GetCamera().GetWorldCoordinates(type1.x, type1.y, floating);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@@ -55,7 +55,7 @@ CVector3D AtlasMessage::Position::GetWorldSpace(float h, bool floating) const
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return g_Game->GetView()->GetCamera()->GetWorldCoordinates(type1.x, type1.y, h);
|
return g_Game->GetView()->GetCamera().GetWorldCoordinates(type1.x, type1.y, h);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return GetWorldSpace(floating);
|
return GetWorldSpace(floating);
|
||||||
@@ -80,7 +80,7 @@ void AtlasMessage::Position::GetScreenSpace(float& x, float& y) const
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
const CVector2D screenPos{g_Game->GetView()->GetCamera()->GetScreenCoordinates(
|
const CVector2D screenPos{g_Game->GetView()->GetCamera().GetScreenCoordinates(
|
||||||
CVector3D{type0.x, type0.y, type0.x})};
|
CVector3D{type0.x, type0.y, type0.x})};
|
||||||
x = screenPos.X;
|
x = screenPos.X;
|
||||||
y = screenPos.Y;
|
y = screenPos.Y;
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ void AtlasViewGame::Update(float realFrameLength)
|
|||||||
|
|
||||||
// Cinematic motion should be independent of simulation update, so we can
|
// Cinematic motion should be independent of simulation update, so we can
|
||||||
// preview the cinematics by themselves
|
// preview the cinematics by themselves
|
||||||
g_Game->GetView()->GetCinema()->Update(realFrameLength);
|
g_Game->GetView()->GetCinema()->Update(realFrameLength, g_Game->GetView()->GetCamera());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasViewGame::Render()
|
void AtlasViewGame::Render()
|
||||||
@@ -241,7 +241,7 @@ void AtlasViewGame::Render()
|
|||||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
SViewPort vp = { 0, 0, g_xres, g_yres };
|
||||||
CCamera& camera = GetCamera();
|
CCamera& camera = GetCamera();
|
||||||
camera.SetViewPort(vp);
|
camera.SetViewPort(vp);
|
||||||
camera.SetProjectionFromCamera(*g_Game->GetView()->GetCamera());
|
camera.SetProjectionFromCamera(g_Game->GetView()->GetCamera());
|
||||||
camera.UpdateFrustum();
|
camera.UpdateFrustum();
|
||||||
|
|
||||||
g_Renderer.RenderFrame(false);
|
g_Renderer.RenderFrame(false);
|
||||||
@@ -337,7 +337,7 @@ void AtlasViewGame::SetParam(const std::wstring& name, const std::wstring& value
|
|||||||
|
|
||||||
CCamera& AtlasViewGame::GetCamera()
|
CCamera& AtlasViewGame::GetCamera()
|
||||||
{
|
{
|
||||||
return *g_Game->GetView()->GetCamera();
|
return g_Game->GetView()->GetCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtlasViewGame::GetSmoothFramerate() const
|
bool AtlasViewGame::GetSmoothFramerate() const
|
||||||
|
|||||||
Reference in New Issue
Block a user