metaforce/Runtime/Character/CAllFormatsAnimSource.hpp

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

2018-10-06 20:42:33 -07:00
#pragma once
2016-04-11 16:35:37 -07: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 16:35:37 -07:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
2016-08-26 21:54:53 -07:00
class IAnimReader;
class IObjectStore;
2016-04-11 16:35:37 -07:00
2018-12-07 21:30:43 -08: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 16:35:37 -07:00
public:
explicit CAnimFormatUnion(CInputStream& in, IObjectStore& store);
2018-12-07 21:30:43 -08:00
~CAnimFormatUnion();
EAnimFormat GetFormat() const { return x0_format; }
2020-03-13 01:11:17 -07:00
CAnimSource& GetAsCAnimSource() { return *reinterpret_cast<CAnimSource*>(x4_storage); }
CFBStreamedCompression& GetAsCFBStreamedCompression() {
return *reinterpret_cast<CFBStreamedCompression*>(x4_storage);
2018-12-07 21:30:43 -08:00
}
2016-04-11 16:35:37 -07:00
};
2018-12-07 21:30:43 -08:00
class CAllFormatsAnimSource : public CAnimFormatUnion {
zeus::CVector3f x68_;
SObjectTag x74_tag;
2016-04-11 16:35:37 -07:00
public:
explicit CAllFormatsAnimSource(CInputStream& in, IObjectStore& store, const SObjectTag& tag);
2018-12-07 21:30:43 -08:00
static std::shared_ptr<IAnimReader> GetNewReader(const TLockedToken<CAllFormatsAnimSource>& tok,
const CCharAnimTime& startTime);
2016-04-11 16:35:37 -07:00
};
CFactoryFnReturn AnimSourceFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
CObjectReference* selfRef);
2016-04-11 23:15:32 -07:00
2021-04-10 01:42:06 -07:00
} // namespace metaforce