2016-09-04 02:27:35 +00:00
|
|
|
#include "CAnimTreeBlend.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-09-04 02:27:35 +00:00
|
|
|
|
|
|
|
std::string CAnimTreeBlend::CreatePrimitiveName(const std::shared_ptr<CAnimTreeNode>& a,
|
2018-12-08 05:30:43 +00:00
|
|
|
const std::shared_ptr<CAnimTreeNode>& b, float scale) {
|
|
|
|
return "";
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAnimTreeBlend::CAnimTreeBlend(bool b1, const std::shared_ptr<CAnimTreeNode>& a,
|
|
|
|
const std::shared_ptr<CAnimTreeNode>& b, float blendWeight, std::string_view name)
|
|
|
|
: CAnimTreeTweenBase(b1, a, b, 1 | 2, name), x24_blendWeight(blendWeight) {}
|
2016-09-04 02:27:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
SAdvancementResults CAnimTreeBlend::VAdvanceView(const CCharAnimTime& dt) {
|
|
|
|
IncAdvancementDepth();
|
|
|
|
SAdvancementResults resA = x14_a->VAdvanceView(dt);
|
|
|
|
SAdvancementResults resB = x18_b->VAdvanceView(dt);
|
|
|
|
DecAdvancementDepth();
|
|
|
|
if (ShouldCullTree()) {
|
|
|
|
if (GetBlendingWeight() < 0.5f)
|
|
|
|
x20_25_cullSelector = 1;
|
2018-01-30 01:04:01 +00:00
|
|
|
else
|
2018-12-08 05:30:43 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CCharAnimTime CAnimTreeBlend::VGetTimeRemaining() const {
|
|
|
|
CCharAnimTime remA = x14_a->VGetTimeRemaining();
|
|
|
|
CCharAnimTime remB = x18_b->VGetTimeRemaining();
|
|
|
|
return (remA < remB) ? remB : remA;
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CSteadyStateAnimInfo CAnimTreeBlend::VGetSteadyStateAnimInfo() const {
|
|
|
|
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();
|
|
|
|
}
|
2018-01-30 01:04:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return {ssA.IsLooping(), (ssA.GetDuration() < ssB.GetDuration()) ? ssB.GetDuration() : ssA.GetDuration(), resOffset};
|
2016-09-04 02:27:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<IAnimReader> CAnimTreeBlend::VClone() const {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CAnimTreeBlend::SetBlendingWeight(float w) { x24_blendWeight = w; }
|
2016-09-04 02:27:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
float CAnimTreeBlend::VGetBlendingWeight() const { return x24_blendWeight; }
|
2016-09-04 02:27:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|