From e289643742d388d78e8353432ed329509eda9ce2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 9 Mar 2020 11:22:19 -0400 Subject: [PATCH] CAnimData: std::move constructor arguments where applicable Same behavior, but allows calling code to move into the respective parameters now. --- Runtime/Character/CAnimData.cpp | 27 +++++++++++++------------ Runtime/Character/CAnimData.hpp | 9 ++++----- Runtime/Character/CCharacterFactory.cpp | 9 +++++---- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 09adede33..c621ed647 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -40,19 +40,19 @@ void CAnimData::FreeCache() {} void CAnimData::InitializeCache() {} CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop, - const TLockedToken& layout, const TToken& model, + TLockedToken layout, TToken model, const std::optional>& iceModel, - const std::weak_ptr& ctx, const std::shared_ptr& animMgr, - const std::shared_ptr& transMgr, - const TLockedToken& charFactory, int drawInstCount) -: x0_charFactory(charFactory) + const std::weak_ptr& ctx, std::shared_ptr animMgr, + std::shared_ptr transMgr, TLockedToken charFactory, + int drawInstCount) +: x0_charFactory(std::move(charFactory)) , xc_charInfo(character) -, xcc_layoutData(layout) -, xd8_modelData(model) +, xcc_layoutData(std::move(layout)) +, xd8_modelData(std::move(model)) , xfc_animCtx(ctx.lock()) -, x100_animMgr(animMgr) +, x100_animMgr(std::move(animMgr)) , x1d8_selfId(id) -, x1fc_transMgr(transMgr) +, x1fc_transMgr(std::move(transMgr)) , x204_charIdx(charIdx) , x208_defaultAnim(defaultAnim) , x224_pose(layout->GetSegIdList().GetList().size()) @@ -82,10 +82,11 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn character.GetCharacterName()); } - std::shared_ptr treeNode = GetAnimationManager()->GetAnimationTree( - character.GetAnimationIndex(defaultAnim), CMetaAnimTreeBuildOrders::NoSpecialOrders()); - if (treeNode != x1f8_animRoot) - x1f8_animRoot = treeNode; + auto treeNode = GetAnimationManager()->GetAnimationTree(character.GetAnimationIndex(defaultAnim), + CMetaAnimTreeBuildOrders::NoSpecialOrders()); + if (treeNode != x1f8_animRoot) { + x1f8_animRoot = std::move(treeNode); + } } void CAnimData::SetParticleEffectState(std::string_view effectName, bool active, CStateManager& mgr) { diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index 7d0ce311b..d2cf6a91c 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -155,11 +155,10 @@ private: public: CAnimData(CAssetId, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop, - const TLockedToken& layout, const TToken& model, - const std::optional>& iceModel, - const std::weak_ptr& ctx, const std::shared_ptr& animMgr, - const std::shared_ptr& transMgr, const TLockedToken& charFactory, - int drawInstCount); + TLockedToken layout, TToken model, + const std::optional>& iceModel, const std::weak_ptr& ctx, + std::shared_ptr animMgr, std::shared_ptr transMgr, + TLockedToken charFactory, int drawInstCount); void SetParticleEffectState(std::string_view effectName, bool active, CStateManager& mgr); void InitializeEffects(CStateManager&, TAreaId, const zeus::CVector3f&); diff --git a/Runtime/Character/CCharacterFactory.cpp b/Runtime/Character/CCharacterFactory.cpp index d22efeae5..13088c44c 100644 --- a/Runtime/Character/CCharacterFactory.cpp +++ b/Runtime/Character/CCharacterFactory.cpp @@ -78,19 +78,20 @@ std::unique_ptr CCharacterFactory::CreateCharacter(int charIdx, bool const TLockedToken& factory, int defaultAnim, int drawInsts) const { const CCharacterInfo& charInfo = x4_charInfoDB[charIdx]; - CVParamTransfer charParm(new TObjOwnerParam(&charInfo)); + const CVParamTransfer charParm(new TObjOwnerParam(&charInfo)); TToken skinnedModel = const_cast(this)->x70_cacheResPool.GetObj( {FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm); std::optional> iceModel; - if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) + if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) { iceModel.emplace(const_cast(this)->x70_cacheResPool.GetObj( {FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm)); + } return std::make_unique(x68_selfId, charInfo, defaultAnim, charIdx, loop, x14_charLayoutInfoDB[charIdx], - skinnedModel, iceModel, x24_sysContext, x28_animMgr, x2c_transMgr, factory, - drawInsts); + std::move(skinnedModel), iceModel, x24_sysContext, x28_animMgr, x2c_transMgr, + factory, drawInsts); } CAssetId CCharacterFactory::GetEventResourceIdForAnimResourceId(CAssetId id) const {