Make CUnit::GetModel return a reference so it's clear it can never be NULL.
This was SVN commit r7464.
This commit is contained in:
parent
6a9de50692
commit
0547757a30
@ -416,12 +416,12 @@ void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int status = losMgr->GetUnitStatus(units[i], g_Game->GetLocalPlayer());
|
int status = losMgr->GetUnitStatus(units[i], g_Game->GetLocalPlayer());
|
||||||
CModel* model = units[i]->GetModel();
|
CModel& model = units[i]->GetModel();
|
||||||
|
|
||||||
model->ValidatePosition();
|
model.ValidatePosition();
|
||||||
|
|
||||||
if (status != UNIT_HIDDEN &&
|
if (status != UNIT_HIDDEN &&
|
||||||
(!m->Culling || frustum.IsBoxVisible(CVector3D(0,0,0), model->GetBounds())))
|
(!m->Culling || frustum.IsBoxVisible(CVector3D(0,0,0), model.GetBounds())))
|
||||||
{
|
{
|
||||||
if(units[i] != g_BuildingPlacer.m_actor)
|
if(units[i] != g_BuildingPlacer.m_actor)
|
||||||
{
|
{
|
||||||
@ -434,11 +434,11 @@ void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c)
|
|||||||
{
|
{
|
||||||
color = CColor(0.7f, 0.7f, 0.7f, 1.0f);
|
color = CColor(0.7f, 0.7f, 0.7f, 1.0f);
|
||||||
}
|
}
|
||||||
model->SetShadingColor(color);
|
model.SetShadingColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILE( "submit models" );
|
PROFILE( "submit models" );
|
||||||
c->SubmitRecursive(model);
|
c->SubmitRecursive(&model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,13 +493,14 @@ void CGameView::CameraLock(float x, float y, float z, bool smooth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void MarkUpdateColorRecursive(CModel* model)
|
static void MarkUpdateColorRecursive(CModel& model)
|
||||||
{
|
{
|
||||||
model->SetDirty(RENDERDATA_UPDATE_COLOR);
|
model.SetDirty(RENDERDATA_UPDATE_COLOR);
|
||||||
|
|
||||||
const std::vector<CModel::Prop>& props = model->GetProps();
|
const std::vector<CModel::Prop>& props = model.GetProps();
|
||||||
for(size_t i = 0; i < props.size(); ++i) {
|
for(size_t i = 0; i < props.size(); ++i) {
|
||||||
MarkUpdateColorRecursive(props[i].m_Model);
|
debug_assert(props[i].m_Model);
|
||||||
|
MarkUpdateColorRecursive(*props[i].m_Model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1112,7 +1112,7 @@ int CXMLReader::ReadNonEntities(XMBElement parent, double end_time)
|
|||||||
CMatrix3D m;
|
CMatrix3D m;
|
||||||
m.SetYRotation(Orientation + (float)M_PI);
|
m.SetYRotation(Orientation + (float)M_PI);
|
||||||
m.Translate(Position);
|
m.Translate(Position);
|
||||||
unit->GetModel()->SetTransform(m);
|
unit->GetModel().SetTransform(m);
|
||||||
|
|
||||||
// TODO: save object IDs in the map file, and load them again,
|
// TODO: save object IDs in the map file, and load them again,
|
||||||
// so that triggers have a persistent identifier for objects
|
// so that triggers have a persistent identifier for objects
|
||||||
|
@ -379,7 +379,7 @@ void CMapWriter::WriteXML(const VfsPath& filename,
|
|||||||
XML_Setting("Actor", (*unit)->GetObject().m_Base->m_Name);
|
XML_Setting("Actor", (*unit)->GetObject().m_Base->m_Name);
|
||||||
|
|
||||||
{
|
{
|
||||||
CVector3D position = (*unit)->GetModel()->GetTransform().GetTranslation();
|
CVector3D position = (*unit)->GetModel().GetTransform().GetTranslation();
|
||||||
|
|
||||||
XML_Element("Position");
|
XML_Element("Position");
|
||||||
XML_Attribute("x", position.X);
|
XML_Attribute("x", position.X);
|
||||||
@ -388,7 +388,7 @@ void CMapWriter::WriteXML(const VfsPath& filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
CVector3D orient = (*unit)->GetModel()->GetTransform().GetIn();
|
CVector3D orient = (*unit)->GetModel().GetTransform().GetIn();
|
||||||
float angle = atan2(-orient.X, -orient.Z);
|
float angle = atan2(-orient.X, -orient.Z);
|
||||||
|
|
||||||
XML_Element("Orientation");
|
XML_Element("Orientation");
|
||||||
|
@ -59,8 +59,8 @@ public:
|
|||||||
|
|
||||||
// get unit's template object
|
// get unit's template object
|
||||||
const CObjectEntry& GetObject() const { return *m_Object; }
|
const CObjectEntry& GetObject() const { return *m_Object; }
|
||||||
// get unit's model data; never NULL
|
// get unit's model data
|
||||||
CModel* GetModel() const { return m_Model; }
|
CModel& GetModel() const { return *m_Model; }
|
||||||
// get actor's entity; can be NULL
|
// get actor's entity; can be NULL
|
||||||
CEntity* GetEntity() const { return m_Entity; }
|
CEntity* GetEntity() const { return m_Entity; }
|
||||||
|
|
||||||
@ -107,9 +107,9 @@ public:
|
|||||||
void SetActorSelections(const std::set<CStr>& selections);
|
void SetActorSelections(const std::set<CStr>& selections);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// object from which unit was created
|
// object from which unit was created; never NULL
|
||||||
CObjectEntry* m_Object;
|
CObjectEntry* m_Object;
|
||||||
// object model representation
|
// object model representation; never NULL
|
||||||
CModel* m_Model;
|
CModel* m_Model;
|
||||||
// the entity that this actor represents, if any
|
// the entity that this actor represents, if any
|
||||||
CEntity* m_Entity;
|
CEntity* m_Entity;
|
||||||
|
@ -65,32 +65,32 @@ void CUnitAnimation::SetAnimationState(const CStr& name, bool once, float speed,
|
|||||||
|
|
||||||
void CUnitAnimation::SetAnimationSync(float actionTime, float repeatTime)
|
void CUnitAnimation::SetAnimationSync(float actionTime, float repeatTime)
|
||||||
{
|
{
|
||||||
CModel* model = m_Unit.GetModel();
|
CModel& model = m_Unit.GetModel();
|
||||||
|
|
||||||
if (!model || !model->m_Anim || !model->m_Anim->m_AnimDef)
|
if (!model.m_Anim || !model.m_Anim->m_AnimDef)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float duration = model->m_Anim->m_AnimDef->GetDuration();
|
float duration = model.m_Anim->m_AnimDef->GetDuration();
|
||||||
|
|
||||||
// Set the speed so it loops once in repeatTime
|
// Set the speed so it loops once in repeatTime
|
||||||
float speed = duration / repeatTime;
|
float speed = duration / repeatTime;
|
||||||
|
|
||||||
// Need to offset so that start+actionTime*speed = ActionPos
|
// Need to offset so that start+actionTime*speed = ActionPos
|
||||||
float start = model->m_Anim->m_ActionPos - actionTime*speed;
|
float start = model.m_Anim->m_ActionPos - actionTime*speed;
|
||||||
// Wrap it so that it's within the animation
|
// Wrap it so that it's within the animation
|
||||||
start = fmodf(start, duration);
|
start = fmodf(start, duration);
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
start += duration;
|
start += duration;
|
||||||
|
|
||||||
// Make the animation run at the computed timings
|
// Make the animation run at the computed timings
|
||||||
model->m_AnimTime = start;
|
model.m_AnimTime = start;
|
||||||
m_Speed = m_OriginalSpeed = speed;
|
m_Speed = m_OriginalSpeed = speed;
|
||||||
m_Desync = 0.f;
|
m_Desync = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUnitAnimation::Update(float time)
|
void CUnitAnimation::Update(float time)
|
||||||
{
|
{
|
||||||
CModel* model = m_Unit.GetModel();
|
CModel& model = m_Unit.GetModel();
|
||||||
|
|
||||||
// Convert from real time to scaled animation time
|
// Convert from real time to scaled animation time
|
||||||
float advance = time*m_Speed;
|
float advance = time*m_Speed;
|
||||||
@ -98,10 +98,10 @@ void CUnitAnimation::Update(float time)
|
|||||||
// Check if the current animation will trigger the action events
|
// Check if the current animation will trigger the action events
|
||||||
bool action = false;
|
bool action = false;
|
||||||
bool action2 = false;
|
bool action2 = false;
|
||||||
m_Unit.GetModel()->CheckActionTriggers(advance, action, action2);
|
model.CheckActionTriggers(advance, action, action2);
|
||||||
|
|
||||||
// Choose a new random animation if we're going to loop
|
// Choose a new random animation if we're going to loop
|
||||||
if (m_Looping && model->NeedsNewAnim(time))
|
if (m_Looping && model.NeedsNewAnim(time))
|
||||||
{
|
{
|
||||||
// Re-desynchronise the animation, to keep the irregular drifting between separate units
|
// Re-desynchronise the animation, to keep the irregular drifting between separate units
|
||||||
m_Speed = DesyncSpeed(m_OriginalSpeed, m_Desync);
|
m_Speed = DesyncSpeed(m_OriginalSpeed, m_Desync);
|
||||||
@ -115,7 +115,7 @@ void CUnitAnimation::Update(float time)
|
|||||||
|
|
||||||
// Check if the start of the new animation will trigger the action events
|
// Check if the start of the new animation will trigger the action events
|
||||||
// (This is additive with the previous CheckActionTriggers)
|
// (This is additive with the previous CheckActionTriggers)
|
||||||
m_Unit.GetModel()->CheckActionTriggers(advance, action, action2);
|
model.CheckActionTriggers(advance, action, action2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: props should get a new random animation once they loop, independent
|
// TODO: props should get a new random animation once they loop, independent
|
||||||
@ -143,5 +143,5 @@ void CUnitAnimation::Update(float time)
|
|||||||
// TODO: some animations (e.g. wood chopping) have two action points that should trigger sounds,
|
// TODO: some animations (e.g. wood chopping) have two action points that should trigger sounds,
|
||||||
// so we ought to support that somehow
|
// so we ought to support that somehow
|
||||||
|
|
||||||
model->Update(advance);
|
model.Update(advance);
|
||||||
}
|
}
|
||||||
|
@ -112,12 +112,12 @@ CUnit* CUnitManager::PickUnit(const CVector3D& origin, const CVector3D& dir, boo
|
|||||||
if( ent && !ent->m_visible )
|
if( ent && !ent->m_visible )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (unit->GetModel()->GetBounds().RayIntersect(origin, dir, tmin, tmax)
|
if (unit->GetModel().GetBounds().RayIntersect(origin, dir, tmin, tmax)
|
||||||
&& losMgr->GetUnitStatus(unit, g_Game->GetLocalPlayer()) != UNIT_HIDDEN)
|
&& losMgr->GetUnitStatus(unit, g_Game->GetLocalPlayer()) != UNIT_HIDDEN)
|
||||||
{
|
{
|
||||||
// Point of closest approach
|
// Point of closest approach
|
||||||
CVector3D obj;
|
CVector3D obj;
|
||||||
unit->GetModel()->GetBounds().GetCentre(obj);
|
unit->GetModel().GetBounds().GetCentre(obj);
|
||||||
CVector3D delta = obj - origin;
|
CVector3D delta = obj - origin;
|
||||||
float distance = delta.Dot(dir);
|
float distance = delta.Dot(dir);
|
||||||
CVector3D closest = origin + dir * distance;
|
CVector3D closest = origin + dir * distance;
|
||||||
|
@ -1200,7 +1200,7 @@ InReaction InteractInputHandler( const SDL_Event_* ev )
|
|||||||
if ( g_Selection.m_selected.empty() )
|
if ( g_Selection.m_selected.empty() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::vector<CModel::Prop>& Props = g_Selection.m_selected.front()->m_actor->GetModel()->GetProps();
|
std::vector<CModel::Prop>& Props = g_Selection.m_selected.front()->m_actor->GetModel().GetProps();
|
||||||
|
|
||||||
for (size_t x=0; x<Props.size(); x++)
|
for (size_t x=0; x<Props.size(); x++)
|
||||||
{
|
{
|
||||||
@ -1343,7 +1343,7 @@ bool IsOnScreen( CEntity* e, void* UNUSED(userdata) )
|
|||||||
CFrustum frustum = pCamera->GetFrustum();
|
CFrustum frustum = pCamera->GetFrustum();
|
||||||
|
|
||||||
if( e->m_actor )
|
if( e->m_actor )
|
||||||
return( frustum.IsBoxVisible( CVector3D(), e->m_actor->GetModel()->GetBounds() ) );
|
return( frustum.IsBoxVisible( CVector3D(), e->m_actor->GetModel().GetBounds() ) );
|
||||||
else
|
else
|
||||||
// If there's no actor, just treat the entity as a point
|
// If there's no actor, just treat the entity as a point
|
||||||
return( frustum.IsBoxVisible( e->m_graphics_position, CBound() ) );
|
return( frustum.IsBoxVisible( e->m_graphics_position, CBound() ) );
|
||||||
@ -1519,7 +1519,7 @@ void CBuildingPlacer::Update( float timeStep )
|
|||||||
CMatrix3D m;
|
CMatrix3D m;
|
||||||
m.SetYRotation(m_angle + (float)M_PI);
|
m.SetYRotation(m_angle + (float)M_PI);
|
||||||
m.Translate(pos);
|
m.Translate(pos);
|
||||||
m_actor->GetModel()->SetTransform( m );
|
m_actor->GetModel().SetTransform( m );
|
||||||
m_bounds->SetPosition(pos.X, pos.Z);
|
m_bounds->SetPosition(pos.X, pos.Z);
|
||||||
|
|
||||||
if( m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
if( m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
||||||
@ -1543,7 +1543,7 @@ void CBuildingPlacer::Update( float timeStep )
|
|||||||
float add = ( sin(4*(float)M_PI*m_totalTime) + 1.0f ) * 0.08f;
|
float add = ( sin(4*(float)M_PI*m_totalTime) + 1.0f ) * 0.08f;
|
||||||
col = CColor( 1.4f+add, 0.4f+add, 0.4f+add, 1.0f );
|
col = CColor( 1.4f+add, 0.4f+add, 0.4f+add, 1.0f );
|
||||||
}
|
}
|
||||||
m_actor->GetModel()->SetShadingColor( col );
|
m_actor->GetModel().SetShadingColor( col );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -372,7 +372,7 @@ void CEntity::UpdateActorTransforms()
|
|||||||
mXZ.Translate(m_graphics_position);
|
mXZ.Translate(m_graphics_position);
|
||||||
|
|
||||||
if( m_actor )
|
if( m_actor )
|
||||||
m_actor->GetModel()->SetTransform( mXZ );
|
m_actor->GetModel().SetTransform( mXZ );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEntity::SnapToGround()
|
void CEntity::SnapToGround()
|
||||||
@ -627,7 +627,7 @@ void CEntity::UpdateOrders( int timestep )
|
|||||||
PROFILE( "animation updates" );
|
PROFILE( "animation updates" );
|
||||||
if( m_extant )
|
if( m_extant )
|
||||||
{
|
{
|
||||||
if( ( m_lastState != -1 ) || !m_actor->GetModel()->GetAnimation() )
|
if( ( m_lastState != -1 ) || !m_actor->GetModel().GetAnimation() )
|
||||||
{
|
{
|
||||||
m_actor->SetAnimationState( "idle", false, 1.f, 0.f, false, L"" );
|
m_actor->SetAnimationState( "idle", false, 1.f, 0.f, false, L"" );
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ float CEntity::ChooseMovementSpeed( float distance )
|
|||||||
m_actor->SetAnimationState( anim_name, false, speed, 0.f, false, L"" );
|
m_actor->SetAnimationState( anim_name, false, speed, 0.f, false, L"" );
|
||||||
|
|
||||||
// Animation desync
|
// Animation desync
|
||||||
m_actor->GetModel()->Update( rand( 0, 1000 ) / 1000.0f );
|
m_actor->GetModel().Update( rand( 0, 1000 ) / 1000.0f );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ EUnitLOSStatus CLOSManager::GetUnitStatus(CUnit* unit, CPlayer* player)
|
|||||||
if (entity)
|
if (entity)
|
||||||
centre = entity->m_position;
|
centre = entity->m_position;
|
||||||
else
|
else
|
||||||
centre = unit->GetModel()->GetTransform().GetTranslation();
|
centre = unit->GetModel().GetTransform().GetTranslation();
|
||||||
|
|
||||||
ELOSStatus status = GetStatus(centre.X, centre.Z, player);
|
ELOSStatus status = GetStatus(centre.X, centre.Z, player);
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ void CCmpProjectileManager::AdvanceProjectile(const CSimContext& context, Projec
|
|||||||
transform.Translate(projectile.pos);
|
transform.Translate(projectile.pos);
|
||||||
|
|
||||||
// Move the model
|
// Move the model
|
||||||
projectile.unit->GetModel()->SetTransform(transform);
|
projectile.unit->GetModel().SetTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCmpProjectileManager::Interpolate(const CSimContext& context, float frameTime, float frameOffset)
|
void CCmpProjectileManager::Interpolate(const CSimContext& context, float frameTime, float frameOffset)
|
||||||
@ -279,15 +279,15 @@ void CCmpProjectileManager::RenderSubmit(const CSimContext& UNUSED(context), Sce
|
|||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_Projectiles.size(); ++i)
|
for (size_t i = 0; i < m_Projectiles.size(); ++i)
|
||||||
{
|
{
|
||||||
CModel* model = m_Projectiles[i].unit->GetModel();
|
CModel& model = m_Projectiles[i].unit->GetModel();
|
||||||
|
|
||||||
model->ValidatePosition();
|
model.ValidatePosition();
|
||||||
|
|
||||||
if (culling && !frustum.IsBoxVisible(CVector3D(0, 0, 0), model->GetBounds()))
|
if (culling && !frustum.IsBoxVisible(CVector3D(0, 0, 0), model.GetBounds()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// TODO: do something about LOS (copy from CCmpVisualActor)
|
// TODO: do something about LOS (copy from CCmpVisualActor)
|
||||||
|
|
||||||
collector.SubmitRecursive(model);
|
collector.SubmitRecursive(&model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,14 +166,14 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_Unit)
|
if (!m_Unit)
|
||||||
return CBound();
|
return CBound();
|
||||||
return m_Unit->GetModel()->GetBounds();
|
return m_Unit->GetModel().GetBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual CVector3D GetPosition()
|
virtual CVector3D GetPosition()
|
||||||
{
|
{
|
||||||
if (!m_Unit)
|
if (!m_Unit)
|
||||||
return CVector3D(0, 0, 0);
|
return CVector3D(0, 0, 0);
|
||||||
return m_Unit->GetModel()->GetTransform().GetTranslation();
|
return m_Unit->GetModel().GetTransform().GetTranslation();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::wstring GetActor()
|
virtual std::wstring GetActor()
|
||||||
@ -221,7 +221,7 @@ public:
|
|||||||
if (!m_Unit)
|
if (!m_Unit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_Unit->GetModel()->SetShadingColor(CColor(r.ToFloat(), g.ToFloat(), b.ToFloat(), a.ToFloat()));
|
m_Unit->GetModel().SetShadingColor(CColor(r.ToFloat(), g.ToFloat(), b.ToFloat(), a.ToFloat()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -248,7 +248,7 @@ void CCmpVisualActor::Interpolate(const CSimContext& context, float frameTime, f
|
|||||||
|
|
||||||
CMatrix3D transform(cmpPosition->GetInterpolatedTransform(frameOffset));
|
CMatrix3D transform(cmpPosition->GetInterpolatedTransform(frameOffset));
|
||||||
|
|
||||||
m_Unit->GetModel()->SetTransform(transform);
|
m_Unit->GetModel().SetTransform(transform);
|
||||||
m_Unit->UpdateModel(frameTime);
|
m_Unit->UpdateModel(frameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,14 +259,14 @@ void CCmpVisualActor::RenderSubmit(const CSimContext& UNUSED(context), SceneColl
|
|||||||
|
|
||||||
// TODO: need to think about things like LOS here
|
// TODO: need to think about things like LOS here
|
||||||
|
|
||||||
CModel* model = m_Unit->GetModel();
|
CModel& model = m_Unit->GetModel();
|
||||||
|
|
||||||
model->ValidatePosition();
|
model.ValidatePosition();
|
||||||
|
|
||||||
if (culling && !frustum.IsBoxVisible(CVector3D(0, 0, 0), model->GetBounds()))
|
if (culling && !frustum.IsBoxVisible(CVector3D(0, 0, 0), model.GetBounds()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: model->SetShadingColor(CColor(1.0f, 1.0f, 1.0f, 1.0f) if visible, CColor(0.7f, 0.7f, 0.7f, 1.0f) if hidden in FOW)
|
// TODO: model->SetShadingColor(CColor(1.0f, 1.0f, 1.0f, 1.0f) if visible, CColor(0.7f, 0.7f, 0.7f, 1.0f) if hidden in FOW)
|
||||||
|
|
||||||
collector.SubmitRecursive(model);
|
collector.SubmitRecursive(&model);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ void AtlasRenderSelection()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const CBound& bound = unit->GetModel()->GetBounds();
|
const CBound& bound = unit->GetModel().GetBounds();
|
||||||
// Expand bounds by 10% around the centre
|
// Expand bounds by 10% around the centre
|
||||||
CVector3D centre;
|
CVector3D centre;
|
||||||
bound.GetCentre(centre);
|
bound.GetCentre(centre);
|
||||||
@ -529,7 +529,7 @@ MESSAGEHANDLER(ObjectPreview)
|
|||||||
m._21 = 0.0f; m._22 = 1.0f; m._23 = 0.0f; m._24 = pos.Y;
|
m._21 = 0.0f; m._22 = 1.0f; m._23 = 0.0f; m._24 = pos.Y;
|
||||||
m._31 = s; m._32 = 0.0f; m._33 = -c; m._34 = pos.Z;
|
m._31 = s; m._32 = 0.0f; m._33 = -c; m._34 = pos.Z;
|
||||||
m._41 = 0.0f; m._42 = 0.0f; m._43 = 0.0f; m._44 = 1.0f;
|
m._41 = 0.0f; m._42 = 0.0f; m._43 = 0.0f; m._44 = 1.0f;
|
||||||
previewUnit->GetModel()->SetTransform(m);
|
previewUnit->GetModel().SetTransform(m);
|
||||||
|
|
||||||
// Update the unit's player colour:
|
// Update the unit's player colour:
|
||||||
previewUnit->SetPlayerID(msg->settings->player);
|
previewUnit->SetPlayerID(msg->settings->player);
|
||||||
@ -656,7 +656,7 @@ BEGIN_COMMAND(CreateObject)
|
|||||||
m._21 = 0.0f; m._22 = 1.0f; m._23 = 0.0f; m._24 = m_Pos.Y;
|
m._21 = 0.0f; m._22 = 1.0f; m._23 = 0.0f; m._24 = m_Pos.Y;
|
||||||
m._31 = s; m._32 = 0.0f; m._33 = -c; m._34 = m_Pos.Z;
|
m._31 = s; m._32 = 0.0f; m._33 = -c; m._34 = m_Pos.Z;
|
||||||
m._41 = 0.0f; m._42 = 0.0f; m._43 = 0.0f; m._44 = 1.0f;
|
m._41 = 0.0f; m._42 = 0.0f; m._43 = 0.0f; m._44 = 1.0f;
|
||||||
unit->GetModel()->SetTransform(m);
|
unit->GetModel().SetTransform(m);
|
||||||
|
|
||||||
unit->SetPlayerID(m_Player);
|
unit->SetPlayerID(m_Player);
|
||||||
}
|
}
|
||||||
@ -724,7 +724,7 @@ QUERYHANDLER(PickObject)
|
|||||||
// working out the screen coordinates to move the object to.
|
// working out the screen coordinates to move the object to.
|
||||||
// (TODO: http://trac.wildfiregames.com/ticket/99)
|
// (TODO: http://trac.wildfiregames.com/ticket/99)
|
||||||
|
|
||||||
CVector3D centre = target->GetModel()->GetTransform().GetTranslation();
|
CVector3D centre = target->GetModel().GetTransform().GetTranslation();
|
||||||
|
|
||||||
centre.Y = g_Game->GetWorld()->GetTerrain()->GetExactGroundLevel(centre.X, centre.Z);
|
centre.Y = g_Game->GetWorld()->GetTerrain()->GetExactGroundLevel(centre.X, centre.Z);
|
||||||
if (IsFloating(target))
|
if (IsFloating(target))
|
||||||
@ -775,7 +775,7 @@ BEGIN_COMMAND(MoveObject)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CMatrix3D m = unit->GetModel()->GetTransform();
|
CMatrix3D m = unit->GetModel().GetTransform();
|
||||||
m_PosOld = m.GetTranslation();
|
m_PosOld = m.GetTranslation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -808,9 +808,9 @@ BEGIN_COMMAND(MoveObject)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CMatrix3D m = unit->GetModel()->GetTransform();
|
CMatrix3D m = unit->GetModel().GetTransform();
|
||||||
m.Translate(pos - m.GetTranslation());
|
m.Translate(pos - m.GetTranslation());
|
||||||
unit->GetModel()->SetTransform(m);
|
unit->GetModel().SetTransform(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -884,9 +884,9 @@ BEGIN_COMMAND(RotateObject)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_TransformOld = unit->GetModel()->GetTransform();
|
m_TransformOld = unit->GetModel().GetTransform();
|
||||||
|
|
||||||
CVector3D pos = unit->GetModel()->GetTransform().GetTranslation();
|
CVector3D pos = unit->GetModel().GetTransform().GetTranslation();
|
||||||
|
|
||||||
float s, c;
|
float s, c;
|
||||||
if (msg->usetarget)
|
if (msg->usetarget)
|
||||||
@ -935,7 +935,7 @@ BEGIN_COMMAND(RotateObject)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unit->GetModel()->SetTransform(transform);
|
unit->GetModel().SetTransform(transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,8 @@ SimState::Nonentity SimState::Nonentity::Freeze(CUnit* unit)
|
|||||||
n.actorName = unit->GetObject().m_Base->m_Name;
|
n.actorName = unit->GetObject().m_Base->m_Name;
|
||||||
n.unitID = unit->GetID();
|
n.unitID = unit->GetID();
|
||||||
n.selections = unit->GetActorSelections();
|
n.selections = unit->GetActorSelections();
|
||||||
n.position = unit->GetModel()->GetTransform().GetTranslation();
|
n.position = unit->GetModel().GetTransform().GetTranslation();
|
||||||
CVector3D orient = unit->GetModel()->GetTransform().GetIn();
|
CVector3D orient = unit->GetModel().GetTransform().GetIn();
|
||||||
n.angle = atan2(-orient.X, -orient.Z);
|
n.angle = atan2(-orient.X, -orient.Z);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ CUnit* SimState::Nonentity::Thaw()
|
|||||||
CMatrix3D m;
|
CMatrix3D m;
|
||||||
m.SetYRotation(angle + (float)M_PI);
|
m.SetYRotation(angle + (float)M_PI);
|
||||||
m.Translate(position);
|
m.Translate(position);
|
||||||
unit->GetModel()->SetTransform(m);
|
unit->GetModel().SetTransform(m);
|
||||||
|
|
||||||
unit->SetID(unitID);
|
unit->SetID(unitID);
|
||||||
return unit;
|
return unit;
|
||||||
|
Loading…
Reference in New Issue
Block a user