2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 22:27:41 +00:00

Various imps and stubs

This commit is contained in:
2016-09-13 22:45:46 -07:00
parent 8b23c0538e
commit c20eb76189
26 changed files with 479 additions and 134 deletions

View File

@@ -8,6 +8,18 @@ namespace urde
class CAnimTreeDoubleChild : public CAnimTreeNode
{
public:
class CDoubleChildAdvancementResult
{
CCharAnimTime x0_;
SAdvancementDeltas x8_;
SAdvancementDeltas x24_;
public:
CDoubleChildAdvancementResult(const CCharAnimTime&, const SAdvancementDeltas&, const SAdvancementDeltas);
void GetLeftAdvancementDeltas() const;
void GetRightAdvancementDeltas() const;
void GetTrueAdvancement() const;
};
protected:
std::shared_ptr<CAnimTreeNode> x14_a;
std::shared_ptr<CAnimTreeNode> x18_b;
@@ -32,8 +44,8 @@ public:
std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const;
void VGetWeightedReaders(std::vector<std::pair<float, std::weak_ptr<IAnimReader>>>& out, float w) const;
virtual float VGetLeftChildWeight() const = 0;
float GetLeftChildWeight() const { return VGetLeftChildWeight(); }
//virtual float VGetTotalChildWeight(float) const = 0;
//float GetTotalChildWeight(float f) const { return VGetTotalChildWeight(f); }
virtual float VGetRightChildWeight() const = 0;
float GetRightChildWeight() const { return VGetRightChildWeight(); }

View File

@@ -1,13 +0,0 @@
#ifndef __URDE_CANIMTREESCALE_HPP__
#define __URDE_CANIMTREESCALE_HPP__
namespace urde
{
class CAnimTreeScale
{
};
}
#endif // __URDE_CANIMTREESCALE_HPP__

View File

@@ -5,6 +5,7 @@ namespace urde
CAnimTreeSingleChild::CAnimTreeSingleChild(const std::weak_ptr<CAnimTreeNode>& node, const std::string& name)
: CAnimTreeNode(name)
, x14_child(node.lock())
{
}

View File

@@ -0,0 +1,50 @@
#include "CAnimTreeTimeScale.hpp"
namespace urde
{
CAnimTreeTimeScale::CAnimTreeTimeScale(const std::weak_ptr<CAnimTreeNode>& node, float scale, const std::string& name)
: CAnimTreeSingleChild(node, name)
, x18_timeScale(new CConstantAnimationTimeScale(scale))
{
}
std::string CAnimTreeTimeScale::CreatePrimitiveName(const std::weak_ptr<CAnimTreeNode>&, float, const CCharAnimTime&, float)
{
return {};
}
CCharAnimTime CAnimTreeTimeScale::GetRealLifeTime(const CCharAnimTime& time) const
{
CCharAnimTime timeRem = x14_child->VGetTimeRemaining();
CCharAnimTime tmp = std::min(timeRem, time);
if (x28_ > CCharAnimTime())
{
if (tmp < CCharAnimTime(x28_ * x20_))
return x18_timeScale->TimeScaleIntegral(x20_, x20_ + tmp);
else
{
CCharAnimTime integral = x18_timeScale->TimeScaleIntegral(x20_, x28_);
if (integral > tmp)
return x18_timeScale->FindUpperLimit(x20_, tmp) * x20_;
else
return integral + (integral * tmp);
}
}
return tmp;
}
void CAnimTreeTimeScale::VSetPhase(float phase)
{
x14_child->VSetPhase(phase);
}
std::shared_ptr<IAnimReader> CAnimTreeTimeScale::VSimplified()
{
return {};
}
}

View File

@@ -1,11 +1,25 @@
#ifndef __URDE_CANIMTREETIMESCALE_HPP__
#define __URDE_CANIMTREETIMESCALE_HPP__
#include "CAnimTreeSingleChild.hpp"
#include "CConstantAnimationTimeScale.hpp"
namespace urde
{
class CAnimTreeTimeScale
class CAnimTreeTimeScale : public CAnimTreeSingleChild
{
std::unique_ptr<CConstantAnimationTimeScale> x18_timeScale;
CCharAnimTime x20_;
CCharAnimTime x28_;
public:
CAnimTreeTimeScale(const std::weak_ptr<CAnimTreeNode>&, float, const std::string&);
static std::string CreatePrimitiveName(const std::weak_ptr<CAnimTreeNode>&, float, const CCharAnimTime&, float);
CCharAnimTime GetRealLifeTime(const CCharAnimTime&) const;
void VSetPhase(float);
std::shared_ptr<IAnimReader> VSimplified();
};
}

View File

@@ -11,10 +11,11 @@ CAnimTreeTweenBase::CAnimTreeTweenBase(bool b1, const std::weak_ptr<CAnimTreeNod
{
}
void CAnimTreeTweenBase::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const
/*void CAnimTreeTweenBase::VGetTotalChildWeight(float t) const
{
}*/
}
void CAnimTreeTweenBase::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const {}
void CAnimTreeTweenBase::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut,
const CCharAnimTime& time) const
@@ -23,21 +24,30 @@ void CAnimTreeTweenBase::VGetSegStatementSet(const CSegIdList& list, CSegStateme
bool CAnimTreeTweenBase::VHasOffset(const CSegId& seg) const
{
return false;
return (x14_a->VHasOffset(seg) || x18_b->VHasOffset(seg));
}
zeus::CVector3f CAnimTreeTweenBase::VGetOffset(const CSegId& seg) const
{
return {};
const float weight = GetBlendingWeight();
if (weight >= 1.0f)
return x18_b->VGetOffset(seg);
const zeus::CVector3f oA = x14_a->VGetOffset(seg);
const zeus::CVector3f oB = x18_b->VGetOffset(seg);
return zeus::CVector3f::lerp(oA, oB, weight);
}
zeus::CQuaternion CAnimTreeTweenBase::VGetRotation(const CSegId& seg) const
{
return {};
const float weight = GetBlendingWeight();
if (weight >= 1.0f)
return x18_b->VGetRotation(seg);
const zeus::CQuaternion qA = x14_a->VGetRotation(seg);
const zeus::CQuaternion qB = x18_b->VGetRotation(seg);
return zeus::CQuaternion::slerp(qA, qB, weight);
}
std::shared_ptr<IAnimReader> CAnimTreeTweenBase::VSimplified()
{
return {};
}
std::shared_ptr<IAnimReader> CAnimTreeTweenBase::VSimplified() { return {}; }
}

View File

@@ -24,7 +24,7 @@ public:
float GetBlendingWeight() const { return VGetBlendingWeight(); }
float VGetLeftChildWeight() const { return 1.f - GetBlendingWeight(); }
//void VGetTotalChildWeight(float) const;
float VGetRightChildWeight() const { return GetBlendingWeight(); }
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const;

View File

@@ -9,36 +9,36 @@ namespace urde
CCharAnimTime CCharAnimTime::Infinity()
{
CCharAnimTime ret(1.f);
ret.m_type = Type::Infinity;
ret.x4_type = EType::Infinity;
return ret;
}
bool CCharAnimTime::EqualsZero() const
{
if (m_type == Type::ZeroIncreasing || m_type == Type::ZeroSteady || m_type == Type::ZeroDecreasing)
if (x4_type == EType::ZeroIncreasing || x4_type == EType::ZeroSteady || x4_type == EType::ZeroDecreasing)
return false;
return (m_time == 0.f);
return (x0_time == 0.f);
}
bool CCharAnimTime::EpsilonZero() const
{
return (std::fabs(m_time) < FLT_EPSILON);
return (std::fabs(x0_time) < FLT_EPSILON);
}
bool CCharAnimTime::GreaterThanZero() const
{
if (EqualsZero())
return false;
return (m_time > 0.f);
return (x0_time > 0.f);
}
bool CCharAnimTime::operator ==(const CCharAnimTime& other) const
{
if (m_type == Type::NonZero)
if (x4_type == EType::NonZero)
{
if (other.m_type == Type::NonZero)
return m_time == other.m_time;
if (other.x4_type == EType::NonZero)
return x0_time == other.x0_time;
return !other.EqualsZero();
}
@@ -47,18 +47,18 @@ bool CCharAnimTime::operator ==(const CCharAnimTime& other) const
if (other.EqualsZero())
{
int type = -1;
if (m_type != Type::ZeroDecreasing)
if (x4_type != EType::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
if (x4_type != EType::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
if (other.x4_type != EType::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
if (other.x4_type != EType::ZeroSteady)
otherType = 1;
else
otherType = 0;
@@ -69,8 +69,8 @@ bool CCharAnimTime::operator ==(const CCharAnimTime& other) const
return false;
}
if (other.m_type == Type::Infinity)
return m_time * other.m_time < 0.f;
if (other.x4_type == EType::Infinity)
return x0_time * other.x0_time < 0.f;
return false;
}
@@ -103,14 +103,14 @@ bool CCharAnimTime::operator >(const CCharAnimTime& other) const
bool CCharAnimTime::operator <(const CCharAnimTime& other) const
{
if (m_type == Type::NonZero)
if (x4_type == EType::NonZero)
{
if (other.m_type == Type::NonZero)
return m_time < other.m_time;
if (other.x4_type == EType::NonZero)
return x0_time < other.x0_time;
if (other.EqualsZero())
return m_time < 0.f;
return x0_time < 0.f;
else
return other.m_time > 0.f;
return other.x0_time > 0.f;
}
if (EqualsZero())
@@ -118,18 +118,18 @@ bool CCharAnimTime::operator <(const CCharAnimTime& other) const
if (other.EqualsZero())
{
int type = -1;
if (m_type != Type::ZeroDecreasing)
if (x4_type != EType::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
if (x4_type != EType::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
if (other.x4_type != EType::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
if (other.x4_type != EType::ZeroSteady)
otherType = 1;
else
otherType = 0;
@@ -138,15 +138,15 @@ bool CCharAnimTime::operator <(const CCharAnimTime& other) const
return type < otherType;
}
if (other.m_type == Type::NonZero)
return other.m_time > 0.f;
return other.m_time < 0.f;
if (other.x4_type == EType::NonZero)
return other.x0_time > 0.f;
return other.x0_time < 0.f;
}
else
{
if (m_type == Type::Infinity)
return m_time < 0.f && other.m_time > 0.f;
return m_time < other.m_time;
if (x4_type == EType::Infinity)
return x0_time < 0.f && other.x0_time > 0.f;
return x0_time < other.x0_time;
}
}
@@ -164,33 +164,33 @@ CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other)
CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity)
{
if (other.m_time != m_time)
if (other.x0_time != x0_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
else if (x4_type == EType::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
else if (other.x4_type == EType::Infinity)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time + other.m_time);
return CCharAnimTime(x0_time + other.x0_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
if (x4_type != EType::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
if (x4_type != EType::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
if (other.x4_type != EType::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
if (other.x4_type != EType::ZeroSteady)
otherType = 1;
else
otherType = 0;
@@ -201,11 +201,11 @@ CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other)
CCharAnimTime ret;
if (otherType == -1)
ret.m_type = Type::ZeroDecreasing;
ret.x4_type = EType::ZeroDecreasing;
else if (otherType == 0)
ret.m_type = Type::ZeroSteady;
ret.x4_type = EType::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
ret.x4_type = EType::ZeroIncreasing;
return ret;
}
@@ -218,37 +218,37 @@ CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other)
CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity)
{
if (other.m_time == m_time)
if (other.x0_time == x0_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
else if (x4_type == EType::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
else if (other.x4_type == EType::Infinity)
{
CCharAnimTime ret(-other.m_time);
ret.m_type = Type::Infinity;
CCharAnimTime ret(-other.x0_time);
ret.x4_type = EType::Infinity;
return ret;
}
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time - other.m_time);
return CCharAnimTime(x0_time - other.x0_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
if (x4_type != EType::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
if (x4_type != EType::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
if (other.x4_type != EType::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
if (other.x4_type != EType::ZeroSteady)
otherType = 1;
else
otherType = 0;
@@ -257,44 +257,44 @@ CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other)
CCharAnimTime ret;
type -= otherType;
if (type == -1)
ret.m_type = Type::ZeroDecreasing;
ret.x4_type = EType::ZeroDecreasing;
else if (type == 0)
ret.m_type = Type::ZeroSteady;
ret.x4_type = EType::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
ret.x4_type = EType::ZeroIncreasing;
return ret;
}
CCharAnimTime CCharAnimTime::operator*(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
if (x4_type == EType::Infinity && other.x4_type == EType::Infinity)
{
if (other.m_time != m_time)
if (other.x0_time != x0_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
else if (x4_type == EType::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
else if (other.x4_type == EType::Infinity)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time * other.m_time);
return CCharAnimTime(x0_time * other.x0_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
if (x4_type != EType::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
if (x4_type != EType::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
if (other.x4_type != EType::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
if (other.x4_type != EType::ZeroSteady)
otherType = 1;
else
otherType = 0;
@@ -305,11 +305,11 @@ CCharAnimTime CCharAnimTime::operator*(const CCharAnimTime& other)
CCharAnimTime ret;
if (otherType == -1)
ret.m_type = Type::ZeroDecreasing;
ret.x4_type = EType::ZeroDecreasing;
else if (otherType == 0)
ret.m_type = Type::ZeroSteady;
ret.x4_type = EType::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
ret.x4_type = EType::ZeroIncreasing;
return ret;
}
@@ -320,14 +320,14 @@ CCharAnimTime CCharAnimTime::operator*(const float& other)
return ret;
if (!EqualsZero())
return CCharAnimTime(m_time * other);
return CCharAnimTime(x0_time * other);
if (other > 0.f)
return *this;
else if (other == 0.f)
return ret;
ret.m_type = m_type;
ret.x4_type = x4_type;
return ret;
}
@@ -336,7 +336,7 @@ float CCharAnimTime::operator/(const CCharAnimTime& other)
if (other.EqualsZero())
return 0.f;
return m_time / other.m_time;
return x0_time / other.x0_time;
}
}

View File

@@ -8,26 +8,35 @@ namespace urde
class CCharAnimTime
{
float m_time = 0.f;
enum class Type
public:
enum class EType
{
NonZero,
ZeroIncreasing,
ZeroSteady,
ZeroDecreasing,
Infinity
} m_type = Type::ZeroSteady;
};
private:
float x0_time = 0.f;
EType x4_type = EType::ZeroSteady;
public:
CCharAnimTime() = default;
CCharAnimTime(CInputStream& in)
: m_time(in.readFloatBig()),
m_type(Type(in.readUint32Big())) {}
: x0_time(in.readFloatBig()),
x4_type(EType(in.readUint32Big())) {}
CCharAnimTime(float time)
: m_time(time),
m_type(m_time != 0.f ? Type::NonZero : Type::ZeroSteady) {}
: x0_time(time),
x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {}
CCharAnimTime(EType type, const float& t)
: x0_time(t)
, x4_type(type)
{
}
static CCharAnimTime Infinity();
operator float() const {return m_time;}
operator float() const {return x0_time;}
bool EqualsZero() const;
bool EpsilonZero() const;

View File

@@ -0,0 +1,19 @@
#include "CConstantAnimationTimeScale.hpp"
namespace urde
{
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; }
std::unique_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VClone() const
{
return std::make_unique<CConstantAnimationTimeScale>(x4_);
}
std::unique_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const
{
return Clone();
}
}

View File

@@ -0,0 +1,22 @@
#ifndef __URDE_CONSTANTANIMATIONTIMESCALE_HPP__
#define __URDE_CONSTANTANIMATIONTIMESCALE_HPP__
#include "IVaryingAnimationTimeScale.hpp"
namespace urde
{
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale
{
private:
float x4_;
public:
CConstantAnimationTimeScale(float f) : x4_(f) {}
u32 GetType() const { return 0; }
float VTimeScaleIntegral(const float &, const float &) const;
float VFindUpperLimit(const float &, const float &) const;
std::unique_ptr<IVaryingAnimationTimeScale> VClone() const;
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float &) const;
};
}
#endif // __URDE_CONSTANTANIMATIONTIMESCALE_HPP__

View File

@@ -0,0 +1,31 @@
#ifndef __URDE_CLINEARANIMATIONTIMESCALE_HPP__
#define __URDE_CLINEARANIMATIONTIMESCALE_HPP__
#include "IVaryingAnimationTimeScale.hpp"
namespace urde
{
class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale
{
public:
class CFunctionDescription
{
public:
CFunctionDescription(const float&, const float&, const float&);
CFunctionDescription FunctionMirroredAround(const float&) const;
};
private:
public:
CLinearAnimationTimeScale(const CCharAnimTime&, float, const CCharAnimTime&, float);
u32 GetType() const { return 1; }
float VTimeScaleIntegral(const float &, const float &) const { return 0.f; }
float VFindUpperLimit(const float &, const float &) const { return 0.f; }
std::unique_ptr<IVaryingAnimationTimeScale> VClone() { return {}; }
std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float &) const { return {}; }
float TimeScaleIntegralWithSortedLimits(const CFunctionDescription&, const float&, const float&);
float GetScale(const CFunctionDescription&, const float&);
};
}
#endif // __URDE_CLINEARANIMATIONTIMESCALE_HPP__

View File

@@ -7,6 +7,9 @@ set(CHARACTER_SOURCES
CCharAnimTime.hpp CCharAnimTime.cpp
IMetaAnim.hpp IMetaAnim.cpp
IMetaTrans.hpp
IVaryingAnimationTimeScale.hpp
CLinearAnimationTimeScale.hpp CLinearAnimationTimeScale.cpp
CConstantAnimationTimeScale.hpp CConstantAnimationTimeScale.cpp
CAnimationDatabase.hpp
CAnimationDatabaseGame.hpp CAnimationDatabaseGame.cpp
CTransitionDatabase.hpp
@@ -53,7 +56,6 @@ set(CHARACTER_SOURCES
CTreeUtils.hpp CTreeUtils.cpp
CAnimTreeBlend.hpp CAnimTreeBlend.cpp
CAnimTreeNode.hpp CAnimTreeNode.cpp
CAnimTreeScale.hpp CAnimTreeScale.cpp
CAnimTreeTimeScale.hpp CAnimTreeTimeScale.cpp
CAnimTreeTransition.hpp CAnimTreeTransition.cpp
CAnimTreeTweenBase.hpp CAnimTreeTweenBase.cpp

View File

@@ -0,0 +1,29 @@
#ifndef __URDE_IVARYINGANIMATIONTIMESCALE_HPP__
#define __URDE_IVARYINGANIMATIONTIMESCALE_HPP__
#include "CCharAnimTime.hpp"
namespace urde
{
class IVaryingAnimationTimeScale
{
public:
virtual u32 GetType() const = 0;
virtual float VTimeScaleIntegral(const float&, const float&) const = 0;
virtual float VFindUpperLimit(const float&, const float&) const = 0;
virtual std::unique_ptr<IVaryingAnimationTimeScale> VClone() const = 0;
virtual std::unique_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const = 0;
CCharAnimTime FindUpperLimit(const CCharAnimTime& a, const CCharAnimTime& b) const
{
return VFindUpperLimit(a, b);
}
CCharAnimTime TimeScaleIntegral(const CCharAnimTime& a, const CCharAnimTime& b) const
{
return VTimeScaleIntegral(a, b);
}
std::unique_ptr<IVaryingAnimationTimeScale> Clone() const { return VClone(); }
};
}
#endif // __URDE_IVARYINGANIMATIONTIMESCALE_HPP__