Index: ps/trunk/source/graphics/UnitAnimation.h =================================================================== --- ps/trunk/source/graphics/UnitAnimation.h +++ ps/trunk/source/graphics/UnitAnimation.h @@ -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 @@ */ void ReloadUnit(CModel* model, const CObjectEntry* object); + /** + * Reload animation so any changes take immediate effect. + */ + void ReloadAnimation(); + private: /** Index: ps/trunk/source/graphics/UnitAnimation.cpp =================================================================== --- ps/trunk/source/graphics/UnitAnimation.cpp +++ ps/trunk/source/graphics/UnitAnimation.cpp @@ -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::ReloadAnimation() +{ + UpdateAnimationID(); + ReloadUnit(m_Model, m_Object); +} + void CUnitAnimation::ReloadUnit(CModel* model, const CObjectEntry* object) { m_Model = model; @@ -108,9 +114,7 @@ if (name != m_State) { m_State = name; - UpdateAnimationID(); - - ReloadUnit(m_Model, m_Object); + ReloadAnimation(); } } Index: ps/trunk/source/simulation2/components/CCmpVisualActor.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpVisualActor.cpp +++ ps/trunk/source/simulation2/components/CCmpVisualActor.cpp @@ -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 @@ 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