2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/Character/CAnimTreeSequence.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/Character/CAnimSysContext.hpp"
|
|
|
|
#include "Runtime/Character/CTreeUtils.hpp"
|
|
|
|
#include "Runtime/Character/IMetaAnim.hpp"
|
2016-08-27 21:16:44 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-08-27 21:16:44 +00:00
|
|
|
|
2020-03-09 15:33:22 +00:00
|
|
|
CAnimTreeSequence::CAnimTreeSequence(std::vector<std::shared_ptr<IMetaAnim>> seq, CAnimSysContext animSys,
|
2017-11-13 06:19:18 +00:00
|
|
|
std::string_view name)
|
2018-12-08 05:30:43 +00:00
|
|
|
: CAnimTreeSingleChild(seq[0]->GetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders()), name)
|
2020-03-09 15:33:22 +00:00
|
|
|
, x18_animCtx(std::move(animSys))
|
|
|
|
, x28_sequence(std::move(seq))
|
|
|
|
, x3c_fundamentals(CSequenceHelper(x28_sequence, x18_animCtx).ComputeSequenceFundamentals())
|
2018-12-08 05:30:43 +00:00
|
|
|
, x94_curTime(0.f) {}
|
2016-08-27 21:16:44 +00:00
|
|
|
|
|
|
|
CAnimTreeSequence::CAnimTreeSequence(const std::shared_ptr<CAnimTreeNode>& curNode,
|
2020-03-09 15:33:22 +00:00
|
|
|
std::vector<std::shared_ptr<IMetaAnim>> metaAnims,
|
|
|
|
CAnimSysContext animSys, std::string_view name,
|
|
|
|
CSequenceFundamentals fundamentals, const CCharAnimTime& time)
|
2018-12-08 05:30:43 +00:00
|
|
|
: CAnimTreeSingleChild(curNode, name)
|
2020-03-09 15:33:22 +00:00
|
|
|
, x18_animCtx(std::move(animSys))
|
|
|
|
, x28_sequence(std::move(metaAnims))
|
|
|
|
, x3c_fundamentals(std::move(fundamentals))
|
2018-12-08 05:30:43 +00:00
|
|
|
, x94_curTime(time) {}
|
|
|
|
|
|
|
|
CAnimTreeEffectiveContribution CAnimTreeSequence::VGetContributionOfHighestInfluence() const {
|
|
|
|
return x14_child->GetContributionOfHighestInfluence();
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::shared_ptr<IAnimReader> CAnimTreeSequence::VGetBestUnblendedChild() const {
|
|
|
|
std::shared_ptr<IAnimReader> ch = x14_child->GetBestUnblendedChild();
|
|
|
|
if (!ch)
|
|
|
|
return ch;
|
|
|
|
return std::make_shared<CAnimTreeSequence>(
|
|
|
|
std::static_pointer_cast<CAnimTreeNode>(std::shared_ptr<IAnimReader>(ch->Clone())), x28_sequence, x18_animCtx,
|
|
|
|
x4_name, x3c_fundamentals, x94_curTime);
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
SAdvancementResults CAnimTreeSequence::VAdvanceView(const CCharAnimTime& dt) {
|
|
|
|
CCharAnimTime totalDelta;
|
|
|
|
zeus::CVector3f posDelta;
|
|
|
|
zeus::CQuaternion rotDelta;
|
|
|
|
|
|
|
|
std::shared_ptr<CAnimTreeNode> curChild = x14_child;
|
|
|
|
if (x38_curIdx >= x28_sequence.size() && curChild->VGetTimeRemaining().EqualsZero()) {
|
|
|
|
x3c_fundamentals = CSequenceHelper(x28_sequence, x18_animCtx).ComputeSequenceFundamentals();
|
|
|
|
x38_curIdx = 0;
|
|
|
|
x14_child = CTreeUtils::GetTransitionTree(
|
|
|
|
curChild, x28_sequence[x38_curIdx]->GetAnimationTree(x18_animCtx, CMetaAnimTreeBuildOrders::NoSpecialOrders()),
|
|
|
|
x18_animCtx);
|
|
|
|
curChild = x14_child;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCharAnimTime remTime = dt;
|
2020-04-30 06:16:50 +00:00
|
|
|
// Note: EpsilonZero check added
|
|
|
|
while (remTime.GreaterThanZero() && !remTime.EpsilonZero() && x38_curIdx < x28_sequence.size()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CCharAnimTime chRem = curChild->VGetTimeRemaining();
|
|
|
|
if (chRem.EqualsZero()) {
|
|
|
|
++x38_curIdx;
|
|
|
|
if (x38_curIdx < x28_sequence.size()) {
|
|
|
|
x14_child = CTreeUtils::GetTransitionTree(
|
|
|
|
curChild,
|
|
|
|
x28_sequence[x38_curIdx]->GetAnimationTree(x18_animCtx, CMetaAnimTreeBuildOrders::NoSpecialOrders()),
|
|
|
|
x18_animCtx);
|
|
|
|
}
|
2018-01-30 01:04:01 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
curChild = x14_child;
|
|
|
|
if (x38_curIdx < x28_sequence.size()) {
|
|
|
|
SAdvancementResults res = curChild->VAdvanceView(remTime);
|
|
|
|
if (auto simp = curChild->Simplified()) {
|
|
|
|
curChild = CAnimTreeNode::Cast(std::move(*simp));
|
|
|
|
x14_child = curChild;
|
|
|
|
}
|
|
|
|
CCharAnimTime prevRemTime = remTime;
|
|
|
|
remTime = res.x0_remTime;
|
|
|
|
totalDelta += prevRemTime - remTime;
|
|
|
|
posDelta += res.x8_deltas.x0_posDelta;
|
|
|
|
rotDelta = rotDelta * res.x8_deltas.xc_rotDelta;
|
2018-01-30 01:04:01 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-01-30 01:04:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x94_curTime += totalDelta;
|
|
|
|
return {dt - totalDelta, {posDelta, rotDelta}};
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CCharAnimTime CAnimTreeSequence::VGetTimeRemaining() const {
|
|
|
|
if (x38_curIdx == x28_sequence.size() - 1)
|
|
|
|
return x14_child->VGetTimeRemaining();
|
2020-04-30 06:16:50 +00:00
|
|
|
return x3c_fundamentals.GetSteadyStateAnimInfo().GetDuration() - x94_curTime;
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CSteadyStateAnimInfo CAnimTreeSequence::VGetSteadyStateAnimInfo() const {
|
|
|
|
return x3c_fundamentals.GetSteadyStateAnimInfo();
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
size_t CAnimTreeSequence::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, size_t capacity,
|
|
|
|
size_t iterator, u32 unk) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
return _getPOIList(time, listOut, capacity, iterator, unk, x3c_fundamentals.GetBoolPointsOfInterest(), x94_curTime);
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
size_t CAnimTreeSequence::VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, size_t capacity,
|
|
|
|
size_t iterator, u32 unk) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
return _getPOIList(time, listOut, capacity, iterator, unk, x3c_fundamentals.GetInt32PointsOfInterest(), x94_curTime);
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
size_t CAnimTreeSequence::VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, size_t capacity,
|
|
|
|
size_t iterator, u32 unk) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
return _getPOIList(time, listOut, capacity, iterator, unk, x3c_fundamentals.GetParticlePointsOfInterest(),
|
|
|
|
x94_curTime);
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
size_t CAnimTreeSequence::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, size_t capacity,
|
|
|
|
size_t iterator, u32 unk) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
return _getPOIList(time, listOut, capacity, iterator, unk, x3c_fundamentals.GetSoundPointsOfInterest(), x94_curTime);
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<IAnimReader> CAnimTreeSequence::VClone() const {
|
|
|
|
return std::make_unique<CAnimTreeSequence>(
|
|
|
|
std::static_pointer_cast<CAnimTreeNode>(std::shared_ptr<IAnimReader>(x14_child->Clone())), x28_sequence,
|
|
|
|
x18_animCtx, x4_name, x3c_fundamentals, x94_curTime);
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|