mirror of https://github.com/AxioDL/metaforce.git
Various CAnimTree implementations
This commit is contained in:
parent
50ee1246cf
commit
758d0f48ff
|
@ -542,7 +542,7 @@ SAdvancementDeltas CAnimData::Advance(float dt, const zeus::CVector3f& scale,
|
||||||
{
|
{
|
||||||
if (node.GetCharacterIndex() == -1 || node.GetCharacterIndex() == x204_charIdx)
|
if (node.GetCharacterIndex() == -1 || node.GetCharacterIndex() == x204_charIdx)
|
||||||
{
|
{
|
||||||
x120_particleDB.StartEffect(node.GetName(), node.GetFlags(), node.GetParticleData(),
|
x120_particleDB.StartEffect(node.GetString(), node.GetFlags(), node.GetParticleData(),
|
||||||
scale, stateMgr, aid, x21c_);
|
scale, stateMgr, aid, x21c_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ CAnimSourceReaderBase::GetUniqueParticlePOIs() const
|
||||||
const std::vector<CParticlePOINode>& particleNodes = x4_sourceInfo->GetParticlePOIStream();
|
const std::vector<CParticlePOINode>& particleNodes = x4_sourceInfo->GetParticlePOIStream();
|
||||||
std::map<std::string, CParticleData::EParentedMode> ret;
|
std::map<std::string, CParticleData::EParentedMode> ret;
|
||||||
for (const CParticlePOINode& node : particleNodes)
|
for (const CParticlePOINode& node : particleNodes)
|
||||||
ret[node.GetName()] = node.GetParticleData().GetParentedMode();
|
ret[node.GetString()] = node.GetParticleData().GetParentedMode();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ CAnimSourceReaderBase::GetUniqueInt32POIs() const
|
||||||
const std::vector<CInt32POINode>& int32Nodes = x4_sourceInfo->GetInt32POIStream();
|
const std::vector<CInt32POINode>& int32Nodes = x4_sourceInfo->GetInt32POIStream();
|
||||||
std::map<std::string, s32> ret;
|
std::map<std::string, s32> ret;
|
||||||
for (const CInt32POINode& node : int32Nodes)
|
for (const CInt32POINode& node : int32Nodes)
|
||||||
ret[node.GetName()] = node.GetValue();
|
ret[node.GetString()] = node.GetValue();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ CAnimSourceReaderBase::GetUniqueBoolPOIs() const
|
||||||
const std::vector<CBoolPOINode>& boolNodes = x4_sourceInfo->GetBoolPOIStream();
|
const std::vector<CBoolPOINode>& boolNodes = x4_sourceInfo->GetBoolPOIStream();
|
||||||
std::map<std::string, bool> ret;
|
std::map<std::string, bool> ret;
|
||||||
for (const CBoolPOINode& node : boolNodes)
|
for (const CBoolPOINode& node : boolNodes)
|
||||||
ret[node.GetName()] = node.GetValue();
|
ret[node.GetString()] = node.GetValue();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,42 +16,69 @@ SAdvancementResults CAnimTreeDoubleChild::VAdvanceView(const CCharAnimTime& a)
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CAnimTreeDoubleChild::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut,
|
u32 CAnimTreeDoubleChild::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut,
|
||||||
u32 capacity, u32 iterator, u32) const
|
u32 capacity, u32 iterator, u32 unk) const
|
||||||
{
|
{
|
||||||
return 0;
|
u32 newCapacity = x14_a->GetBoolPOIList(time, listOut, capacity, iterator, unk);
|
||||||
|
newCapacity += x18_b->GetBoolPOIList(time, listOut, capacity, newCapacity + iterator, unk);
|
||||||
|
if (newCapacity > capacity)
|
||||||
|
newCapacity = capacity;
|
||||||
|
|
||||||
|
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
||||||
|
|
||||||
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CAnimTreeDoubleChild::VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut,
|
u32 CAnimTreeDoubleChild::VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut,
|
||||||
u32 capacity, u32 iterator, u32) const
|
u32 capacity, u32 iterator, u32 unk) const
|
||||||
{
|
{
|
||||||
return 0;
|
u32 newCapacity = x14_a->GetInt32POIList(time, listOut, capacity, iterator, unk);
|
||||||
|
newCapacity += x18_b->GetInt32POIList(time, listOut, capacity, newCapacity + iterator, unk);
|
||||||
|
if (newCapacity > capacity)
|
||||||
|
newCapacity = capacity;
|
||||||
|
|
||||||
|
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
||||||
|
|
||||||
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CAnimTreeDoubleChild::VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut,
|
u32 CAnimTreeDoubleChild::VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut,
|
||||||
u32 capacity, u32 iterator, u32) const
|
u32 capacity, u32 iterator, u32 unk) const
|
||||||
{
|
{
|
||||||
return 0;
|
u32 newCapacity = x14_a->GetParticlePOIList(time, listOut, capacity, iterator, unk);
|
||||||
|
newCapacity += x18_b->GetParticlePOIList(time, listOut, capacity, newCapacity + iterator, unk);
|
||||||
|
if (newCapacity > capacity)
|
||||||
|
newCapacity = capacity;
|
||||||
|
|
||||||
|
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
||||||
|
|
||||||
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CAnimTreeDoubleChild::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut,
|
u32 CAnimTreeDoubleChild::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut,
|
||||||
u32 capacity, u32 iterator, u32) const
|
u32 capacity, u32 iterator, u32 unk) const
|
||||||
{
|
{
|
||||||
return 0;
|
u32 newCapacity = x14_a->GetSoundPOIList(time, listOut, capacity, iterator, unk);
|
||||||
|
newCapacity += x18_b->GetSoundPOIList(time, listOut, capacity, newCapacity + iterator, unk);
|
||||||
|
if (newCapacity > capacity)
|
||||||
|
newCapacity = capacity;
|
||||||
|
|
||||||
|
std::sort(listOut, listOut + newCapacity, CPOINode::compare);
|
||||||
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAnimTreeDoubleChild::VGetBoolPOIState(const char* name) const
|
bool CAnimTreeDoubleChild::VGetBoolPOIState(const char* name) const
|
||||||
{
|
{
|
||||||
return false;
|
return x18_b->VGetBoolPOIState(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 CAnimTreeDoubleChild::VGetInt32POIState(const char* name) const
|
s32 CAnimTreeDoubleChild::VGetInt32POIState(const char* name) const
|
||||||
{
|
{
|
||||||
return 0;
|
return x18_b->VGetBoolPOIState(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CParticleData::EParentedMode CAnimTreeDoubleChild::VGetParticlePOIState(const char* name) const
|
CParticleData::EParentedMode CAnimTreeDoubleChild::VGetParticlePOIState(const char* name) const
|
||||||
{
|
{
|
||||||
return CParticleData::EParentedMode::Initial;
|
return x18_b->VGetParticlePOIState(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimTreeDoubleChild::VSetPhase(float)
|
void CAnimTreeDoubleChild::VSetPhase(float)
|
||||||
|
|
|
@ -11,14 +11,15 @@ class CAnimTreeDoubleChild : public CAnimTreeNode
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<CAnimTreeNode> x14_a;
|
std::shared_ptr<CAnimTreeNode> x14_a;
|
||||||
std::shared_ptr<CAnimTreeNode> x18_b;
|
std::shared_ptr<CAnimTreeNode> x18_b;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAnimTreeDoubleChild(const std::weak_ptr<CAnimTreeNode>& a,
|
CAnimTreeDoubleChild(const std::weak_ptr<CAnimTreeNode>& a, const std::weak_ptr<CAnimTreeNode>& b,
|
||||||
const std::weak_ptr<CAnimTreeNode>& b,
|
|
||||||
const std::string& name);
|
const std::string& name);
|
||||||
SAdvancementResults VAdvanceView(const CCharAnimTime& a);
|
SAdvancementResults VAdvanceView(const CCharAnimTime& a);
|
||||||
u32 VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator, u32) const;
|
u32 VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator, u32) const;
|
||||||
u32 VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32 capacity, u32 iterator, u32) const;
|
u32 VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32 capacity, u32 iterator, u32) const;
|
||||||
u32 VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32 capacity, u32 iterator, u32) const;
|
u32 VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32 capacity, u32 iterator,
|
||||||
|
u32) const;
|
||||||
u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const;
|
u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const;
|
||||||
bool VGetBoolPOIState(const char* name) const;
|
bool VGetBoolPOIState(const char* name) const;
|
||||||
s32 VGetInt32POIState(const char* name) const;
|
s32 VGetInt32POIState(const char* name) const;
|
||||||
|
@ -39,7 +40,6 @@ public:
|
||||||
const std::shared_ptr<CAnimTreeNode>& GetLeftChild() const { return x14_a; }
|
const std::shared_ptr<CAnimTreeNode>& GetLeftChild() const { return x14_a; }
|
||||||
const std::shared_ptr<CAnimTreeNode>& GetRightChild() const { return x18_b; }
|
const std::shared_ptr<CAnimTreeNode>& GetRightChild() const { return x18_b; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __URDE_CANIMTREEDOUBLECHILD_HPP__
|
#endif // __URDE_CANIMTREEDOUBLECHILD_HPP__
|
||||||
|
|
|
@ -24,18 +24,46 @@ CAnimTreeTransition::CAnimTreeTransition(bool b1, const std::weak_ptr<CAnimTreeN
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CCharAnimTime CAnimTreeTransition::VGetTimeRemaining() const { return {}; }
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
CSteadyStateAnimInfo CAnimTreeTransition::VGetSteadyStateAnimInfo() const
|
CSteadyStateAnimInfo CAnimTreeTransition::VGetSteadyStateAnimInfo() const
|
||||||
|
{
|
||||||
|
CSteadyStateAnimInfo bInfo = x18_b->VGetSteadyStateAnimInfo();
|
||||||
|
|
||||||
|
if (x24_ < bInfo.GetDuration())
|
||||||
|
return CSteadyStateAnimInfo(bInfo.IsLooping(), bInfo.GetDuration(), bInfo.GetOffset());
|
||||||
|
return CSteadyStateAnimInfo(bInfo.IsLooping(), x24_, bInfo.GetOffset());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IAnimReader> CAnimTreeTransition::VClone() const
|
||||||
|
{
|
||||||
|
return std::make_shared<CAnimTreeTransition>(x20_31_b1, std::static_pointer_cast<CAnimTreeNode>(x14_a->Clone()),
|
||||||
|
std::static_pointer_cast<CAnimTreeNode>(x18_b->Clone()), x24_, x2c_,
|
||||||
|
x34_, x35_, x1c_flags, x4_name, x36_);
|
||||||
|
}
|
||||||
|
|
||||||
|
SAdvancementResults CAnimTreeTransition::VAdvanceView(const CCharAnimTime& time) const
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IAnimReader> CAnimTreeTransition::VClone() const { return {}; }
|
|
||||||
|
|
||||||
void CAnimTreeTransition::SetBlendingWeight(float w)
|
void CAnimTreeTransition::SetBlendingWeight(float w)
|
||||||
{
|
{
|
||||||
static_cast<CAnimTreeTweenBase*>(x18_b.get())->SetBlendingWeight(w);
|
std::static_pointer_cast<CAnimTreeTweenBase>(x18_b)->SetBlendingWeight(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CAnimTreeTransition::VGetBlendingWeight() const
|
float CAnimTreeTransition::VGetBlendingWeight() const
|
||||||
|
|
|
@ -23,9 +23,11 @@ public:
|
||||||
const CCharAnimTime&, const CCharAnimTime&, bool, bool, int, const std::string&, bool);
|
const CCharAnimTime&, const CCharAnimTime&, bool, bool, int, const std::string&, bool);
|
||||||
CAnimTreeTransition(bool, const std::weak_ptr<CAnimTreeNode>&, const std::weak_ptr<CAnimTreeNode>&,
|
CAnimTreeTransition(bool, const std::weak_ptr<CAnimTreeNode>&, const std::weak_ptr<CAnimTreeNode>&,
|
||||||
const CCharAnimTime&, bool, int, const std::string&);
|
const CCharAnimTime&, bool, int, const std::string&);
|
||||||
|
std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const;
|
||||||
CCharAnimTime VGetTimeRemaining() const;
|
CCharAnimTime VGetTimeRemaining() const;
|
||||||
CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const;
|
CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const;
|
||||||
std::shared_ptr<IAnimReader> VClone() const;
|
std::shared_ptr<IAnimReader> VClone() const;
|
||||||
|
SAdvancementResults VAdvanceView(const CCharAnimTime& a) const;
|
||||||
void SetBlendingWeight(float w);
|
void SetBlendingWeight(float w);
|
||||||
float VGetBlendingWeight() const;
|
float VGetBlendingWeight() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
|
s32 CAnimTreeTweenBase::sAdvancementDepth = 0;
|
||||||
|
|
||||||
CAnimTreeTweenBase::CAnimTreeTweenBase(bool b1, const std::weak_ptr<CAnimTreeNode>& a,
|
CAnimTreeTweenBase::CAnimTreeTweenBase(bool b1, const std::weak_ptr<CAnimTreeNode>& a,
|
||||||
const std::weak_ptr<CAnimTreeNode>& b, int flags, const std::string& name)
|
const std::weak_ptr<CAnimTreeNode>& b, int flags, const std::string& name)
|
||||||
: CAnimTreeDoubleChild(a, b, name), x1c_flags(flags), x20_31_b1(b1)
|
: CAnimTreeDoubleChild(a, b, name), x1c_flags(flags), x20_31_b1(b1)
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace urde
|
||||||
|
|
||||||
class CAnimTreeTweenBase : public CAnimTreeDoubleChild
|
class CAnimTreeTweenBase : public CAnimTreeDoubleChild
|
||||||
{
|
{
|
||||||
|
static s32 sAdvancementDepth;
|
||||||
protected:
|
protected:
|
||||||
int x1c_flags;
|
int x1c_flags;
|
||||||
bool x20_31_b1;
|
bool x20_31_b1;
|
||||||
|
@ -34,6 +35,9 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<IAnimReader> VSimplified();
|
std::shared_ptr<IAnimReader> VSimplified();
|
||||||
bool ShouldCullTree() const { return false; }
|
bool ShouldCullTree() const { return false; }
|
||||||
|
|
||||||
|
static void IncAdvancementDepth() { sAdvancementDepth++; }
|
||||||
|
static void DecAdvancementDepth() { sAdvancementDepth--; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,23 @@ CPOINode::CPOINode(CInputStream& in)
|
||||||
x34_flags(in.readUint32Big())
|
x34_flags(in.readUint32Big())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
bool CPOINode::operator>(const CPOINode& other) const
|
||||||
|
{
|
||||||
|
return x1c_time < other.x1c_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPOINode::operator<(const CPOINode& other) const
|
||||||
|
{
|
||||||
|
return x1c_time > other.x1c_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPOINode::compare(const CPOINode& a, const CPOINode& b)
|
||||||
|
{
|
||||||
|
if (a > b)
|
||||||
|
return 1;
|
||||||
|
return (a < b);
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
u32 _getPOIList(const CCharAnimTime& time,
|
u32 _getPOIList(const CCharAnimTime& time,
|
||||||
T* listOut,
|
T* listOut,
|
||||||
|
|
|
@ -37,13 +37,18 @@ public:
|
||||||
CPOINode(CInputStream& in);
|
CPOINode(CInputStream& in);
|
||||||
virtual ~CPOINode() = default;
|
virtual ~CPOINode() = default;
|
||||||
|
|
||||||
const std::string& GetName() const {return x8_name;}
|
const std::string& GetString() const {return x8_name;}
|
||||||
const CCharAnimTime& GetTime() const {return x1c_time;}
|
const CCharAnimTime& GetTime() const {return x1c_time;}
|
||||||
|
void SetTime(const CCharAnimTime& time) { x1c_time = time; }
|
||||||
EPOIType GetPoiType() const { return x18_type; }
|
EPOIType GetPoiType() const { return x18_type; }
|
||||||
u32 GetIndex() const {return x24_index;}
|
u32 GetIndex() const {return x24_index;}
|
||||||
float GetWeight() const { return x2c_weight; }
|
float GetWeight() const { return x2c_weight; }
|
||||||
u32 GetCharacterIndex() const { return x30_charIdx; }
|
u32 GetCharacterIndex() const { return x30_charIdx; }
|
||||||
u32 GetFlags() const { return x34_flags; }
|
u32 GetFlags() const { return x34_flags; }
|
||||||
|
|
||||||
|
bool operator>(const CPOINode& other) const;
|
||||||
|
bool operator<(const CPOINode& other) const;
|
||||||
|
static bool compare(const CPOINode& a, const CPOINode& b);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
|
@ -47,7 +47,7 @@ CCharAnimTime IMetaAnim::GetTime(const CPreAdvanceIndicator& ind, const IAnimRea
|
||||||
for (u32 i=0 ; i<count ; ++i)
|
for (u32 i=0 ; i<count ; ++i)
|
||||||
{
|
{
|
||||||
CBoolPOINode& node = nodes[i];
|
CBoolPOINode& node = nodes[i];
|
||||||
if (node.GetName().compare(cmpStr) || !node.GetValue())
|
if (node.GetString().compare(cmpStr) || !node.GetValue())
|
||||||
continue;
|
continue;
|
||||||
return node.GetTime();
|
return node.GetTime();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue