metaforce/Runtime/Character/CAnimTreeTransition.cpp

78 lines
2.8 KiB
C++
Raw Normal View History

2016-09-10 04:50:00 +00:00
#include "CAnimTreeTransition.hpp"
namespace urde
{
std::string CAnimTreeTransition::CreatePrimitiveName(const std::weak_ptr<CAnimTreeNode>&,
const std::weak_ptr<CAnimTreeNode>&, float)
{
return {};
}
CAnimTreeTransition::CAnimTreeTransition(bool b1, const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b, const CCharAnimTime& time1,
const CCharAnimTime& time2, bool b2, bool b3, int flags,
const std::string& name, bool b4)
: CAnimTreeTweenBase(b1, a, b, flags, name), x24_(time1), x2c_(time2), x34_(b2), x35_(b3), x36_(b4)
{
}
CAnimTreeTransition::CAnimTreeTransition(bool b1, const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b, const CCharAnimTime& time, bool b2,
int flags, const std::string& name)
: CAnimTreeTweenBase(b1, a, b, flags, name), x24_(time), x34_(b2), x35_(a.lock()->VGetBoolPOIState("Loop"))
{
}
2016-09-11 18:40:33 +00:00
std::shared_ptr<IAnimReader> CAnimTreeTransition::VGetBestUnblendedChild() const
{
std::shared_ptr<IAnimReader> child = x18_b->GetBestUnblendedChild();
return (child ? child : x18_b);
}
CCharAnimTime CAnimTreeTransition::VGetTimeRemaining() const
{
CCharAnimTime time = x24_ * x2c_;
CCharAnimTime bTimeRem = x18_b->VGetTimeRemaining();
if (time < bTimeRem)
return bTimeRem;
return time;
}
2016-09-10 04:50:00 +00:00
CSteadyStateAnimInfo CAnimTreeTransition::VGetSteadyStateAnimInfo() const
{
2016-09-11 18:40:33 +00:00
CSteadyStateAnimInfo bInfo = x18_b->VGetSteadyStateAnimInfo();
if (x24_ < bInfo.GetDuration())
return CSteadyStateAnimInfo(bInfo.IsLooping(), bInfo.GetDuration(), bInfo.GetOffset());
return CSteadyStateAnimInfo(bInfo.IsLooping(), x24_, bInfo.GetOffset());
}
2017-03-01 06:02:54 +00:00
std::unique_ptr<IAnimReader> CAnimTreeTransition::VClone() const
2016-09-11 18:40:33 +00:00
{
2017-03-01 06:02:54 +00:00
return std::make_unique<CAnimTreeTransition>(x20_31_b1, std::static_pointer_cast<CAnimTreeNode>(
std::shared_ptr<IAnimReader>(x14_a->Clone())),
std::static_pointer_cast<CAnimTreeNode>(
std::shared_ptr<IAnimReader>(x18_b->Clone())), x24_, x2c_,
2016-09-11 18:40:33 +00:00
x34_, x35_, x1c_flags, x4_name, x36_);
2016-09-10 04:50:00 +00:00
}
2016-09-11 18:40:33 +00:00
SAdvancementResults CAnimTreeTransition::VAdvanceView(const CCharAnimTime& time) const
{
return {};
}
2016-09-10 04:50:00 +00:00
void CAnimTreeTransition::SetBlendingWeight(float w)
{
2016-09-11 18:40:33 +00:00
std::static_pointer_cast<CAnimTreeTweenBase>(x18_b)->SetBlendingWeight(w);
2016-09-10 04:50:00 +00:00
}
float CAnimTreeTransition::VGetBlendingWeight() const
{
if (x24_.GreaterThanZero())
2017-07-10 04:55:51 +00:00
return (1.f / x24_.GetSeconds()) * x2c_.GetSeconds();
2016-09-10 04:50:00 +00:00
return 0.f;
}
}