metaforce/Runtime/Character/CMetaAnimPhaseBlend.cpp

44 lines
1.9 KiB
C++
Raw Normal View History

#include "Runtime/Character/CMetaAnimPhaseBlend.hpp"
#include "Runtime/Character/CAnimTreeBlend.hpp"
#include "Runtime/Character/CAnimTreeTimeScale.hpp"
#include "Runtime/Character/CMetaAnimFactory.hpp"
2016-04-10 14:22:59 -07:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
2016-04-10 14:22:59 -07:00
2018-12-07 21:30:43 -08:00
CMetaAnimPhaseBlend::CMetaAnimPhaseBlend(CInputStream& in) {
x4_animA = CMetaAnimFactory::CreateMetaAnim(in);
x8_animB = CMetaAnimFactory::CreateMetaAnim(in);
xc_blend = in.ReadFloat();
x10_ = in.ReadBool();
2016-04-10 14:22:59 -07:00
}
2018-12-07 21:30:43 -08:00
void CMetaAnimPhaseBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const {
x4_animA->GetUniquePrimitives(primsOut);
x8_animB->GetUniquePrimitives(primsOut);
2016-04-10 14:22:59 -07:00
}
2018-12-07 21:30:43 -08:00
std::shared_ptr<CAnimTreeNode> CMetaAnimPhaseBlend::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const {
2019-03-09 00:58:27 -08:00
if (orders.x0_recursiveAdvance)
return GetAnimationTree(animSys, CMetaAnimTreeBuildOrders::PreAdvanceForAll(*orders.x0_recursiveAdvance));
auto a = x4_animA->GetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
auto b = x8_animB->GetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
auto da = a->GetContributionOfHighestInfluence().GetSteadyStateAnimInfo().GetDuration();
auto db = b->GetContributionOfHighestInfluence().GetSteadyStateAnimInfo().GetDuration();
auto dblend = da + (db - da) * xc_blend;
float fa = da / dblend;
float fb = db / dblend;
2021-06-07 12:29:18 -07:00
auto tsa = std::make_shared<CAnimTreeTimeScale>(
a, fa, CAnimTreeTimeScale::CreatePrimitiveName(a, fa, CCharAnimTime::Infinity(), -1.f));
auto tsb = std::make_shared<CAnimTreeTimeScale>(
b, fb, CAnimTreeTimeScale::CreatePrimitiveName(b, fb, CCharAnimTime::Infinity(), -1.f));
2019-03-09 00:58:27 -08:00
return std::make_shared<CAnimTreeBlend>(x10_, tsa, tsb, xc_blend,
CAnimTreeBlend::CreatePrimitiveName(tsa, tsb, xc_blend));
2016-04-10 14:22:59 -07:00
}
2021-04-10 01:42:06 -07:00
} // namespace metaforce