Additional ANIM integration

This commit is contained in:
Jack Andersen 2016-08-26 18:54:53 -10:00
parent c5ddb51dfc
commit f76324a029
13 changed files with 230 additions and 19 deletions

View File

@ -2,6 +2,7 @@
#include "logvisor/logvisor.hpp"
#include "CSimplePool.hpp"
#include "CAnimSourceReader.hpp"
#include "CFBStreamedAnimReader.hpp"
namespace urde
{
@ -15,8 +16,11 @@ void CAnimFormatUnion::SubConstruct(u8* storage, EAnimFormat fmt,
case EAnimFormat::Uncompressed:
new (storage) CAnimSource(in, store);
break;
case EAnimFormat::BitstreamCompressed:
new (storage) CFBStreamedCompression(in, store, false);
break;
case EAnimFormat::BitstreamCompressed24:
new (storage) CAnimSource(in, store);
new (storage) CFBStreamedCompression(in, store, true);
break;
default:
Log.report(logvisor::Fatal, "unable to read ANIM format %d", int(fmt));
@ -35,11 +39,15 @@ CAnimFormatUnion::~CAnimFormatUnion()
{
case EAnimFormat::Uncompressed:
reinterpret_cast<CAnimSource*>(x4_storage)->~CAnimSource();
break;
case EAnimFormat::BitstreamCompressed:
case EAnimFormat::BitstreamCompressed24:
reinterpret_cast<CFBStreamedCompression*>(x4_storage)->~CFBStreamedCompression();
default: break;
}
}
std::shared_ptr<CAnimSourceReaderBase>
std::shared_ptr<IAnimReader>
CAllFormatsAnimSource::GetNewReader(const TLockedToken<CAllFormatsAnimSource>& tok,
const CCharAnimTime& startTime)
{

View File

@ -4,12 +4,13 @@
#include "RetroTypes.hpp"
#include "zeus/CVector3f.hpp"
#include "CAnimSource.hpp"
#include "CFBStreamedCompression.hpp"
#include "CFactoryMgr.hpp"
namespace urde
{
class IObjectStore;
class CAnimSourceReaderBase;
class IAnimReader;
enum class EAnimFormat
{
@ -26,7 +27,7 @@ class CAnimFormatUnion
EAnimFormat x0_format;
intptr_t _align = 0;
};
u8 x4_storage[sizeof(CAnimSource)];
u8 x4_storage[std::max(sizeof(CAnimSource), sizeof(CFBStreamedCompression))];
static void SubConstruct(u8* storage, EAnimFormat fmt,
CInputStream& in, IObjectStore& store);
public:
@ -41,8 +42,8 @@ class CAllFormatsAnimSource : public CAnimFormatUnion
SObjectTag x74_tag;
public:
CAllFormatsAnimSource(CInputStream& in, IObjectStore& store, const SObjectTag& tag);
static std::shared_ptr<CAnimSourceReaderBase> GetNewReader(const TLockedToken<CAllFormatsAnimSource>& tok,
const CCharAnimTime& startTime);
static std::shared_ptr<IAnimReader> GetNewReader(const TLockedToken<CAllFormatsAnimSource>& tok,
const CCharAnimTime& startTime);
};
CFactoryFnReturn AnimSourceFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params);

View File

@ -0,0 +1,114 @@
#include "CAnimTreeAnimReaderContainer.hpp"
namespace urde
{
CAnimTreeAnimReaderContainer::CAnimTreeAnimReaderContainer(const std::string& name,
std::shared_ptr<IAnimReader> reader,
u32 dbIdx)
: CAnimTreeNode(name), x14_reader(reader), x1c_animDbIdx(dbIdx)
{
}
CAnimTreeEffectiveContribution CAnimTreeAnimReaderContainer::VGetContributionOfHighestInfluence() const
{
return {1.f, x4_name, VGetSteadyStateAnimInfo(), VGetTimeRemaining(), x1c_animDbIdx};
}
SAdvancementResults CAnimTreeAnimReaderContainer::VAdvanceView(const CCharAnimTime& dt)
{
return x14_reader->VAdvanceView(dt);
}
CCharAnimTime CAnimTreeAnimReaderContainer::VGetTimeRemaining() const
{
return x14_reader->VGetTimeRemaining();
}
CSteadyStateAnimInfo CAnimTreeAnimReaderContainer::VGetSteadyStateAnimInfo() const
{
return x14_reader->VGetSteadyStateAnimInfo();
}
bool CAnimTreeAnimReaderContainer::VHasOffset(const CSegId& seg) const
{
return x14_reader->VHasOffset(seg);
}
zeus::CVector3f CAnimTreeAnimReaderContainer::VGetOffset(const CSegId& seg) const
{
return x14_reader->VGetOffset(seg);
}
zeus::CQuaternion CAnimTreeAnimReaderContainer::VGetRotation(const CSegId& seg) const
{
return x14_reader->VGetRotation(seg);
}
u32 CAnimTreeAnimReaderContainer::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return x14_reader->GetBoolPOIList(time, listOut, capacity, iterator, unk);
}
u32 CAnimTreeAnimReaderContainer::VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return x14_reader->GetInt32POIList(time, listOut, capacity, iterator, unk);
}
u32 CAnimTreeAnimReaderContainer::VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return x14_reader->GetParticlePOIList(time, listOut, capacity, iterator, unk);
}
u32 CAnimTreeAnimReaderContainer::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return x14_reader->GetSoundPOIList(time, listOut, capacity, iterator, unk);
}
bool CAnimTreeAnimReaderContainer::VGetBoolPOIState(const char* name) const
{
return x14_reader->VGetBoolPOIState(name);
}
s32 CAnimTreeAnimReaderContainer::VGetInt32POIState(const char* name) const
{
return x14_reader->VGetBoolPOIState(name);
}
CParticleData::EParentedMode CAnimTreeAnimReaderContainer::VGetParticlePOIState(const char* name) const
{
return x14_reader->VGetParticlePOIState(name);
}
void CAnimTreeAnimReaderContainer::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const
{
return x14_reader->VGetSegStatementSet(list, setOut);
}
void CAnimTreeAnimReaderContainer::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const
{
return x14_reader->VGetSegStatementSet(list, setOut, time);
}
std::shared_ptr<IAnimReader> CAnimTreeAnimReaderContainer::VClone() const
{
std::shared_ptr<IAnimReader> ret =
std::make_shared<CAnimTreeAnimReaderContainer>(x4_name, x14_reader->Clone(), x1c_animDbIdx);
return ret;
}
void CAnimTreeAnimReaderContainer::VSetPhase(float ph)
{
x14_reader->VSetPhase(ph);
}
SAdvancementResults CAnimTreeAnimReaderContainer::VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const
{
return x14_reader->VGetAdvancementResults(a, b);
}
}

View File

@ -8,9 +8,37 @@ namespace urde
class CAnimTreeAnimReaderContainer : public CAnimTreeNode
{
std::shared_ptr<IAnimReader> x14_
std::shared_ptr<IAnimReader> x14_reader;
u32 x1c_animDbIdx;
public:
CAnimTreeAnimReaderContainer(const std::string& name, std::shared_ptr<>);
CAnimTreeAnimReaderContainer(const std::string& name,
std::shared_ptr<IAnimReader> reader,
u32 animDbIdx);
u32 Depth() const { return 1; }
CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const;
u32 VGetNumChildren() const { return 0; }
std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const { return {}; }
SAdvancementResults VAdvanceView(const CCharAnimTime& a);
CCharAnimTime VGetTimeRemaining() const;
CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const;
bool VHasOffset(const CSegId& seg) const;
zeus::CVector3f VGetOffset(const CSegId& seg) const;
zeus::CQuaternion VGetRotation(const CSegId& seg) 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 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;
bool VGetBoolPOIState(const char*) const;
s32 VGetInt32POIState(const char*) const;
CParticleData::EParentedMode VGetParticlePOIState(const char*) const;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const;
std::shared_ptr<IAnimReader> VClone() const;
std::shared_ptr<IAnimReader> VSimplified() { return {}; }
void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
};
}

View File

@ -19,8 +19,8 @@ public:
CParticleData::EParentedMode VGetParticlePOIState(const char* name) const;
void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Depth() const;
void VGetContributionOfHighestInfluence() const;
u32 Depth() const;
CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const;
u32 VGetNumChildren() const;
std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const;
};

View File

@ -8,13 +8,14 @@ namespace urde
class CAnimTreeNode : public IAnimReader
{
protected:
std::string x4_name;
public:
CAnimTreeNode(const std::string& name) : x4_name(name) {}
bool IsCAnimTreeNode() const {return true;}
virtual void Depth() const=0;
virtual void VGetContributionOfHighestInfluence() const=0;
virtual u32 Depth() const=0;
virtual CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const=0;
virtual u32 VGetNumChildren() const=0;
virtual std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const=0;

View File

@ -99,8 +99,9 @@ CAnimTreeSingleChild::VGetAdvancementResults(const CCharAnimTime& a,
return {};
}
void CAnimTreeSingleChild::Depth() const
u32 CAnimTreeSingleChild::Depth() const
{
return 1;
}
u32 CAnimTreeSingleChild::VGetNumChildren() const

View File

@ -28,7 +28,7 @@ public:
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const;
void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Depth() const;
u32 Depth() const;
u32 VGetNumChildren() const;
};

View File

@ -1,10 +1,14 @@
#include "CMetaAnimPlay.hpp"
#include "CAnimSysContext.hpp"
#include "CSimplePool.hpp"
#include "CAllFormatsAnimSource.hpp"
#include "CAnimTreeAnimReaderContainer.hpp"
namespace urde
{
CMetaAnimPlay::CMetaAnimPlay(CInputStream& in)
: x4_primitive(in), x1c_(in.readFloatBig()), x20_(in.readUint32Big()) {}
: x4_primitive(in), x1c_startTime(in) {}
std::shared_ptr<CAnimTreeNode>
CMetaAnimPlay::GetAnimationTree(const CAnimSysContext& animSys,
@ -21,7 +25,20 @@ std::shared_ptr<CAnimTreeNode>
CMetaAnimPlay::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
return {};
if (orders.x0_)
{
CMetaAnimTreeBuildOrders modOrders;
modOrders.PreAdvanceForAll(*orders.x0_);
return GetAnimationTree(animSys, modOrders);
}
TLockedToken<CAllFormatsAnimSource> prim =
animSys.xc_store.GetObj(SObjectTag{FOURCC('ANIM'), x4_primitive.GetAnimResId()});
std::shared_ptr<CAnimTreeNode> ret =
std::make_shared<CAnimTreeAnimReaderContainer>(x4_primitive.GetName(),
CAllFormatsAnimSource::GetNewReader(prim, x1c_startTime),
x4_primitive.GetAnimDbIdx());
return ret;
}
}

View File

@ -11,8 +11,7 @@ namespace urde
class CMetaAnimPlay : public IMetaAnim
{
CPrimitive x4_primitive;
float x1c_;
u32 x20_;
CCharAnimTime x1c_startTime;
public:
CMetaAnimPlay(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Primitive;}

View File

@ -14,7 +14,9 @@ class CPrimitive
std::string x8_animName;
public:
CPrimitive(CInputStream& in);
ResId GetAnimResId() const {return x0_animId;}
ResId GetAnimResId() const { return x0_animId; }
u32 GetAnimDbIdx() const { return x4_animIdx; }
const std::string& GetName() const { return x8_animName; }
};
}

View File

@ -37,6 +37,24 @@ struct CSteadyStateAnimInfo
bool x78_ = false;
};
struct CAnimTreeEffectiveContribution
{
float x0_contributionWeight;
std::string x4_name;
CSteadyStateAnimInfo x14_ssInfo;
CCharAnimTime x2c_remTime;
u32 x34_dbIdx;
public:
CAnimTreeEffectiveContribution(float cweight, const std::string& 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; }
const std::string& 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; }
};
template <class T>
using TSubAnimTypeToken = TLockedToken<T>;
@ -69,6 +87,8 @@ public:
u32 GetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32 capacity, u32 iterator, u32) const;
u32 GetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32 capacity, u32 iterator, u32) const;
u32 GetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const;
std::shared_ptr<IAnimReader> Clone() const { return VClone(); }
};
}

View File

@ -27,6 +27,18 @@ class CPreAdvanceIndicator
bool x0_isTime;
CCharAnimTime x4_time;
const char* xc_string;
u32 x10_;
u32 x14_;
u32 x18_;
u32 x1c_;
u32 x20_;
u32 x24_;
u32 x28_;
u32 x2c_;
u32 x30_;
u32 x34_;
u32 x38_;
u16 x3c_;
public:
CPreAdvanceIndicator(const CCharAnimTime& time)
: x0_isTime(true), x4_time(time) {}
@ -38,6 +50,14 @@ public:
bool IsTime() const {return x0_isTime;}
};
struct CMetaAnimTreeBuildOrders
{
std::experimental::optional<CPreAdvanceIndicator> x0_;
std::experimental::optional<CPreAdvanceIndicator> x44_;
static CMetaAnimTreeBuildOrders NoSpecialOrders() { return {}; }
void PreAdvanceForAll(const CPreAdvanceIndicator& ind) { x44_.emplace(ind); }
};
class IMetaAnim
{
public: