Various cleanups and minor imps

This commit is contained in:
Phillip Stephens 2016-09-09 21:50:00 -07:00
parent 529223e311
commit f2635f449c
24 changed files with 210 additions and 116 deletions

View File

@ -95,7 +95,7 @@ public:
PAKRouterBase* pakRouter = g_PakRouter.get();
if (!pakRouter)
LogDNACommon.report(logvisor::Fatal,
"g_Project must be set to non-null before calling UniqueIDBridge::TranslatePakIdToPath");
"g_PakRouter must be set to non-null before calling UniqueIDBridge::TranslatePakIdToPath");
return pakRouter->getWorking(id, silenceWarnings);
}
static hecl::ProjectPath MakePathFromString(const std::string& str)

View File

@ -46,6 +46,16 @@ struct HINT : BigYAML
hint.toYAMLStream(writer);
return true;
}
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
{
HINT hint;
athena::io::FileReader reader(inPath.getAbsolutePath());
hint.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
hint.write(ws);
return true;
}
};
}
}

View File

@ -5,6 +5,7 @@
#include "SpecBase.hpp"
#include "DNAMP1/DNAMP1.hpp"
#include "DNAMP1/HINT.hpp"
#include "DNAMP1/MLVL.hpp"
#include "DNAMP1/STRG.hpp"
#include "DNAMP1/CMDL.hpp"
@ -353,6 +354,8 @@ struct SpecMP1 : SpecBase
return true;
else if (!strcmp(classType, DNAMP1::CTweakGunRes::DNAType()))
return true;
else if (!strcmp(classType, DNAMP1::HINT::DNAType()))
return true;
return false;
});
}
@ -504,6 +507,10 @@ struct SpecMP1 : SpecBase
gunRes.read(reader);
WriteTweak(gunRes, out);
}
else if (!classStr.compare(DNAMP1::HINT::DNAType()))
{
DNAMP1::HINT::Cook(in, out);
}
}
progress(_S("Done"));
}

View File

@ -1,6 +1,7 @@
#include "ProjectResourceFactoryMP1.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/CGameHintInfo.hpp"
#include "Runtime/Particle/CParticleDataFactory.hpp"
#include "Runtime/Particle/CGenDescription.hpp"
#include "Runtime/Particle/CElectricDescription.hpp"
@ -46,6 +47,7 @@ ProjectResourceFactoryMP1::ProjectResourceFactoryMP1(hecl::ClientProcess& client
m_factoryMgr.AddFactory(FOURCC('DGRP'), FFactoryFunc(FDependencyGroupFactory));
m_factoryMgr.AddFactory(FOURCC('AGSC'), FMemFactoryFunc(FAudioGroupSetDataFactory));
m_factoryMgr.AddFactory(FOURCC('STRG'), FFactoryFunc(FStringTableFactory));
m_factoryMgr.AddFactory(FOURCC('HINT'), FFactoryFunc(FHintFactory));
}
void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj)
@ -111,41 +113,46 @@ SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path,
yaml_parser_set_input_file(reader.getParser(), fp);
SObjectTag resTag;
if (reader.ClassTypeOperation([&](const char* className) -> bool
{
if (!strcmp(className, "GPSM"))
{
resTag.type = SBIG('PART');
return true;
}
else if (!strcmp(className, "FONT"))
{
resTag.type = SBIG('FONT');
return true;
}
else if (!strcmp(className, "urde::DNAMP1::EVNT"))
{
resTag.type = SBIG('EVNT');
return true;
}
else if (!strcmp(className, "urde::DGRP"))
{
resTag.type = SBIG('DGRP');
return true;
}
else if (!strcmp(className, "urde::DNAMP1::STRG"))
{
resTag.type = SBIG('STRG');
return true;
}
else if (!strcmp(className, "DataSpec::DNAMP1::CTweakPlayerRes") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakGunRes"))
{
resTag.type = SBIG('CTWK');
return true;
}
return false;
}))
if (reader.ClassTypeOperation([&](const char* className) -> bool {
if (!strcmp(className, "GPSM"))
{
resTag.type = SBIG('PART');
return true;
}
else if (!strcmp(className, "FONT"))
{
resTag.type = SBIG('FONT');
return true;
}
else if (!strcmp(className, "urde::DNAMP1::EVNT"))
{
resTag.type = SBIG('EVNT');
return true;
}
else if (!strcmp(className, "urde::DGRP"))
{
resTag.type = SBIG('DGRP');
return true;
}
else if (!strcmp(className, "urde::DNAMP1::STRG"))
{
resTag.type = SBIG('STRG');
return true;
}
else if (!strcmp(className, "DataSpec::DNAMP1::CTweakPlayerRes") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakGunRes"))
{
resTag.type = SBIG('CTWK');
return true;
}
else if (!strcmp(className, "DataSpec::DNAMP1::HINT"))
{
resTag.type = SBIG('HINT');
return true;
}
return false;
}))
{
resTag.id = path.hash().val32();
fclose(fp);
@ -155,5 +162,4 @@ SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path,
}
return {};
}
}

View File

@ -6,6 +6,7 @@
#include "ProjectManager.hpp"
#include "Space.hpp"
#include "Runtime/CGameHintInfo.hpp"
#include "Runtime/Particle/CElementGen.hpp"
#include "Runtime/Graphics/CLineRenderer.hpp"
#include "Runtime/Graphics/CMoviePlayer.hpp"
@ -66,6 +67,7 @@ class ViewManager : public specter::IViewManager
std::unique_ptr<ParticleView> m_particleView;
urde::TLockedToken<CModel> m_modelTest;
urde::TLockedToken<CGenDescription> m_partGenDesc;
TLockedToken<CGameHintInfo> m_hints;
std::unique_ptr<CElementGen> m_partGen;
std::unique_ptr<CLineRenderer> m_lineRenderer;
std::unique_ptr<CMoviePlayer> m_moviePlayer;

View File

@ -3,10 +3,10 @@
namespace urde
{
CAnimTreeDoubleChild::CAnimTreeDoubleChild(const std::shared_ptr<CAnimTreeNode>& a,
const std::shared_ptr<CAnimTreeNode>& b,
CAnimTreeDoubleChild::CAnimTreeDoubleChild(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const std::string& name)
: CAnimTreeNode(name), x14_a(a), x18_b(b)
: CAnimTreeNode(name), x14_a(a.lock()), x18_b(b.lock())
{
}

View File

@ -8,11 +8,12 @@ namespace urde
class CAnimTreeDoubleChild : public CAnimTreeNode
{
protected:
std::shared_ptr<CAnimTreeNode> x14_a;
std::shared_ptr<CAnimTreeNode> x18_b;
public:
CAnimTreeDoubleChild(const std::shared_ptr<CAnimTreeNode>& a,
const std::shared_ptr<CAnimTreeNode>& b,
CAnimTreeDoubleChild(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const std::string& name);
SAdvancementResults VAdvanceView(const CCharAnimTime& a);
u32 VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator, u32) const;

View File

@ -0,0 +1,47 @@
#include "CAnimTreeTransition.hpp"
namespace urde
{
std::string CAnimTreeTransition::CreatePrimitiveName(const std::weak_ptr<CAnimTreeNode>&,
const std::weak_ptr<CAnimTreeNode>&, float)
{
return {};
}
CAnimTreeTransition::CAnimTreeTransition(bool b1, const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b, const CCharAnimTime& time1,
const CCharAnimTime& time2, bool b2, bool b3, int flags,
const std::string& name, bool b4)
: CAnimTreeTweenBase(b1, a, b, flags, name), x24_(time1), x2c_(time2), x34_(b2), x35_(b3), x36_(b4)
{
}
CAnimTreeTransition::CAnimTreeTransition(bool b1, const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b, const CCharAnimTime& time, bool b2,
int flags, const std::string& name)
: CAnimTreeTweenBase(b1, a, b, flags, name), x24_(time), x34_(b2), x35_(a.lock()->VGetBoolPOIState("Loop"))
{
}
CCharAnimTime CAnimTreeTransition::VGetTimeRemaining() const { return {}; }
CSteadyStateAnimInfo CAnimTreeTransition::VGetSteadyStateAnimInfo() const
{
return {};
}
std::shared_ptr<IAnimReader> CAnimTreeTransition::VClone() const { return {}; }
void CAnimTreeTransition::SetBlendingWeight(float w)
{
static_cast<CAnimTreeTweenBase*>(x18_b.get())->SetBlendingWeight(w);
}
float CAnimTreeTransition::VGetBlendingWeight() const
{
if (x24_.GreaterThanZero())
return (1.f / x24_) * x2c_;
return 0.f;
}
}

View File

@ -9,10 +9,26 @@ namespace urde
class CAnimTreeTransition : public CAnimTreeTweenBase
{
protected:
CCharAnimTime x24_;
CCharAnimTime x2c_;
bool x34_;
bool x35_;
bool x36_ = false;
public:
static std::string CreatePrimitiveName();
};
static std::string CreatePrimitiveName(const std::weak_ptr<CAnimTreeNode>&, const std::weak_ptr<CAnimTreeNode>&,
float);
CAnimTreeTransition(bool, const std::weak_ptr<CAnimTreeNode>&, const std::weak_ptr<CAnimTreeNode>&,
const CCharAnimTime&, const CCharAnimTime&, bool, bool, int, const std::string&, bool);
CAnimTreeTransition(bool, const std::weak_ptr<CAnimTreeNode>&, const std::weak_ptr<CAnimTreeNode>&,
const CCharAnimTime&, bool, int, const std::string&);
CCharAnimTime VGetTimeRemaining() const;
CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const;
std::shared_ptr<IAnimReader> VClone() const;
void SetBlendingWeight(float w);
float VGetBlendingWeight() const;
};
}
#endif // __URDE_CANIMTREETRANSITION_HPP__

View File

@ -3,37 +3,24 @@
namespace urde
{
CAnimTreeTweenBase::CAnimTreeTweenBase(bool b1,
const std::shared_ptr<CAnimTreeNode>& a,
const std::shared_ptr<CAnimTreeNode>& b,
int flags, const std::string& name)
CAnimTreeTweenBase::CAnimTreeTweenBase(bool b1, const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b, int flags, const std::string& name)
: CAnimTreeDoubleChild(a, b, name), x1c_flags(flags), x20_31_b1(b1)
{
}
void CAnimTreeTweenBase::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const
{
}
void CAnimTreeTweenBase::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const {}
void CAnimTreeTweenBase::VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut,
const CCharAnimTime& time) const
{
}
bool CAnimTreeTweenBase::VHasOffset(const CSegId& seg) const
{
}
bool CAnimTreeTweenBase::VHasOffset(const CSegId& seg) const {}
zeus::CVector3f CAnimTreeTweenBase::VGetOffset(const CSegId& seg) const
{
}
zeus::CVector3f CAnimTreeTweenBase::VGetOffset(const CSegId& seg) const {}
zeus::CQuaternion CAnimTreeTweenBase::VGetRotation(const CSegId& seg) const
{
}
std::shared_ptr<IAnimReader> CAnimTreeTweenBase::VSimplified()
{
}
zeus::CQuaternion CAnimTreeTweenBase::VGetRotation(const CSegId& seg) const {}
std::shared_ptr<IAnimReader> CAnimTreeTweenBase::VSimplified() {}
}

View File

@ -8,13 +8,14 @@ namespace urde
class CAnimTreeTweenBase : public CAnimTreeDoubleChild
{
protected:
int x1c_flags;
bool x20_31_b1;
bool x20_30_b2 = false;
public:
CAnimTreeTweenBase(bool,
const std::shared_ptr<CAnimTreeNode>& a,
const std::shared_ptr<CAnimTreeNode>& b,
const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
int, const std::string& name);
virtual void SetBlendingWeight(float w)=0;

View File

@ -24,18 +24,14 @@ class CAnimationSet
public:
CAnimationSet(CInputStream& in);
const std::vector<CAnimation>& GetAnimations() const {return x4_animations;}
const std::vector<CTransition>& GetTransitions() const {return x14_transitions;}
const std::shared_ptr<IMetaTrans>& GetDefaultTransition() const {return x24_defaultTransition;}
const std::vector<CHalfTransition>& GetHalfTransitions() const {return x40_halfTransitions;}
const std::vector<std::pair<u32, CAdditiveAnimationInfo>>&
GetAdditiveInfo() const {return x28_additiveInfo;}
const CAdditiveAnimationInfo&
GetDefaultAdditiveInfo() const {return x38_defaultAdditiveInfo;}
const std::vector<std::pair<ResId, ResId>>&
GetAnimResIds() const {return x50_animRes;}
const std::vector<CAnimation>& GetAnimations() const { return x4_animations; }
const std::vector<CTransition>& GetTransitions() const { return x14_transitions; }
const std::shared_ptr<IMetaTrans>& GetDefaultTransition() const { return x24_defaultTransition; }
const std::vector<CHalfTransition>& GetHalfTransitions() const { return x40_halfTransitions; }
const std::vector<std::pair<u32, CAdditiveAnimationInfo>>& GetAdditiveInfo() const { return x28_additiveInfo; }
const CAdditiveAnimationInfo& GetDefaultAdditiveInfo() const { return x38_defaultAdditiveInfo; }
const std::vector<std::pair<ResId, ResId>>& GetAnimResIds() const { return x50_animRes; }
};
}
#endif // __URDE_CANIMATIONSET_HPP__

View File

@ -3,10 +3,7 @@
namespace urde
{
SObjectTag CEffectComponent::GetSObjectTagFromStream(CInputStream& in)
{
return SObjectTag(in);
}
SObjectTag CEffectComponent::GetSObjectTagFromStream(CInputStream& in) { return SObjectTag(in); }
CEffectComponent::CEffectComponent(CInputStream& in)
{
@ -14,18 +11,19 @@ CEffectComponent::CEffectComponent(CInputStream& in)
x10_tag = GetSObjectTagFromStream(in);
x18_boneName = in.readString();
x28_scale = in.readFloatBig();
x2c_ = in.readUint32Big();
x30_ = in.readUint32Big();
x2c_parentedMode = in.readUint32Big();
x30_flags = in.readUint32Big();
}
const std::string& CEffectComponent::GetComponentName() const
{
return x0_name;
}
const std::string& CEffectComponent::GetComponentName() const { return x0_name; }
const SObjectTag& CEffectComponent::GetParticleTag() const
{
return x10_tag;
}
const SObjectTag& CEffectComponent::GetParticleTag() const { return x10_tag; }
const std::string& CEffectComponent::GetSegmentName() const { return x18_boneName; }
float CEffectComponent::GetScale() const { return x28_scale; }
u32 CEffectComponent::GetParentedMode() const { return x2c_parentedMode; }
u32 CEffectComponent::GetFlags() const { return x30_flags; }
}

View File

@ -13,14 +13,18 @@ class CEffectComponent
SObjectTag x10_tag;
std::string x18_boneName;
float x28_scale;
u32 x2c_;
u32 x30_;
u32 x2c_parentedMode;
u32 x30_flags;
static SObjectTag GetSObjectTagFromStream(CInputStream& in);
public:
CEffectComponent(CInputStream& in);
const std::string& GetComponentName() const;
const SObjectTag& GetParticleTag() const;
const std::string& GetSegmentName() const;
float GetScale() const;
u32 GetParentedMode() const;
u32 GetFlags() const;
};
}

View File

@ -14,7 +14,7 @@ std::shared_ptr<IMetaAnim> CMetaAnimFactory::CreateMetaAnim(CInputStream& in)
switch (type)
{
case EMetaAnimType::Primitive:
case EMetaAnimType::Play:
return std::make_shared<CMetaAnimPlay>(in);
case EMetaAnimType::Blend:
return std::make_shared<CMetaAnimBlend>(in);

View File

@ -14,7 +14,7 @@ class CMetaAnimPlay : public IMetaAnim
CCharAnimTime x1c_startTime;
public:
CMetaAnimPlay(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Primitive;}
EMetaAnimType GetType() const {return EMetaAnimType::Play;}
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,

View File

@ -21,10 +21,10 @@ std::shared_ptr<IMetaTrans> CMetaTransFactory::CreateMetaTrans(CInputStream& in)
return std::make_shared<CMetaTransPhaseTrans>(in);
case EMetaTransType::Snap:
return std::make_shared<CMetaTransSnap>();
default: break;
default:
break;
}
return {};
}
}

View File

@ -1,4 +1,5 @@
#include "CMetaTransPhaseTrans.hpp"
#include "CAnimTreeNode.hpp"
namespace urde
{
@ -17,7 +18,6 @@ CMetaTransPhaseTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const
{
return {};
}
}

View File

@ -6,19 +6,17 @@ namespace urde
CMetaTransTrans::CMetaTransTrans(CInputStream& in)
{
x4_ = in.readFloatBig();
x8_ = in.readUint32Big();
x4_animTime = CCharAnimTime(in);
xc_ = in.readBool();
xd_ = in.readBool();
x10_ = in.readUint32Big();
}
std::shared_ptr<CAnimTreeNode>
CMetaTransTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const
std::shared_ptr<CAnimTreeNode> CMetaTransTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const
{
return {};
return std::make_shared<CAnimTreeTransition>(xc_, a, b, x4_animTime, xd_, x10_,
CAnimTreeTransition::CreatePrimitiveName(a, b, x4_animTime));
}
}

View File

@ -3,14 +3,14 @@
#include "IMetaTrans.hpp"
#include "IOStreams.hpp"
#include "CCharAnimTime.hpp"
namespace urde
{
class CMetaTransTrans : public IMetaTrans
{
float x4_;
u32 x8_;
CCharAnimTime x4_animTime;
bool xc_;
bool xd_;
u32 x10_;

View File

@ -15,7 +15,7 @@ class IAnimReader;
enum class EMetaAnimType
{
Primitive,
Play,
Blend,
PhaseBlend,
Random,

View File

@ -19,9 +19,9 @@ struct SObjectTag
{
FourCC type;
ResId id = -1;
operator bool() const {return id != -1;}
bool operator!=(const SObjectTag& other) const {return id != other.id;}
bool operator==(const SObjectTag& other) const {return id == other.id;}
operator bool() const { return id != -1; }
bool operator!=(const SObjectTag& other) const { return id != other.id; }
bool operator==(const SObjectTag& other) const { return id == other.id; }
SObjectTag() = default;
SObjectTag(FourCC tp, ResId rid) : type(tp), id(rid) {}
SObjectTag(CInputStream& in)
@ -56,16 +56,35 @@ struct TEditorId
#define kInvalidEditorId TEditorId()
#define kInvalidUniqueId TUniqueId(-1)
#define kInvalidAreaId TAreaId(-1)
}
#if 0
template <class T, size_t N>
class TRoundRobin
{
rstl::reserved_vector<T, N> vals;
public:
TRoundRobin(const T& val) : vals(N, val) {}
void PushBack(const T& val) { vals.push_back(val); }
size_t Size() const { return vals.size(); }
const T& GetLastValue() const { return vals.back(); }
void Clear() { vals.clear(); }
const T& GetValue(s32) const {}
};
#endif
namespace std
{
template<>
template <>
struct hash<urde::SObjectTag>
{
inline size_t operator()(const urde::SObjectTag& tag) const
{return tag.id;}
inline size_t operator()(const urde::SObjectTag& tag) const { return tag.id; }
};
}

View File

@ -40,6 +40,7 @@ public:
{
struct
{
bool x2a8_24_ : 1;
bool x2a8_25_ : 1;
bool x2a8_26_ : 1;
bool x2a8_27_ : 1;

View File

@ -19,6 +19,7 @@ class reserved_vector : public std::vector<T>
{
public:
reserved_vector() {this->reserve(N);}
reserved_vector(size_t n, const T& val) : std::vector<T>(n, val) { }
};
}