2016-04-11 07:10:28 +00:00
|
|
|
#include "IMetaAnim.hpp"
|
|
|
|
#include "CCharAnimTime.hpp"
|
|
|
|
#include "IAnimReader.hpp"
|
|
|
|
#include "CBoolPOINode.hpp"
|
2016-08-27 21:16:44 +00:00
|
|
|
#include "CAnimTreeNode.hpp"
|
2016-04-11 07:10:28 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-04-11 07:10:28 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::shared_ptr<CAnimTreeNode> IMetaAnim::GetAnimationTree(const CAnimSysContext& animSys,
|
|
|
|
const CMetaAnimTreeBuildOrders& orders) const {
|
|
|
|
if (orders.x44_singleAdvance) {
|
|
|
|
std::shared_ptr<CAnimTreeNode> tree = VGetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
|
|
|
|
if (orders.x44_singleAdvance->IsTime() || orders.x44_singleAdvance->IsString()) {
|
|
|
|
CCharAnimTime time = GetTime(*orders.x44_singleAdvance, *tree);
|
|
|
|
AdvanceAnim(*tree, time);
|
2016-08-27 21:16:44 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
return tree;
|
|
|
|
}
|
|
|
|
return VGetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
|
2016-04-11 07:10:28 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void IMetaAnim::AdvanceAnim(IAnimReader& anim, const CCharAnimTime& dt) {
|
|
|
|
CCharAnimTime remDt = dt;
|
|
|
|
while (remDt > CCharAnimTime()) {
|
|
|
|
SAdvancementResults res = anim.VAdvanceView(remDt);
|
|
|
|
remDt = res.x0_remTime;
|
|
|
|
}
|
2016-04-11 07:10:28 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CCharAnimTime IMetaAnim::GetTime(const CPreAdvanceIndicator& ind, const IAnimReader& anim) {
|
|
|
|
if (ind.IsTime())
|
|
|
|
return ind.GetTime();
|
2016-04-11 07:10:28 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CBoolPOINode nodes[64];
|
|
|
|
CCharAnimTime rem = anim.VGetTimeRemaining();
|
|
|
|
u32 count = anim.VGetBoolPOIList(rem, nodes, 64, 0, 0);
|
|
|
|
const char* cmpStr = ind.GetString();
|
|
|
|
for (u32 i = 0; i < count; ++i) {
|
|
|
|
CBoolPOINode& node = nodes[i];
|
2019-10-01 07:38:03 +00:00
|
|
|
if (node.GetString() != cmpStr || !node.GetValue())
|
2018-12-08 05:30:43 +00:00
|
|
|
continue;
|
|
|
|
return node.GetTime();
|
|
|
|
}
|
2016-04-11 07:10:28 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return {};
|
2016-04-11 07:10:28 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|