metaforce/Runtime/Character/CTimeScaleFunctions.cpp

81 lines
2.6 KiB
C++
Raw Normal View History

2016-04-11 03:59:54 +00:00
#include "CTimeScaleFunctions.hpp"
#include "CCharAnimTime.hpp"
namespace urde
{
std::shared_ptr<IVaryingAnimationTimeScale> IVaryingAnimationTimeScale::Clone() const
{
return VClone();
}
float CConstantAnimationTimeScale::VTimeScaleIntegral(const float& a, const float& b) const { return (b - a) * x4_; }
float CConstantAnimationTimeScale::VFindUpperLimit(const float& a, const float& b) const { return (b / x4_) + a; }
2016-04-11 03:59:54 +00:00
std::shared_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VClone() const
{
CConstantAnimationTimeScale* ret = new CConstantAnimationTimeScale(x4_);
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
2016-04-11 03:59:54 +00:00
}
std::shared_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const
2016-04-11 03:59:54 +00:00
{
return Clone();
2016-04-11 03:59:54 +00:00
}
float CLinearAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
2016-04-11 03:59:54 +00:00
{
return 0.f;
2016-04-11 03:59:54 +00:00
}
float CLinearAnimationTimeScale::TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc,
2016-04-11 03:59:54 +00:00
const float&, const float&)
{
return 0.f;
2016-04-11 03:59:54 +00:00
}
float CLinearAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
2016-04-11 03:59:54 +00:00
{
return 0.f;
2016-04-11 03:59:54 +00:00
}
float CLinearAnimationTimeScale::FindUpperLimitFromRoot(const CFunctionDescription& desc,
2016-04-11 03:59:54 +00:00
const float&, const float&)
{
return 0.f;
2016-04-11 03:59:54 +00:00
}
std::shared_ptr<IVaryingAnimationTimeScale> CLinearAnimationTimeScale::VClone() const
{
CCharAnimTime timeA(x10_);
CCharAnimTime timeB(xc_);
CLinearAnimationTimeScale* ret = new CLinearAnimationTimeScale();
float f30 = x4_ * xc_ + x8_;
2017-07-10 04:55:51 +00:00
ret->x4_ = (x4_ * x10_ + x8_ - f30) / timeB.GetSeconds();
ret->x8_ = -((x4_ * x10_ + x8_ - f30) / (timeA - timeB).GetSeconds() * timeB.GetSeconds() - f30);
ret->xc_ = timeB.GetSeconds();
ret->x10_ = timeA.GetSeconds();
2016-04-11 03:59:54 +00:00
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
}
std::shared_ptr<IVaryingAnimationTimeScale>
CLinearAnimationTimeScale::VGetFunctionMirrored(const float& parm) const
{
float f27 = -(x4_ * parm * 2.f - x8_);
float f31 = -x4_ * parm * 2.f - x10_ + f27;
CCharAnimTime timeA(2.f * parm - xc_);
CCharAnimTime timeB(2.f * parm - x10_);
CLinearAnimationTimeScale* ret = new CLinearAnimationTimeScale();
2017-07-10 04:55:51 +00:00
ret->x4_ = (-x4_ * 2.f * parm - xc_ + f27 - f31) / (timeA - timeB).GetSeconds();
ret->x8_ = -(((-x4_ * 2.f * parm - xc_ + f27 - f31) /
(timeA - timeB).GetSeconds()) * timeB.GetSeconds() - f31);
ret->xc_ = timeB.GetSeconds();
ret->x10_ = timeA.GetSeconds();
2016-04-11 03:59:54 +00:00
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
}
}