metaforce/Runtime/Character/CAllFormatsAnimSource.hpp

52 lines
1.6 KiB
C++
Raw Permalink Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-04-11 23:35:37 +00:00
#include <algorithm>
#include <memory>
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Character/CAnimSource.hpp"
#include "Runtime/Character/CFBStreamedCompression.hpp"
#include <zeus/CVector3f.hpp>
2016-04-11 23:35:37 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2016-08-27 04:54:53 +00:00
class IAnimReader;
class IObjectStore;
2016-04-11 23:35:37 +00:00
2018-12-08 05:30:43 +00:00
enum class EAnimFormat { Uncompressed, Unknown, BitstreamCompressed, BitstreamCompressed24 };
class CAnimFormatUnion {
friend class CAllFormatsAnimSource;
union {
EAnimFormat x0_format;
u8 _align[16];
};
u8 x4_storage[std::max(sizeof(CAnimSource), sizeof(CFBStreamedCompression))];
static void SubConstruct(u8* storage, EAnimFormat fmt, CInputStream& in, IObjectStore& store);
2016-04-11 23:35:37 +00:00
public:
explicit CAnimFormatUnion(CInputStream& in, IObjectStore& store);
2018-12-08 05:30:43 +00:00
~CAnimFormatUnion();
EAnimFormat GetFormat() const { return x0_format; }
2020-03-13 08:11:17 +00:00
CAnimSource& GetAsCAnimSource() { return *reinterpret_cast<CAnimSource*>(x4_storage); }
CFBStreamedCompression& GetAsCFBStreamedCompression() {
return *reinterpret_cast<CFBStreamedCompression*>(x4_storage);
2018-12-08 05:30:43 +00:00
}
2016-04-11 23:35:37 +00:00
};
2018-12-08 05:30:43 +00:00
class CAllFormatsAnimSource : public CAnimFormatUnion {
zeus::CVector3f x68_;
SObjectTag x74_tag;
2016-04-11 23:35:37 +00:00
public:
explicit CAllFormatsAnimSource(CInputStream& in, IObjectStore& store, const SObjectTag& tag);
2018-12-08 05:30:43 +00:00
static std::shared_ptr<IAnimReader> GetNewReader(const TLockedToken<CAllFormatsAnimSource>& tok,
const CCharAnimTime& startTime);
2016-04-11 23:35:37 +00:00
};
CFactoryFnReturn AnimSourceFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
CObjectReference* selfRef);
2016-04-12 06:15:32 +00:00
2021-04-10 08:42:06 +00:00
} // namespace metaforce