Update the animation immediately after a varaint is changed, so we don't have sliding issues when we do so.

Differential Revision: https://code.wildfiregames.com/D1322
Reviewed By: temple
This was SVN commit r21335.
This commit is contained in:
bb 2018-02-23 20:11:16 +00:00
parent 7908045272
commit c0349931c0
3 changed files with 22 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2016 Wildfire Games.
/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -85,6 +85,12 @@ void CUnitAnimation::AddModel(CModel* model, const CObjectEntry* object)
}
}
void CUnitAnimation::ReloadAnimation()
{
UpdateAnimationID();
ReloadUnit(m_Model, m_Object);
}
void CUnitAnimation::ReloadUnit(CModel* model, const CObjectEntry* object)
{
m_Model = model;
@ -108,9 +114,7 @@ void CUnitAnimation::SetAnimationState(const CStr& name, bool once, float speed,
if (name != m_State)
{
m_State = name;
UpdateAnimationID();
ReloadUnit(m_Model, m_Object);
ReloadAnimation();
}
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2016 Wildfire Games.
/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -91,6 +91,11 @@ public:
*/
void ReloadUnit(CModel* model, const CObjectEntry* object);
/**
* Reload animation so any changes take immediate effect.
*/
void ReloadAnimation();
private:
/**

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2017 Wildfire Games.
/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -418,10 +418,17 @@ public:
virtual void SetVariant(const CStr& key, const CStr& selection)
{
if (m_VariantSelections[key] == selection)
return;
m_VariantSelections[key] = selection;
if (m_Unit)
{
m_Unit->SetEntitySelection(key, selection);
if (m_Unit->GetAnimation())
m_Unit->GetAnimation()->ReloadAnimation();
}
}
virtual std::string GetAnimationName() const