mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-16 04:17:03 +00:00
Lots of bug fixes; working CPhazonSuitFilter
This commit is contained in:
@@ -533,17 +533,18 @@ zeus::CTransform CAnimData::GetLocatorTransform(CSegId id, const CCharAnimTime*
|
||||
return {};
|
||||
|
||||
zeus::CTransform ret;
|
||||
if (!x220_31_poseCached)
|
||||
if (time || !x220_31_poseCached)
|
||||
{
|
||||
const_cast<CAnimData*>(this)->RecalcPoseBuilder(time);
|
||||
const_cast<CAnimData*>(this)->x220_31_poseCached = time == nullptr;
|
||||
}
|
||||
|
||||
if (!x220_30_poseBuilt)
|
||||
x2fc_poseBuilder.BuildTransform(id, ret);
|
||||
else
|
||||
{
|
||||
zeus::CMatrix3f rot = x224_pose.GetRotation(id);
|
||||
zeus::CVector3f offset = x224_pose.GetOffset(id);
|
||||
ret.setRotation(rot);
|
||||
ret.origin = offset;
|
||||
ret.setRotation(x224_pose.GetTransformMinusOffset(id));
|
||||
ret.origin = x224_pose.GetOffset(id);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -339,6 +339,7 @@ bool CBitLevelLoader::LoadBool()
|
||||
|
||||
CSegIdToIndexConverter::CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals)
|
||||
{
|
||||
std::fill(std::begin(x0_indices), std::end(x0_indices), -1);
|
||||
for (u32 b=0 ; b<totals.x24_boneChanCount ; ++b)
|
||||
{
|
||||
u16 segId = totals.xc_segIds2[b];
|
||||
@@ -360,13 +361,19 @@ CFBStreamedAnimReader::CFBStreamedAnimReader(const TSubAnimTypeToken<CFBStreamed
|
||||
|
||||
bool CFBStreamedAnimReader::HasOffset(const CSegId& seg) const
|
||||
{
|
||||
return x7c_totals.Prior().x8_hasTrans1[x114_segIdToIndex.SegIdToIndex(seg)];
|
||||
s32 idx = x114_segIdToIndex.SegIdToIndex(seg);
|
||||
if (idx == -1)
|
||||
return false;
|
||||
return x7c_totals.Prior().x8_hasTrans1[idx];
|
||||
}
|
||||
|
||||
zeus::CVector3f CFBStreamedAnimReader::GetOffset(const CSegId& seg) const
|
||||
{
|
||||
const float* af = x7c_totals.Prior().GetFloats(x114_segIdToIndex.SegIdToIndex(seg));
|
||||
const float* bf = x7c_totals.Next().GetFloats(x114_segIdToIndex.SegIdToIndex(seg));
|
||||
s32 idx = x114_segIdToIndex.SegIdToIndex(seg);
|
||||
if (idx == -1)
|
||||
return {};
|
||||
const float* af = x7c_totals.Prior().GetFloats(idx);
|
||||
const float* bf = x7c_totals.Next().GetFloats(idx);
|
||||
zeus::CVector3f a(af[4], af[5], af[6]);
|
||||
zeus::CVector3f b(bf[4], bf[5], bf[6]);
|
||||
return zeus::CVector3f::lerp(a, b, x7c_totals.GetT());
|
||||
@@ -374,8 +381,11 @@ zeus::CVector3f CFBStreamedAnimReader::GetOffset(const CSegId& seg) const
|
||||
|
||||
zeus::CQuaternion CFBStreamedAnimReader::GetRotation(const CSegId& seg) const
|
||||
{
|
||||
const float* af = x7c_totals.Prior().GetFloats(x114_segIdToIndex.SegIdToIndex(seg));
|
||||
const float* bf = x7c_totals.Next().GetFloats(x114_segIdToIndex.SegIdToIndex(seg));
|
||||
s32 idx = x114_segIdToIndex.SegIdToIndex(seg);
|
||||
if (idx == -1)
|
||||
return {};
|
||||
const float* af = x7c_totals.Prior().GetFloats(idx);
|
||||
const float* bf = x7c_totals.Next().GetFloats(idx);
|
||||
zeus::CQuaternion a(af[0], af[1], af[2], af[3]);
|
||||
zeus::CQuaternion b(bf[0], bf[1], bf[2], bf[3]);
|
||||
return zeus::CQuaternion::slerp(a, b, x7c_totals.GetT());
|
||||
@@ -479,33 +489,40 @@ SAdvancementResults CFBStreamedAnimReader::VAdvanceView(const CCharAnimTime& dt)
|
||||
SAdvancementResults res = {};
|
||||
|
||||
CCharAnimTime animDur = x54_source->GetAnimationDuration();
|
||||
if (xc_curTime >= animDur || dt.EqualsZero())
|
||||
if (xc_curTime == animDur)
|
||||
{
|
||||
xc_curTime = CCharAnimTime(0);
|
||||
xc_curTime = CCharAnimTime();
|
||||
x7c_totals.SetTime(x108_bitLoader, xc_curTime);
|
||||
res.x0_remTime = dt;
|
||||
return res;
|
||||
}
|
||||
else if (dt.EqualsZero())
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
zeus::CQuaternion priorQ = GetRotation(3);
|
||||
zeus::CVector3f priorV = GetOffset(3);
|
||||
|
||||
CCharAnimTime nextTime = xc_curTime + dt;
|
||||
if (nextTime > animDur)
|
||||
xc_curTime += dt;
|
||||
CCharAnimTime overTime;
|
||||
if (xc_curTime > animDur)
|
||||
{
|
||||
nextTime = animDur;
|
||||
res.x0_remTime = nextTime - animDur;
|
||||
overTime = xc_curTime - animDur;
|
||||
xc_curTime = animDur;
|
||||
}
|
||||
xc_curTime = nextTime;
|
||||
|
||||
x7c_totals.SetTime(x108_bitLoader, xc_curTime);
|
||||
if (x54_source->HasPOIData())
|
||||
UpdatePOIStates();
|
||||
|
||||
zeus::CQuaternion nextQ = GetRotation(3);
|
||||
zeus::CVector3f nextV = GetOffset(3);
|
||||
|
||||
res.x8_deltas.xc_rotDelta = priorQ.inverse() * nextQ;
|
||||
res.x0_remTime = overTime;
|
||||
res.x8_deltas.xc_rotDelta = nextQ * priorQ.inverse();
|
||||
if (HasOffset(3))
|
||||
res.x8_deltas.x0_posDelta = res.x8_deltas.xc_rotDelta.transform(nextV - priorV);
|
||||
res.x8_deltas.x0_posDelta = nextQ.inverse().transform(nextV - priorV);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -85,10 +85,10 @@ public:
|
||||
|
||||
class CSegIdToIndexConverter
|
||||
{
|
||||
u32 x0_indices[96] = {u32(-1)};
|
||||
s32 x0_indices[96];
|
||||
public:
|
||||
CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals);
|
||||
u32 SegIdToIndex(const CSegId& id) const { return x0_indices[id]; }
|
||||
s32 SegIdToIndex(const CSegId& id) const { return x0_indices[id]; }
|
||||
};
|
||||
|
||||
class CFBStreamedAnimReader : public CAnimSourceReaderBase
|
||||
|
||||
@@ -19,10 +19,10 @@ std::shared_ptr<CAnimTreeNode>
|
||||
CMetaAnimPlay::VGetAnimationTree(const CAnimSysContext& animSys,
|
||||
const CMetaAnimTreeBuildOrders& orders) const
|
||||
{
|
||||
if (orders.x0_)
|
||||
if (orders.x0_recursiveAdvance)
|
||||
{
|
||||
CMetaAnimTreeBuildOrders modOrders;
|
||||
modOrders.PreAdvanceForAll(*orders.x0_);
|
||||
modOrders.PreAdvanceForAll(*orders.x0_recursiveAdvance);
|
||||
return GetAnimationTree(animSys, modOrders);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "CMetaAnimRandom.hpp"
|
||||
#include "CMetaAnimFactory.hpp"
|
||||
#include "CAnimSysContext.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@@ -32,7 +33,16 @@ std::shared_ptr<CAnimTreeNode>
|
||||
CMetaAnimRandom::VGetAnimationTree(const CAnimSysContext& animSys,
|
||||
const CMetaAnimTreeBuildOrders& orders) const
|
||||
{
|
||||
return {};
|
||||
s32 r = animSys.x8_random->Range(1, 100);
|
||||
const std::pair<std::shared_ptr<IMetaAnim>, u32>* useRd = nullptr;
|
||||
for (auto& rd : x4_randomData)
|
||||
{
|
||||
useRd = &rd;
|
||||
if (r <= rd.second)
|
||||
break;
|
||||
}
|
||||
|
||||
return useRd->first->GetAnimationTree(animSys, orders);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ std::shared_ptr<CAnimTreeNode>
|
||||
CMetaAnimSequence::VGetAnimationTree(const CAnimSysContext& animSys,
|
||||
const CMetaAnimTreeBuildOrders& orders) const
|
||||
{
|
||||
if (orders.x0_)
|
||||
if (orders.x0_recursiveAdvance)
|
||||
{
|
||||
CMetaAnimTreeBuildOrders modOrders;
|
||||
modOrders.PreAdvanceForAll(*orders.x0_);
|
||||
modOrders.PreAdvanceForAll(*orders.x0_recursiveAdvance);
|
||||
return GetAnimationTree(animSys, modOrders);
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, cons
|
||||
|
||||
/* Normal Blended */
|
||||
lights->ActivateLights(*model.GetModelInst());
|
||||
flags.m_extendedShader = EExtendedShader::Lighting;
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = alphaColor;
|
||||
x10_animData->Render(model, flags, {}, nullptr);
|
||||
|
||||
@@ -445,7 +445,7 @@ void CModelData::InvSuitDraw(EWhichModel which, const zeus::CTransform& xf, cons
|
||||
|
||||
/* Normal Blended */
|
||||
lights->ActivateLights(model);
|
||||
flags.m_extendedShader = EExtendedShader::Lighting;
|
||||
flags.m_extendedShader = EExtendedShader::ForcedAlpha;
|
||||
flags.x4_color = alphaColor;
|
||||
model.Draw(flags, nullptr, nullptr);
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ std::shared_ptr<CAnimTreeNode>
|
||||
IMetaAnim::GetAnimationTree(const CAnimSysContext& animSys,
|
||||
const CMetaAnimTreeBuildOrders& orders) const
|
||||
{
|
||||
if (orders.x44_)
|
||||
if (orders.x44_singleAdvance)
|
||||
{
|
||||
std::shared_ptr<CAnimTreeNode> tree =
|
||||
VGetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
|
||||
if (orders.x44_->IsTime() || orders.x44_->IsString())
|
||||
if (orders.x44_singleAdvance->IsTime() || orders.x44_singleAdvance->IsString())
|
||||
{
|
||||
CCharAnimTime time = GetTime(*orders.x44_, *tree);
|
||||
CCharAnimTime time = GetTime(*orders.x44_singleAdvance, *tree);
|
||||
AdvanceAnim(*tree, time);
|
||||
}
|
||||
return tree;
|
||||
|
||||
@@ -52,14 +52,14 @@ public:
|
||||
|
||||
struct CMetaAnimTreeBuildOrders
|
||||
{
|
||||
std::experimental::optional<CPreAdvanceIndicator> x0_;
|
||||
std::experimental::optional<CPreAdvanceIndicator> x44_;
|
||||
std::experimental::optional<CPreAdvanceIndicator> x0_recursiveAdvance;
|
||||
std::experimental::optional<CPreAdvanceIndicator> x44_singleAdvance;
|
||||
static CMetaAnimTreeBuildOrders NoSpecialOrders() { return {}; }
|
||||
static CMetaAnimTreeBuildOrders PreAdvanceForAll(const CPreAdvanceIndicator& ind)
|
||||
{
|
||||
CMetaAnimTreeBuildOrders ret;
|
||||
ret.x0_.emplace(ind);
|
||||
ret.x44_.emplace(ind);
|
||||
ret.x0_recursiveAdvance.emplace(ind);
|
||||
ret.x44_singleAdvance.emplace(ind);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user