diff --git a/Editor/main.cpp b/Editor/main.cpp index ac5a48a9d..5e954ac9e 100644 --- a/Editor/main.cpp +++ b/Editor/main.cpp @@ -12,7 +12,7 @@ static void AthenaExc(athena::error::Level level, const char* file, { va_list ap; va_start(ap, fmt); - AthenaLog.reportSource(logvisor::Level(level), file, line, fmt, ap); + AthenaLog.report(logvisor::Level(level), fmt, ap); va_end(ap); } @@ -60,9 +60,7 @@ struct Application : boo::IApplicationCallback void initialize(boo::IApplication* /*app*/) { zeus::detectCPU(); -#ifndef WIN32 /* Console issue with Win32 */ hecl::VerbosityLevel = 1; -#endif const zeus::CPUInfo& cpuInf = zeus::cpuFeatures(); Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand); diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 60db739ec..6c1fa1042 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -542,7 +542,7 @@ SAdvancementDeltas CAnimData::Advance(float dt, const zeus::CVector3f& scale, { if (node.GetCharacterIndex() == -1 || node.GetCharacterIndex() == x204_charIdx) { - x120_particleDB.StartEffect(node.GetName(), node.GetFlags(), node.GetParticleData(), + x120_particleDB.StartEffect(node.GetString(), node.GetFlags(), node.GetParticleData(), scale, stateMgr, aid, x21c_); } } diff --git a/Runtime/Character/CAnimSourceReader.cpp b/Runtime/Character/CAnimSourceReader.cpp index c050a2937..6899372fc 100644 --- a/Runtime/Character/CAnimSourceReader.cpp +++ b/Runtime/Character/CAnimSourceReader.cpp @@ -46,7 +46,7 @@ CAnimSourceReaderBase::GetUniqueParticlePOIs() const const std::vector& particleNodes = x4_sourceInfo->GetParticlePOIStream(); std::map ret; for (const CParticlePOINode& node : particleNodes) - ret[node.GetName()] = node.GetParticleData().GetParentedMode(); + ret[node.GetString()] = node.GetParticleData().GetParentedMode(); return ret; } @@ -56,7 +56,7 @@ CAnimSourceReaderBase::GetUniqueInt32POIs() const const std::vector& int32Nodes = x4_sourceInfo->GetInt32POIStream(); std::map ret; for (const CInt32POINode& node : int32Nodes) - ret[node.GetName()] = node.GetValue(); + ret[node.GetString()] = node.GetValue(); return ret; } @@ -66,7 +66,7 @@ CAnimSourceReaderBase::GetUniqueBoolPOIs() const const std::vector& boolNodes = x4_sourceInfo->GetBoolPOIStream(); std::map ret; for (const CBoolPOINode& node : boolNodes) - ret[node.GetName()] = node.GetValue(); + ret[node.GetString()] = node.GetValue(); return ret; } diff --git a/Runtime/Character/CAnimTreeDoubleChild.cpp b/Runtime/Character/CAnimTreeDoubleChild.cpp index d33cf1eca..9dc34f11b 100644 --- a/Runtime/Character/CAnimTreeDoubleChild.cpp +++ b/Runtime/Character/CAnimTreeDoubleChild.cpp @@ -16,42 +16,69 @@ SAdvancementResults CAnimTreeDoubleChild::VAdvanceView(const CCharAnimTime& a) } u32 CAnimTreeDoubleChild::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, - u32 capacity, u32 iterator, u32) const + u32 capacity, u32 iterator, u32 unk) const { - return 0; + u32 newCapacity = x14_a->GetBoolPOIList(time, listOut, capacity, iterator, unk); + newCapacity += x18_b->GetBoolPOIList(time, listOut, capacity, newCapacity + iterator, unk); + if (newCapacity > capacity) + newCapacity = capacity; + + std::sort(listOut, listOut + newCapacity, CPOINode::compare); + + return newCapacity; } u32 CAnimTreeDoubleChild::VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, - u32 capacity, u32 iterator, u32) const + u32 capacity, u32 iterator, u32 unk) const { - return 0; + u32 newCapacity = x14_a->GetInt32POIList(time, listOut, capacity, iterator, unk); + newCapacity += x18_b->GetInt32POIList(time, listOut, capacity, newCapacity + iterator, unk); + if (newCapacity > capacity) + newCapacity = capacity; + + std::sort(listOut, listOut + newCapacity, CPOINode::compare); + + return newCapacity; } u32 CAnimTreeDoubleChild::VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, - u32 capacity, u32 iterator, u32) const + u32 capacity, u32 iterator, u32 unk) const { - return 0; + u32 newCapacity = x14_a->GetParticlePOIList(time, listOut, capacity, iterator, unk); + newCapacity += x18_b->GetParticlePOIList(time, listOut, capacity, newCapacity + iterator, unk); + if (newCapacity > capacity) + newCapacity = capacity; + + std::sort(listOut, listOut + newCapacity, CPOINode::compare); + + return newCapacity; } u32 CAnimTreeDoubleChild::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, - u32 capacity, u32 iterator, u32) const + u32 capacity, u32 iterator, u32 unk) const { - return 0; + u32 newCapacity = x14_a->GetSoundPOIList(time, listOut, capacity, iterator, unk); + newCapacity += x18_b->GetSoundPOIList(time, listOut, capacity, newCapacity + iterator, unk); + if (newCapacity > capacity) + newCapacity = capacity; + + std::sort(listOut, listOut + newCapacity, CPOINode::compare); + return newCapacity; } bool CAnimTreeDoubleChild::VGetBoolPOIState(const char* name) const { - return false; + return x18_b->VGetBoolPOIState(name); } s32 CAnimTreeDoubleChild::VGetInt32POIState(const char* name) const { - return 0; + return x18_b->VGetBoolPOIState(name); } CParticleData::EParentedMode CAnimTreeDoubleChild::VGetParticlePOIState(const char* name) const { - return CParticleData::EParentedMode::Initial; + return x18_b->VGetParticlePOIState(name); } void CAnimTreeDoubleChild::VSetPhase(float) diff --git a/Runtime/Character/CAnimTreeDoubleChild.hpp b/Runtime/Character/CAnimTreeDoubleChild.hpp index 7a9be9d69..2f7a5140f 100644 --- a/Runtime/Character/CAnimTreeDoubleChild.hpp +++ b/Runtime/Character/CAnimTreeDoubleChild.hpp @@ -11,14 +11,15 @@ class CAnimTreeDoubleChild : public CAnimTreeNode protected: std::shared_ptr x14_a; std::shared_ptr x18_b; + public: - CAnimTreeDoubleChild(const std::weak_ptr& a, - const std::weak_ptr& b, + CAnimTreeDoubleChild(const std::weak_ptr& a, const std::weak_ptr& b, const std::string& name); SAdvancementResults VAdvanceView(const CCharAnimTime& a); 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 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* name) const; s32 VGetInt32POIState(const char* name) const; @@ -31,15 +32,14 @@ public: std::shared_ptr VGetBestUnblendedChild() const; void VGetWeightedReaders(std::vector>>& out, float w) const; - virtual float VGetLeftChildWeight() const=0; + virtual float VGetLeftChildWeight() const = 0; float GetLeftChildWeight() const { return VGetLeftChildWeight(); } - virtual float VGetRightChildWeight() const=0; + virtual float VGetRightChildWeight() const = 0; float GetRightChildWeight() const { return VGetRightChildWeight(); } const std::shared_ptr& GetLeftChild() const { return x14_a; } const std::shared_ptr& GetRightChild() const { return x18_b; } }; - } #endif // __URDE_CANIMTREEDOUBLECHILD_HPP__ diff --git a/Runtime/Character/CAnimTreeTransition.cpp b/Runtime/Character/CAnimTreeTransition.cpp index d6cf49741..0c38a7f8d 100644 --- a/Runtime/Character/CAnimTreeTransition.cpp +++ b/Runtime/Character/CAnimTreeTransition.cpp @@ -24,18 +24,46 @@ CAnimTreeTransition::CAnimTreeTransition(bool b1, const std::weak_ptr CAnimTreeTransition::VGetBestUnblendedChild() const +{ + std::shared_ptr child = x18_b->GetBestUnblendedChild(); + return (child ? child : x18_b); +} + +CCharAnimTime CAnimTreeTransition::VGetTimeRemaining() const +{ + CCharAnimTime time = x24_ * x2c_; + CCharAnimTime bTimeRem = x18_b->VGetTimeRemaining(); + + if (time < bTimeRem) + return bTimeRem; + return time; +} CSteadyStateAnimInfo CAnimTreeTransition::VGetSteadyStateAnimInfo() const +{ + CSteadyStateAnimInfo bInfo = x18_b->VGetSteadyStateAnimInfo(); + + if (x24_ < bInfo.GetDuration()) + return CSteadyStateAnimInfo(bInfo.IsLooping(), bInfo.GetDuration(), bInfo.GetOffset()); + return CSteadyStateAnimInfo(bInfo.IsLooping(), x24_, bInfo.GetOffset()); +} + +std::shared_ptr CAnimTreeTransition::VClone() const +{ + return std::make_shared(x20_31_b1, std::static_pointer_cast(x14_a->Clone()), + std::static_pointer_cast(x18_b->Clone()), x24_, x2c_, + x34_, x35_, x1c_flags, x4_name, x36_); +} + +SAdvancementResults CAnimTreeTransition::VAdvanceView(const CCharAnimTime& time) const { return {}; } -std::shared_ptr CAnimTreeTransition::VClone() const { return {}; } - void CAnimTreeTransition::SetBlendingWeight(float w) { - static_cast(x18_b.get())->SetBlendingWeight(w); + std::static_pointer_cast(x18_b)->SetBlendingWeight(w); } float CAnimTreeTransition::VGetBlendingWeight() const diff --git a/Runtime/Character/CAnimTreeTransition.hpp b/Runtime/Character/CAnimTreeTransition.hpp index 3d877812c..e4ce281f2 100644 --- a/Runtime/Character/CAnimTreeTransition.hpp +++ b/Runtime/Character/CAnimTreeTransition.hpp @@ -23,9 +23,11 @@ public: const CCharAnimTime&, const CCharAnimTime&, bool, bool, int, const std::string&, bool); CAnimTreeTransition(bool, const std::weak_ptr&, const std::weak_ptr&, const CCharAnimTime&, bool, int, const std::string&); + std::shared_ptr VGetBestUnblendedChild() const; CCharAnimTime VGetTimeRemaining() const; CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const; std::shared_ptr VClone() const; + SAdvancementResults VAdvanceView(const CCharAnimTime& a) const; void SetBlendingWeight(float w); float VGetBlendingWeight() const; }; diff --git a/Runtime/Character/CAnimTreeTweenBase.cpp b/Runtime/Character/CAnimTreeTweenBase.cpp index af40c96b3..8a4f4c53d 100644 --- a/Runtime/Character/CAnimTreeTweenBase.cpp +++ b/Runtime/Character/CAnimTreeTweenBase.cpp @@ -3,6 +3,8 @@ namespace urde { +s32 CAnimTreeTweenBase::sAdvancementDepth = 0; + CAnimTreeTweenBase::CAnimTreeTweenBase(bool b1, const std::weak_ptr& a, const std::weak_ptr& b, int flags, const std::string& name) : CAnimTreeDoubleChild(a, b, name), x1c_flags(flags), x20_31_b1(b1) diff --git a/Runtime/Character/CAnimTreeTweenBase.hpp b/Runtime/Character/CAnimTreeTweenBase.hpp index b291caf94..68e09b9cc 100644 --- a/Runtime/Character/CAnimTreeTweenBase.hpp +++ b/Runtime/Character/CAnimTreeTweenBase.hpp @@ -8,6 +8,7 @@ namespace urde class CAnimTreeTweenBase : public CAnimTreeDoubleChild { + static s32 sAdvancementDepth; protected: int x1c_flags; bool x20_31_b1; @@ -34,6 +35,9 @@ public: std::shared_ptr VSimplified(); bool ShouldCullTree() const { return false; } + + static void IncAdvancementDepth() { sAdvancementDepth++; } + static void DecAdvancementDepth() { sAdvancementDepth--; } }; } diff --git a/Runtime/Character/CPOINode.cpp b/Runtime/Character/CPOINode.cpp index 4943acc23..7e8e965fe 100644 --- a/Runtime/Character/CPOINode.cpp +++ b/Runtime/Character/CPOINode.cpp @@ -33,6 +33,23 @@ CPOINode::CPOINode(CInputStream& in) x34_flags(in.readUint32Big()) {} +bool CPOINode::operator>(const CPOINode& other) const +{ + return x1c_time < other.x1c_time; +} + +bool CPOINode::operator<(const CPOINode& other) const +{ + return x1c_time > other.x1c_time; +} + +bool CPOINode::compare(const CPOINode& a, const CPOINode& b) +{ + if (a > b) + return 1; + return (a < b); +} + template u32 _getPOIList(const CCharAnimTime& time, T* listOut, diff --git a/Runtime/Character/CPOINode.hpp b/Runtime/Character/CPOINode.hpp index ef9cd235b..037b66d55 100644 --- a/Runtime/Character/CPOINode.hpp +++ b/Runtime/Character/CPOINode.hpp @@ -37,13 +37,18 @@ public: CPOINode(CInputStream& in); virtual ~CPOINode() = default; - const std::string& GetName() const {return x8_name;} + const std::string& GetString() const {return x8_name;} const CCharAnimTime& GetTime() const {return x1c_time;} + void SetTime(const CCharAnimTime& time) { x1c_time = time; } EPOIType GetPoiType() const { return x18_type; } u32 GetIndex() const {return x24_index;} float GetWeight() const { return x2c_weight; } u32 GetCharacterIndex() const { return x30_charIdx; } u32 GetFlags() const { return x34_flags; } + + bool operator>(const CPOINode& other) const; + bool operator<(const CPOINode& other) const; + static bool compare(const CPOINode& a, const CPOINode& b); }; template diff --git a/Runtime/Character/IMetaAnim.cpp b/Runtime/Character/IMetaAnim.cpp index af2417015..b0749c3c5 100644 --- a/Runtime/Character/IMetaAnim.cpp +++ b/Runtime/Character/IMetaAnim.cpp @@ -47,7 +47,7 @@ CCharAnimTime IMetaAnim::GetTime(const CPreAdvanceIndicator& ind, const IAnimRea for (u32 i=0 ; i