2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
2020-03-31 07:05:05 +00:00
|
|
|
#include <string_view>
|
2019-09-28 02:53:03 +00:00
|
|
|
|
|
|
|
#include "Runtime/CToken.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/Character/CAllFormatsAnimSource.hpp"
|
|
|
|
#include "Runtime/Character/CCharAnimTime.hpp"
|
|
|
|
#include "Runtime/Character/CParticleData.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CQuaternion.hpp>
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2016-04-11 03:59:54 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-11 03:59:54 +00:00
|
|
|
class CBoolPOINode;
|
|
|
|
class CInt32POINode;
|
|
|
|
class CParticlePOINode;
|
2019-09-28 02:53:03 +00:00
|
|
|
class CSegId;
|
2016-04-11 03:59:54 +00:00
|
|
|
class CSegIdList;
|
|
|
|
class CSegStatementSet;
|
2019-09-28 02:53:03 +00:00
|
|
|
class CSoundPOINode;
|
2016-04-11 03:59:54 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SAdvancementDeltas {
|
|
|
|
zeus::CVector3f x0_posDelta;
|
|
|
|
zeus::CQuaternion xc_rotDelta;
|
2018-01-04 04:17:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static SAdvancementDeltas Interpolate(const SAdvancementDeltas& a, const SAdvancementDeltas& b, float oldWeight,
|
|
|
|
float newWeight);
|
|
|
|
static SAdvancementDeltas Blend(const SAdvancementDeltas& a, const SAdvancementDeltas& b, float w);
|
2016-04-14 21:42:47 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SAdvancementResults {
|
|
|
|
CCharAnimTime x0_remTime;
|
|
|
|
SAdvancementDeltas x8_deltas;
|
2016-04-11 03:59:54 +00:00
|
|
|
};
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CSteadyStateAnimInfo {
|
|
|
|
CCharAnimTime x0_duration;
|
|
|
|
zeus::CVector3f x8_offset;
|
|
|
|
bool x14_looping = false;
|
2016-08-27 21:16:44 +00:00
|
|
|
|
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CSteadyStateAnimInfo(bool looping, const CCharAnimTime& duration, const zeus::CVector3f& offset)
|
|
|
|
: x0_duration(duration), x8_offset(offset), x14_looping(looping) {}
|
2016-08-27 21:16:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
const CCharAnimTime& GetDuration() const { return x0_duration; }
|
|
|
|
const zeus::CVector3f& GetOffset() const { return x8_offset; }
|
|
|
|
bool IsLooping() const { return x14_looping; }
|
2016-04-16 03:24:25 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct CAnimTreeEffectiveContribution {
|
|
|
|
float x0_contributionWeight;
|
|
|
|
std::string x4_name;
|
|
|
|
CSteadyStateAnimInfo x14_ssInfo;
|
|
|
|
CCharAnimTime x2c_remTime;
|
|
|
|
u32 x34_dbIdx;
|
|
|
|
|
2016-08-27 04:54:53 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CAnimTreeEffectiveContribution(float cweight, std::string_view name, const CSteadyStateAnimInfo& ssInfo,
|
|
|
|
const CCharAnimTime& remTime, u32 dbIdx)
|
|
|
|
: x0_contributionWeight(cweight), x4_name(name), x14_ssInfo(ssInfo), x2c_remTime(remTime), x34_dbIdx(dbIdx) {}
|
|
|
|
float GetContributionWeight() const { return x0_contributionWeight; }
|
|
|
|
std::string_view GetPrimitiveName() const { return x4_name; }
|
|
|
|
const CSteadyStateAnimInfo& GetSteadyStateAnimInfo() const { return x14_ssInfo; }
|
|
|
|
const CCharAnimTime& GetTimeRemaining() const { return x2c_remTime; }
|
|
|
|
u32 GetAnimDatabaseIndex() const { return x34_dbIdx; }
|
2016-08-27 04:54:53 +00:00
|
|
|
};
|
|
|
|
|
2016-08-26 22:23:59 +00:00
|
|
|
template <class T>
|
2018-12-08 05:30:43 +00:00
|
|
|
class TSubAnimTypeToken : public TLockedToken<CAllFormatsAnimSource> {};
|
2016-09-04 22:47:48 +00:00
|
|
|
|
|
|
|
template <>
|
2020-03-13 08:11:17 +00:00
|
|
|
class TSubAnimTypeToken<CAnimSource> : public TLockedToken<CAnimSource> {
|
2016-09-04 22:47:48 +00:00
|
|
|
public:
|
2020-03-31 03:52:22 +00:00
|
|
|
// Converting constructor
|
|
|
|
TSubAnimTypeToken(const TLockedToken<CAllFormatsAnimSource>& token) : TLockedToken<CAnimSource>(token) {}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-03-31 10:11:08 +00:00
|
|
|
CAnimSource* GetObj() override {
|
2020-03-13 08:11:17 +00:00
|
|
|
CAllFormatsAnimSource* source = reinterpret_cast<CAllFormatsAnimSource*>(TLockedToken<CAnimSource>::GetObj());
|
2018-12-08 05:30:43 +00:00
|
|
|
return &source->GetAsCAnimSource();
|
|
|
|
}
|
2020-03-13 08:11:17 +00:00
|
|
|
|
2020-03-31 10:11:08 +00:00
|
|
|
const CAnimSource* GetObj() const override {
|
2020-03-13 08:11:17 +00:00
|
|
|
return const_cast<TSubAnimTypeToken<CAnimSource>*>(this)->GetObj();
|
|
|
|
}
|
2016-09-04 22:47:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
2020-03-13 08:11:17 +00:00
|
|
|
class TSubAnimTypeToken<CFBStreamedCompression> : public TLockedToken<CFBStreamedCompression> {
|
2016-09-04 22:47:48 +00:00
|
|
|
public:
|
2020-03-31 03:52:22 +00:00
|
|
|
// Converting constructor
|
|
|
|
TSubAnimTypeToken(const TLockedToken<CAllFormatsAnimSource>& token) : TLockedToken<CFBStreamedCompression>(token) {}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-03-31 10:11:08 +00:00
|
|
|
CFBStreamedCompression* GetObj() override {
|
2020-03-13 08:11:17 +00:00
|
|
|
CAllFormatsAnimSource* source =
|
|
|
|
reinterpret_cast<CAllFormatsAnimSource*>(TLockedToken<CFBStreamedCompression>::GetObj());
|
2018-12-08 05:30:43 +00:00
|
|
|
return &source->GetAsCFBStreamedCompression();
|
|
|
|
}
|
2020-03-13 08:11:17 +00:00
|
|
|
|
2020-03-31 10:11:08 +00:00
|
|
|
const CFBStreamedCompression* GetObj() const override {
|
2020-03-13 08:11:17 +00:00
|
|
|
return const_cast<TSubAnimTypeToken<CFBStreamedCompression>*>(this)->GetObj();
|
|
|
|
}
|
2016-09-04 22:47:48 +00:00
|
|
|
};
|
2016-08-26 22:23:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class IAnimReader {
|
2016-04-11 03:59:54 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual ~IAnimReader() = default;
|
|
|
|
virtual bool IsCAnimTreeNode() const { return false; }
|
|
|
|
virtual SAdvancementResults VAdvanceView(const CCharAnimTime& a) = 0;
|
|
|
|
virtual CCharAnimTime VGetTimeRemaining() const = 0;
|
|
|
|
virtual CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const = 0;
|
|
|
|
virtual bool VHasOffset(const CSegId& seg) const = 0;
|
|
|
|
virtual zeus::CVector3f VGetOffset(const CSegId& seg) const = 0;
|
|
|
|
virtual zeus::CQuaternion VGetRotation(const CSegId& seg) const = 0;
|
2020-04-10 21:18:09 +00:00
|
|
|
virtual size_t VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, size_t capacity, size_t iterator,
|
|
|
|
u32) const = 0;
|
|
|
|
virtual size_t VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, size_t capacity, size_t iterator,
|
|
|
|
u32) const = 0;
|
|
|
|
virtual size_t VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, size_t capacity, size_t iterator,
|
|
|
|
u32) const = 0;
|
|
|
|
virtual size_t VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, size_t capacity, size_t iterator,
|
2018-12-08 05:30:43 +00:00
|
|
|
u32) const = 0;
|
2020-03-31 07:05:05 +00:00
|
|
|
virtual bool VGetBoolPOIState(std::string_view name) const = 0;
|
|
|
|
virtual s32 VGetInt32POIState(std::string_view name) const = 0;
|
|
|
|
virtual CParticleData::EParentedMode VGetParticlePOIState(std::string_view name) const = 0;
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const = 0;
|
|
|
|
virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut,
|
|
|
|
const CCharAnimTime& time) const = 0;
|
|
|
|
virtual std::unique_ptr<IAnimReader> VClone() const = 0;
|
2019-06-12 02:05:17 +00:00
|
|
|
virtual std::optional<std::unique_ptr<IAnimReader>> VSimplified() { return {}; }
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual void VSetPhase(float) = 0;
|
|
|
|
virtual SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
|
|
|
|
|
2020-04-10 21:18:09 +00:00
|
|
|
size_t GetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, size_t capacity, size_t iterator, u32) const;
|
|
|
|
size_t GetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, size_t capacity, size_t iterator,
|
|
|
|
u32) const;
|
|
|
|
size_t GetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, size_t capacity, size_t iterator,
|
|
|
|
u32) const;
|
|
|
|
size_t GetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, size_t capacity, size_t iterator,
|
|
|
|
u32) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<std::unique_ptr<IAnimReader>> Simplified() { return VSimplified(); }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
std::unique_ptr<IAnimReader> Clone() const { return VClone(); }
|
2016-04-10 21:22:59 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|