# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "View.h"
|
|
|
|
|
|
|
|
#include "ActorViewer.h"
|
|
|
|
#include "GameLoop.h"
|
2006-09-26 03:44:20 +02:00
|
|
|
#include "Messages.h"
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
#include "graphics/CinemaTrack.h"
|
2006-09-30 17:46:40 +02:00
|
|
|
#include "graphics/GameView.h"
|
2007-01-17 04:25:20 +01:00
|
|
|
#include "graphics/Model.h"
|
|
|
|
#include "graphics/ObjectBase.h"
|
2007-01-24 21:17:28 +01:00
|
|
|
#include "graphics/ObjectEntry.h"
|
2006-09-26 03:44:20 +02:00
|
|
|
#include "graphics/SColor.h"
|
2007-01-17 04:25:20 +01:00
|
|
|
#include "graphics/Unit.h"
|
2006-09-27 18:54:23 +02:00
|
|
|
#include "graphics/UnitManager.h"
|
2007-01-24 21:17:28 +01:00
|
|
|
#include "lib/timer.h"
|
|
|
|
#include "maths/MathUtil.h"
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
#include "ps/Game.h"
|
|
|
|
#include "ps/GameSetup/GameSetup.h"
|
2007-01-17 04:25:20 +01:00
|
|
|
#include "ps/Player.h"
|
|
|
|
#include "renderer/Renderer.h"
|
|
|
|
#include "simulation/Entity.h"
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
#include "simulation/EntityManager.h"
|
2007-01-17 04:25:20 +01:00
|
|
|
#include "simulation/EntityTemplate.h"
|
|
|
|
#include "simulation/EntityTemplateCollection.h"
|
2007-02-09 18:04:55 +01:00
|
|
|
#include "simulation/Projectile.h"
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
#include "simulation/Simulation.h"
|
|
|
|
|
|
|
|
extern void (*Atlas_GLSwapBuffers)(void* context);
|
|
|
|
|
|
|
|
extern int g_xres, g_yres;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-09-26 03:44:20 +02:00
|
|
|
void View::SetParam(const std::wstring& UNUSED(name), bool UNUSED(value))
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
{
|
2006-09-26 03:44:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void View::SetParam(const std::wstring& UNUSED(name), const AtlasMessage::Colour& UNUSED(value))
|
|
|
|
{
|
|
|
|
}
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ViewActor::ViewActor()
|
|
|
|
: m_SpeedMultiplier(1.f), m_ActorViewer(new ActorViewer())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewActor::~ViewActor()
|
|
|
|
{
|
|
|
|
delete m_ActorViewer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewActor::Update(float frameLength)
|
|
|
|
{
|
|
|
|
m_ActorViewer->Update(frameLength * m_SpeedMultiplier);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewActor::Render()
|
|
|
|
{
|
|
|
|
SViewPort vp = { 0, 0, g_xres, g_yres };
|
|
|
|
CCamera& camera = GetCamera();
|
|
|
|
camera.SetViewPort(&vp);
|
|
|
|
camera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);
|
|
|
|
camera.UpdateFrustum();
|
|
|
|
|
|
|
|
m_ActorViewer->Render();
|
2007-01-02 19:11:00 +01:00
|
|
|
Atlas_GLSwapBuffers((void*)g_GameLoop->glCanvas);
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CCamera& ViewActor::GetCamera()
|
|
|
|
{
|
|
|
|
return m_Camera;
|
|
|
|
}
|
|
|
|
|
2006-09-27 18:54:23 +02:00
|
|
|
CUnit* ViewActor::GetUnit(AtlasMessage::ObjectID UNUSED(id))
|
|
|
|
{
|
|
|
|
return m_ActorViewer->GetUnit();
|
|
|
|
}
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
bool ViewActor::WantsHighFramerate()
|
|
|
|
{
|
2006-09-26 03:44:20 +02:00
|
|
|
if (m_SpeedMultiplier != 0.f && m_ActorViewer->HasAnimation())
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewActor::SetSpeedMultiplier(float speed)
|
|
|
|
{
|
|
|
|
m_SpeedMultiplier = speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
ActorViewer& ViewActor::GetActorViewer()
|
|
|
|
{
|
|
|
|
return *m_ActorViewer;
|
|
|
|
}
|
|
|
|
|
2006-09-26 03:44:20 +02:00
|
|
|
void ViewActor::SetParam(const std::wstring& name, bool value)
|
|
|
|
{
|
|
|
|
if (name == L"wireframe")
|
|
|
|
g_Renderer.SetModelRenderMode(value ? WIREFRAME : SOLID);
|
|
|
|
else if (name == L"walk")
|
|
|
|
m_ActorViewer->SetWalkEnabled(value);
|
2006-09-28 22:41:12 +02:00
|
|
|
else if (name == L"ground")
|
|
|
|
m_ActorViewer->SetGroundEnabled(value);
|
|
|
|
else if (name == L"shadows")
|
|
|
|
m_ActorViewer->SetShadowsEnabled(value);
|
|
|
|
else if (name == L"stats")
|
|
|
|
m_ActorViewer->SetStatsEnabled(value);
|
2006-09-26 03:44:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewActor::SetParam(const std::wstring& name, const AtlasMessage::Colour& value)
|
|
|
|
{
|
|
|
|
if (name == L"background")
|
|
|
|
{
|
|
|
|
m_ActorViewer->SetBackgroundColour(SColor4ub(value.r, value.g, value.b, 255));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
namespace AtlasMessage
|
|
|
|
{
|
|
|
|
extern void AtlasRenderSelection();
|
|
|
|
}
|
|
|
|
|
2007-01-17 04:25:20 +01:00
|
|
|
struct SimState
|
|
|
|
{
|
|
|
|
struct Entity
|
|
|
|
{
|
|
|
|
CStrW templateName;
|
|
|
|
int unitID;
|
|
|
|
std::set<CStr> selections;
|
|
|
|
int playerID;
|
|
|
|
CVector3D position;
|
|
|
|
float angle;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Nonentity
|
|
|
|
{
|
|
|
|
CStrW actorName;
|
|
|
|
int unitID;
|
|
|
|
std::set<CStr> selections;
|
|
|
|
CVector3D position;
|
|
|
|
float angle;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool onlyEntities;
|
|
|
|
std::vector<Entity> entities;
|
|
|
|
std::vector<Nonentity> nonentities;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T, typename S>
|
|
|
|
static void delete_pair_2nd(std::pair<T,S> v)
|
|
|
|
{
|
|
|
|
delete v.second;
|
|
|
|
}
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
ViewGame::ViewGame()
|
2007-01-17 04:25:20 +01:00
|
|
|
: m_SpeedMultiplier(0.f)
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
{
|
|
|
|
debug_assert(g_Game);
|
|
|
|
}
|
|
|
|
|
2007-01-17 04:25:20 +01:00
|
|
|
ViewGame::~ViewGame()
|
|
|
|
{
|
|
|
|
std::for_each(m_SavedStates.begin(), m_SavedStates.end(), delete_pair_2nd<std::wstring, SimState*>);
|
|
|
|
}
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
void ViewGame::Update(float frameLength)
|
|
|
|
{
|
2007-01-24 21:17:28 +01:00
|
|
|
float actualFrameLength = frameLength * m_SpeedMultiplier;
|
|
|
|
|
2007-01-17 04:25:20 +01:00
|
|
|
if (m_SpeedMultiplier == 0.f)
|
|
|
|
{
|
|
|
|
// Update unit interpolation
|
2007-01-24 21:17:28 +01:00
|
|
|
g_Game->GetSimulation()->Interpolate(0.0);
|
2007-01-17 04:25:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Update the whole world
|
2007-01-24 21:17:28 +01:00
|
|
|
// (Tell the game update not to interpolate graphics - we'll do that
|
|
|
|
// ourselves)
|
|
|
|
bool ok = g_Game->Update(actualFrameLength, false);
|
|
|
|
if (! ok)
|
|
|
|
{
|
|
|
|
// Whoops, we're trying to go faster than the simulation can manage.
|
|
|
|
// It's probably better to run at the right sim rate, at the expense
|
|
|
|
// of framerate, so let's try simulating a few more times.
|
|
|
|
double t = get_time();
|
|
|
|
while (!ok && get_time() < t + 0.1) // don't go much worse than 10fps
|
|
|
|
{
|
|
|
|
ok = g_Game->Update(0.0, false); // don't add on any extra sim time
|
|
|
|
}
|
|
|
|
}
|
2007-02-10 04:09:52 +01:00
|
|
|
|
|
|
|
// Interpolate the graphics - we only want to do this once per visual frame,
|
2007-01-24 21:17:28 +01:00
|
|
|
// not in every call to g_Game->Update
|
|
|
|
g_Game->GetSimulation()->Interpolate(actualFrameLength);
|
2007-02-10 04:09:52 +01:00
|
|
|
|
|
|
|
// If we still couldn't keep up, just drop the sim rate instead of building
|
|
|
|
// up a (potentially very large) backlog of required updates
|
|
|
|
g_Game->GetSimulation()->DiscardMissedUpdates();
|
2007-01-17 04:25:20 +01:00
|
|
|
}
|
2007-01-28 16:51:28 +01:00
|
|
|
|
|
|
|
// Cinematic motion should be independent of simulation update, so we can
|
|
|
|
// preview the cinematics by themselves
|
|
|
|
if (g_Game->GetView()->GetCinema()->IsPlaying())
|
|
|
|
g_Game->GetView()->GetCinema()->Update(frameLength);
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewGame::Render()
|
|
|
|
{
|
|
|
|
SViewPort vp = { 0, 0, g_xres, g_yres };
|
|
|
|
CCamera& camera = GetCamera();
|
|
|
|
camera.SetViewPort(&vp);
|
|
|
|
camera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);
|
|
|
|
camera.UpdateFrustum();
|
|
|
|
|
|
|
|
::Render();
|
|
|
|
AtlasMessage::AtlasRenderSelection();
|
2007-01-02 19:11:00 +01:00
|
|
|
Atlas_GLSwapBuffers((void*)g_GameLoop->glCanvas);
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CCamera& ViewGame::GetCamera()
|
|
|
|
{
|
|
|
|
return *g_Game->GetView()->GetCamera();
|
|
|
|
}
|
|
|
|
|
2006-09-27 18:54:23 +02:00
|
|
|
CUnit* ViewGame::GetUnit(AtlasMessage::ObjectID id)
|
|
|
|
{
|
2007-01-08 02:56:46 +01:00
|
|
|
return g_Game->GetWorld()->GetUnitManager().FindByID(id);
|
2006-09-27 18:54:23 +02:00
|
|
|
}
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
bool ViewGame::WantsHighFramerate()
|
|
|
|
{
|
|
|
|
if (g_Game->GetView()->GetCinema()->IsPlaying())
|
|
|
|
return true;
|
|
|
|
|
2007-01-17 04:25:20 +01:00
|
|
|
if (m_SpeedMultiplier != 0.f)
|
|
|
|
return true;
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-01-17 04:25:20 +01:00
|
|
|
void ViewGame::SetSpeedMultiplier(float speed)
|
|
|
|
{
|
|
|
|
m_SpeedMultiplier = speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewGame::SaveState(const std::wstring& label, bool onlyEntities)
|
|
|
|
{
|
|
|
|
SimState* simState = new SimState();
|
|
|
|
simState->onlyEntities = onlyEntities;
|
|
|
|
|
|
|
|
CUnitManager& unitMan = g_Game->GetWorld()->GetUnitManager();
|
|
|
|
const std::vector<CUnit*>& units = unitMan.GetUnits();
|
|
|
|
|
|
|
|
for (std::vector<CUnit*>::const_iterator unit = units.begin(); unit != units.end(); ++unit)
|
|
|
|
{
|
|
|
|
CEntity* entity = (*unit)->GetEntity();
|
|
|
|
|
|
|
|
// Ignore objects that aren't entities
|
|
|
|
if (! entity)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SimState::Entity e;
|
|
|
|
e.templateName = entity->m_base->m_Tag;
|
|
|
|
e.unitID = (*unit)->GetID();
|
|
|
|
e.selections = (*unit)->GetActorSelections();
|
|
|
|
e.playerID = entity->GetPlayer()->GetPlayerID();
|
|
|
|
e.position = entity->m_position;
|
|
|
|
e.angle = entity->m_orientation.Y;
|
|
|
|
|
|
|
|
simState->entities.push_back(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! onlyEntities)
|
|
|
|
{
|
|
|
|
for (std::vector<CUnit*>::const_iterator unit = units.begin(); unit != units.end(); ++unit) {
|
|
|
|
|
|
|
|
// Ignore objects that are entities
|
|
|
|
if ((*unit)->GetEntity())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SimState::Nonentity n;
|
|
|
|
n.actorName = (*unit)->GetObject()->m_Base->m_Name;
|
|
|
|
n.unitID = (*unit)->GetID();
|
|
|
|
n.selections = (*unit)->GetActorSelections();
|
|
|
|
n.position = (*unit)->GetModel()->GetTransform().GetTranslation();
|
|
|
|
CVector3D orient = (*unit)->GetModel()->GetTransform().GetIn();
|
|
|
|
n.angle = atan2(-orient.X, -orient.Z);
|
|
|
|
|
|
|
|
simState->nonentities.push_back(n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_SavedStates[label]; // in case it already exists
|
|
|
|
m_SavedStates[label] = simState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewGame::RestoreState(const std::wstring& label)
|
|
|
|
{
|
|
|
|
SimState* simState = m_SavedStates[label];
|
|
|
|
if (! simState)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CUnitManager& unitMan = g_Game->GetWorld()->GetUnitManager();
|
|
|
|
|
|
|
|
// delete all existing entities
|
2007-02-09 18:04:55 +01:00
|
|
|
g_Game->GetWorld()->GetProjectileManager().DeleteAll();
|
2007-05-02 14:07:08 +02:00
|
|
|
g_EntityManager.DeleteAll();
|
2007-01-17 04:25:20 +01:00
|
|
|
|
|
|
|
if (! simState->onlyEntities)
|
|
|
|
{
|
|
|
|
// delete all remaining non-entity units
|
|
|
|
unitMan.DeleteAll();
|
|
|
|
// don't reset the unitID counter - there's no need, since it'll work alright anyway
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < simState->entities.size(); ++i)
|
|
|
|
{
|
|
|
|
SimState::Entity& e = simState->entities[i];
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
CEntityTemplate* base = g_EntityTemplateCollection.GetTemplate(e.templateName, g_Game->GetPlayer(e.playerID));
|
2007-01-17 04:25:20 +01:00
|
|
|
if (base)
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
HEntity ent = g_EntityManager.Create(base, e.position, e.angle, e.selections);
|
2007-01-17 04:25:20 +01:00
|
|
|
|
|
|
|
if (ent)
|
|
|
|
{
|
|
|
|
ent->m_actor->SetPlayerID(e.playerID);
|
|
|
|
ent->m_actor->SetID(e.unitID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_EntityManager.InitializeAll();
|
|
|
|
|
2007-01-24 21:17:28 +01:00
|
|
|
if (! simState->onlyEntities)
|
2007-01-17 04:25:20 +01:00
|
|
|
{
|
2007-01-24 21:17:28 +01:00
|
|
|
for (size_t i = 0; i < simState->nonentities.size(); ++i)
|
|
|
|
{
|
|
|
|
SimState::Nonentity& n = simState->nonentities[i];
|
2007-01-17 04:25:20 +01:00
|
|
|
|
2007-01-24 21:17:28 +01:00
|
|
|
CUnit* unit = unitMan.CreateUnit(n.actorName, NULL, n.selections);
|
2007-01-17 04:25:20 +01:00
|
|
|
|
2007-01-24 21:17:28 +01:00
|
|
|
if (unit)
|
|
|
|
{
|
|
|
|
CMatrix3D m;
|
|
|
|
m.SetYRotation(n.angle + PI);
|
|
|
|
m.Translate(n.position);
|
|
|
|
unit->GetModel()->SetTransform(m);
|
2007-01-17 04:25:20 +01:00
|
|
|
|
2007-01-24 21:17:28 +01:00
|
|
|
unit->SetID(n.unitID);
|
|
|
|
}
|
2007-01-17 04:25:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ViewNone* view_None = NULL;
|
|
|
|
ViewGame* view_Game = NULL;
|
|
|
|
ViewActor* view_Actor = NULL;
|
|
|
|
|
|
|
|
View::~View()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-09-26 03:44:20 +02:00
|
|
|
View* View::GetView(int /*eRenderView*/ view)
|
|
|
|
{
|
2007-01-27 03:36:33 +01:00
|
|
|
switch (view)
|
2006-09-26 03:44:20 +02:00
|
|
|
{
|
2007-01-27 03:36:33 +01:00
|
|
|
case AtlasMessage::eRenderView::NONE: return View::GetView_None();
|
|
|
|
case AtlasMessage::eRenderView::GAME: return View::GetView_Game();
|
|
|
|
case AtlasMessage::eRenderView::ACTOR: return View::GetView_Actor();
|
|
|
|
default:
|
2006-09-26 03:44:20 +02:00
|
|
|
debug_warn("Invalid view type");
|
|
|
|
return View::GetView_None();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
View* View::GetView_None()
|
|
|
|
{
|
|
|
|
if (! view_None)
|
|
|
|
view_None = new ViewNone();
|
|
|
|
return view_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewGame* View::GetView_Game()
|
|
|
|
{
|
|
|
|
if (! view_Game)
|
|
|
|
view_Game = new ViewGame();
|
|
|
|
return view_Game;
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewActor* View::GetView_Actor()
|
|
|
|
{
|
|
|
|
if (! view_Actor)
|
|
|
|
view_Actor = new ViewActor();
|
|
|
|
return view_Actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void View::DestroyViews()
|
|
|
|
{
|
|
|
|
delete view_None; view_None = NULL;
|
|
|
|
delete view_Game; view_Game = NULL;
|
|
|
|
delete view_Actor; view_Actor = NULL;
|
|
|
|
}
|