CAnimData: std::move constructor arguments where applicable

Same behavior, but allows calling code to move into the respective
parameters now.
This commit is contained in:
Lioncash 2020-03-09 11:22:19 -04:00
parent 79565d7f52
commit e289643742
3 changed files with 23 additions and 22 deletions

View File

@ -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<CCharLayoutInfo>& layout, const TToken<CSkinnedModel>& model,
TLockedToken<CCharLayoutInfo> layout, TToken<CSkinnedModel> model,
const std::optional<TToken<CMorphableSkinnedModel>>& iceModel,
const std::weak_ptr<CAnimSysContext>& ctx, const std::shared_ptr<CAnimationManager>& animMgr,
const std::shared_ptr<CTransitionManager>& transMgr,
const TLockedToken<CCharacterFactory>& charFactory, int drawInstCount)
: x0_charFactory(charFactory)
const std::weak_ptr<CAnimSysContext>& ctx, std::shared_ptr<CAnimationManager> animMgr,
std::shared_ptr<CTransitionManager> transMgr, TLockedToken<CCharacterFactory> 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<CAnimTreeNode> 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) {

View File

@ -155,11 +155,10 @@ private:
public:
CAnimData(CAssetId, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop,
const TLockedToken<CCharLayoutInfo>& layout, const TToken<CSkinnedModel>& model,
const std::optional<TToken<CMorphableSkinnedModel>>& iceModel,
const std::weak_ptr<CAnimSysContext>& ctx, const std::shared_ptr<CAnimationManager>& animMgr,
const std::shared_ptr<CTransitionManager>& transMgr, const TLockedToken<CCharacterFactory>& charFactory,
int drawInstCount);
TLockedToken<CCharLayoutInfo> layout, TToken<CSkinnedModel> model,
const std::optional<TToken<CMorphableSkinnedModel>>& iceModel, const std::weak_ptr<CAnimSysContext>& ctx,
std::shared_ptr<CAnimationManager> animMgr, std::shared_ptr<CTransitionManager> transMgr,
TLockedToken<CCharacterFactory> charFactory, int drawInstCount);
void SetParticleEffectState(std::string_view effectName, bool active, CStateManager& mgr);
void InitializeEffects(CStateManager&, TAreaId, const zeus::CVector3f&);

View File

@ -78,19 +78,20 @@ std::unique_ptr<CAnimData> CCharacterFactory::CreateCharacter(int charIdx, bool
const TLockedToken<CCharacterFactory>& factory,
int defaultAnim, int drawInsts) const {
const CCharacterInfo& charInfo = x4_charInfoDB[charIdx];
CVParamTransfer charParm(new TObjOwnerParam<const CCharacterInfo*>(&charInfo));
const CVParamTransfer charParm(new TObjOwnerParam<const CCharacterInfo*>(&charInfo));
TToken<CSkinnedModel> skinnedModel = const_cast<CCharacterFactory*>(this)->x70_cacheResPool.GetObj(
{FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm);
std::optional<TToken<CMorphableSkinnedModel>> iceModel;
if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid())
if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) {
iceModel.emplace(const_cast<CCharacterFactory*>(this)->x70_cacheResPool.GetObj(
{FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm));
}
return std::make_unique<CAnimData>(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 {