2016-09-04 02:27:35 +00:00
|
|
|
#include "CAnimTreeBlend.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string CAnimTreeBlend::CreatePrimitiveName(const std::shared_ptr<CAnimTreeNode>& a,
|
|
|
|
const std::shared_ptr<CAnimTreeNode>& b,
|
|
|
|
float scale)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
CAnimTreeBlend::CAnimTreeBlend(bool b1,
|
|
|
|
const std::shared_ptr<CAnimTreeNode>& a,
|
|
|
|
const std::shared_ptr<CAnimTreeNode>& b,
|
2017-11-13 06:19:18 +00:00
|
|
|
float blendWeight, std::string_view name)
|
2016-09-04 02:27:35 +00:00
|
|
|
: CAnimTreeTweenBase(b1, a, b, 1 | 2, name), x24_blendWeight(blendWeight)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-30 01:04:01 +00:00
|
|
|
SAdvancementResults CAnimTreeBlend::VAdvanceView(const CCharAnimTime& dt)
|
2016-09-04 02:27:35 +00:00
|
|
|
{
|
2018-01-30 01:04:01 +00:00
|
|
|
IncAdvancementDepth();
|
|
|
|
SAdvancementResults resA = x14_a->VAdvanceView(dt);
|
|
|
|
SAdvancementResults resB = x18_b->VAdvanceView(dt);
|
|
|
|
DecAdvancementDepth();
|
|
|
|
if (ShouldCullTree())
|
|
|
|
{
|
|
|
|
if (GetBlendingWeight() < 0.5f)
|
|
|
|
x20_25_cullSelector = 1;
|
|
|
|
else
|
|
|
|
x20_25_cullSelector = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SAdvancementResults& maxRemTime = (resA.x0_remTime < resB.x0_remTime) ? resB : resA;
|
|
|
|
if (x1c_flags & 0x1)
|
|
|
|
{
|
|
|
|
return {maxRemTime.x0_remTime, SAdvancementDeltas::Blend(resA.x8_deltas, resB.x8_deltas,
|
|
|
|
GetBlendingWeight())};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return resB;
|
|
|
|
}
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CCharAnimTime CAnimTreeBlend::VGetTimeRemaining() const
|
|
|
|
{
|
2018-01-30 01:04:01 +00:00
|
|
|
CCharAnimTime remA = x14_a->VGetTimeRemaining();
|
|
|
|
CCharAnimTime remB = x18_b->VGetTimeRemaining();
|
|
|
|
return (remA < remB) ? remB : remA;
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSteadyStateAnimInfo CAnimTreeBlend::VGetSteadyStateAnimInfo() const
|
|
|
|
{
|
2018-01-30 01:04:01 +00:00
|
|
|
CSteadyStateAnimInfo ssA = x14_a->VGetSteadyStateAnimInfo();
|
|
|
|
CSteadyStateAnimInfo ssB = x18_b->VGetSteadyStateAnimInfo();
|
|
|
|
zeus::CVector3f resOffset;
|
|
|
|
if (ssA.GetDuration() < ssB.GetDuration())
|
|
|
|
{
|
|
|
|
resOffset = ssA.GetOffset() * (ssB.GetDuration() / ssA.GetDuration()) * x24_blendWeight +
|
|
|
|
ssB.GetOffset() * (1.f - x24_blendWeight);
|
|
|
|
}
|
|
|
|
else if (ssB.GetDuration() < ssA.GetDuration())
|
|
|
|
{
|
|
|
|
resOffset = ssA.GetOffset() * x24_blendWeight +
|
|
|
|
ssB.GetOffset() * (ssA.GetDuration() / ssB.GetDuration()) * (1.f - x24_blendWeight);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resOffset = ssA.GetOffset() + ssB.GetOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
return {ssA.IsLooping(),
|
|
|
|
(ssA.GetDuration() < ssB.GetDuration()) ? ssB.GetDuration() : ssA.GetDuration(),
|
|
|
|
resOffset};
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
2017-03-01 06:02:54 +00:00
|
|
|
std::unique_ptr<IAnimReader> CAnimTreeBlend::VClone() const
|
2016-09-04 02:27:35 +00:00
|
|
|
{
|
2018-01-30 01:04:01 +00:00
|
|
|
return std::make_unique<CAnimTreeBlend>(x20_24_b1,
|
|
|
|
CAnimTreeNode::Cast(x14_a->Clone()),
|
|
|
|
CAnimTreeNode::Cast(x18_b->Clone()),
|
|
|
|
x24_blendWeight, x4_name);
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CAnimTreeBlend::SetBlendingWeight(float w)
|
|
|
|
{
|
2018-01-30 01:04:01 +00:00
|
|
|
x24_blendWeight = w;
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float CAnimTreeBlend::VGetBlendingWeight() const
|
|
|
|
{
|
2018-01-30 01:04:01 +00:00
|
|
|
return x24_blendWeight;
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|