2006-04-24 01:14:18 +02:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "Unit.h"
|
|
|
|
#include "Model.h"
|
2007-02-04 16:58:23 +01:00
|
|
|
#include "ObjectBase.h"
|
2006-04-24 01:14:18 +02:00
|
|
|
#include "ObjectEntry.h"
|
|
|
|
#include "ObjectManager.h"
|
|
|
|
#include "SkeletonAnim.h"
|
|
|
|
#include "SkeletonAnimDef.h"
|
2007-02-10 04:09:52 +01:00
|
|
|
#include "UnitAnimation.h"
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2006-09-02 23:20:25 +02:00
|
|
|
#include "ps/Game.h"
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
#include "ps/Player.h"
|
2006-09-02 23:20:25 +02:00
|
|
|
#include "simulation/Entity.h"
|
|
|
|
|
2008-06-29 12:12:52 +02:00
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
CUnit::CUnit(CObjectEntry* object, CEntity* entity, CObjectManager& objectManager,
|
|
|
|
const std::set<CStr>& actorSelections)
|
2006-04-24 01:14:18 +02:00
|
|
|
: m_Object(object), m_Model(object->m_Model->Clone()), m_Entity(entity),
|
2008-06-30 19:31:09 +02:00
|
|
|
m_ID(invalidUnitId), m_ActorSelections(actorSelections), m_PlayerID(invalidPlayerId),
|
2007-01-08 02:56:46 +01:00
|
|
|
m_ObjectManager(objectManager)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2007-02-10 04:09:52 +01:00
|
|
|
m_Animation = new CUnitAnimation(*this);
|
2006-04-24 01:14:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CUnit::~CUnit()
|
|
|
|
{
|
2007-02-10 04:09:52 +01:00
|
|
|
delete m_Animation;
|
2006-04-24 01:14:18 +02:00
|
|
|
delete m_Model;
|
|
|
|
}
|
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
CUnit* CUnit::Create(const CStr& actorName, CEntity* entity,
|
|
|
|
const std::set<CStr>& selections, CObjectManager& objectManager)
|
# 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
|
|
|
CObjectBase* base = objectManager.FindObjectBase(actorName);
|
# 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
|
|
|
|
|
|
|
if (! base)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
std::set<CStr> actorSelections = base->CalculateRandomVariation(selections);
|
|
|
|
|
|
|
|
std::vector<std::set<CStr> > selectionsVec;
|
|
|
|
selectionsVec.push_back(actorSelections);
|
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
CObjectEntry* obj = objectManager.FindObjectVariation(base, selectionsVec);
|
# 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
|
|
|
|
|
|
|
if (! obj)
|
|
|
|
return NULL;
|
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
return new CUnit(obj, entity, objectManager, actorSelections);
|
# 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-04-24 01:14:18 +02:00
|
|
|
void CUnit::ShowAmmunition()
|
|
|
|
{
|
|
|
|
if (!m_Object->m_AmmunitionModel || !m_Object->m_AmmunitionPoint)
|
|
|
|
return;
|
2009-02-18 11:36:27 +01:00
|
|
|
// Remove any previous ammunition prop, in case there's still one left on there
|
|
|
|
m_Model->RemoveProp(m_Object->m_AmmunitionPoint);
|
|
|
|
// Then add the new prop
|
2006-04-24 01:14:18 +02:00
|
|
|
m_Model->AddProp(m_Object->m_AmmunitionPoint, m_Object->m_AmmunitionModel->Clone(), m_Object);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CUnit::HideAmmunition()
|
|
|
|
{
|
|
|
|
if (!m_Object->m_AmmunitionModel || !m_Object->m_AmmunitionPoint)
|
|
|
|
return;
|
|
|
|
|
2009-02-18 11:36:27 +01:00
|
|
|
// Remove the ammunition prop
|
|
|
|
m_Model->RemoveProp(m_Object->m_AmmunitionPoint);
|
|
|
|
// Restore the original props that were on the ammo attachpoint, by copying them from
|
|
|
|
// the base model
|
2006-04-24 01:14:18 +02:00
|
|
|
std::vector<CModel::Prop>& props = m_Object->m_Model->GetProps();
|
|
|
|
std::vector<CModel::Prop>::iterator it;
|
|
|
|
for (it = props.begin(); it != props.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it->m_Point == m_Object->m_AmmunitionPoint)
|
|
|
|
{
|
|
|
|
m_Model->AddProp(m_Object->m_AmmunitionPoint, it->m_Model->Clone(), m_Object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static CSkeletonAnim* GetRandomAnimation(const CStr& name, CObjectEntry* object)
|
|
|
|
{
|
|
|
|
CSkeletonAnim* anim = object->GetRandomAnimation(name);
|
|
|
|
|
|
|
|
// Fall back to 'idle', if no matching animation is found
|
|
|
|
if (anim == NULL && name != "idle")
|
|
|
|
anim = object->GetRandomAnimation("idle");
|
|
|
|
|
|
|
|
// Every object should have an idle animation (even if it's a dummy static one)
|
|
|
|
debug_assert(anim != NULL);
|
|
|
|
|
|
|
|
return anim;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool SetRandomAnimation(const CStr& name, bool once, float speed,
|
|
|
|
CModel* model, CObjectEntry* object)
|
|
|
|
{
|
|
|
|
CSkeletonAnim* anim = GetRandomAnimation(name, object);
|
|
|
|
if (anim)
|
|
|
|
{
|
|
|
|
float actualSpeed = 1000.f;
|
|
|
|
if (speed && anim->m_AnimDef)
|
|
|
|
actualSpeed = speed * anim->m_AnimDef->GetDuration();
|
|
|
|
model->SetAnimation(anim, once, actualSpeed);
|
|
|
|
|
|
|
|
// Recursively apply the animation name to props
|
|
|
|
const std::vector<CModel::Prop>& props = model->GetProps();
|
|
|
|
for (std::vector<CModel::Prop>::const_iterator it = props.begin(); it != props.end(); ++it)
|
|
|
|
{
|
|
|
|
bool ok = SetRandomAnimation(name, once, speed, it->m_Model, it->m_ObjectEntry);
|
|
|
|
if (! ok)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// This shouldn't happen, since GetRandomAnimation tries to always
|
|
|
|
// return something valid
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CUnit::SetRandomAnimation(const CStr& name, bool once, float speed)
|
|
|
|
{
|
|
|
|
return ::SetRandomAnimation(name, once, speed, m_Model, m_Object);
|
|
|
|
}
|
|
|
|
|
|
|
|
CSkeletonAnim* CUnit::GetRandomAnimation(const CStr& name)
|
|
|
|
{
|
|
|
|
return ::GetRandomAnimation(name, m_Object);
|
|
|
|
}
|
|
|
|
|
2007-02-10 04:09:52 +01:00
|
|
|
bool CUnit::HasAnimation(const CStr& name)
|
|
|
|
{
|
|
|
|
return (m_Object->GetRandomAnimation(name) != NULL);
|
|
|
|
}
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
bool CUnit::IsPlayingAnimation(const CStr& name)
|
|
|
|
{
|
|
|
|
return (m_Model->GetAnimation() && m_Model->GetAnimation()->m_Name == name);
|
|
|
|
}
|
|
|
|
|
2007-02-10 04:09:52 +01:00
|
|
|
void CUnit::SetAnimationState(const CStr& name, bool once, float speed, bool keepSelection)
|
|
|
|
{
|
|
|
|
m_Animation->SetAnimationState(name, once, speed, keepSelection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CUnit::SetAnimationSync(float timeUntilActionPos)
|
|
|
|
{
|
|
|
|
m_Animation->SetAnimationSync(timeUntilActionPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CUnit::UpdateModel(float frameTime)
|
|
|
|
{
|
|
|
|
m_Animation->Update(frameTime);
|
|
|
|
}
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
void CUnit::SetPlayerID(size_t id)
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
|
|
|
m_PlayerID = id;
|
|
|
|
m_Model->SetPlayerID(m_PlayerID);
|
2006-09-02 23:20:25 +02:00
|
|
|
|
|
|
|
if (m_Entity)
|
|
|
|
m_Entity->SetPlayer(g_Game->GetPlayer(id));
|
2006-04-24 01:14:18 +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
|
|
|
void CUnit::SetEntitySelection(const CStr& selection)
|
2006-04-24 01:14:18 +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
|
|
|
CStr selection_lc = selection.LowerCase();
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
// If we've already selected this, don't do anything
|
|
|
|
if (m_EntitySelections.find(selection_lc) != m_EntitySelections.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Just allow one selection at a time
|
|
|
|
m_EntitySelections.clear();
|
|
|
|
m_EntitySelections.insert(selection_lc);
|
|
|
|
|
|
|
|
ReloadObject();
|
|
|
|
}
|
|
|
|
|
# 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 CUnit::SetActorSelections(const std::set<CStr>& selections)
|
2006-05-31 07:27:02 +02:00
|
|
|
{
|
|
|
|
m_ActorSelections = selections;
|
|
|
|
ReloadObject();
|
|
|
|
}
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
void CUnit::ReloadObject()
|
|
|
|
{
|
# 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
|
|
|
std::vector<std::set<CStr> > selections;
|
2006-04-24 01:14:18 +02:00
|
|
|
// TODO: push world selections (seasons, etc) (and reload whenever they're changed)
|
|
|
|
selections.push_back(m_EntitySelections);
|
|
|
|
selections.push_back(m_ActorSelections);
|
|
|
|
|
|
|
|
// If these selections give a different object, change this unit to use it
|
2007-01-08 02:56:46 +01:00
|
|
|
CObjectEntry* newObject = m_ObjectManager.FindObjectVariation(m_Object->m_Base, selections);
|
2006-04-24 01:14:18 +02:00
|
|
|
if (newObject != m_Object)
|
|
|
|
{
|
2006-09-27 18:54:23 +02:00
|
|
|
// Clone the new object's base (non-instance) model
|
2006-04-24 01:14:18 +02:00
|
|
|
CModel* newModel = newObject->m_Model->Clone();
|
2006-09-02 23:20:25 +02:00
|
|
|
|
2006-09-27 18:54:23 +02:00
|
|
|
// Copy the old instance-specific settings from the old model to the new instance
|
2006-04-24 01:14:18 +02:00
|
|
|
newModel->SetTransform(m_Model->GetTransform());
|
2008-06-30 19:31:09 +02:00
|
|
|
if (m_PlayerID != invalidPlayerId)
|
2006-09-02 23:20:25 +02:00
|
|
|
newModel->SetPlayerID(m_PlayerID);
|
2006-09-27 18:54:23 +02:00
|
|
|
newModel->CopyAnimationFrom(m_Model);
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
delete m_Model;
|
|
|
|
m_Model = newModel;
|
|
|
|
m_Object = newObject;
|
|
|
|
}
|
|
|
|
}
|