From 60f8dfb9d1cecd5eebb82e4c7d49df29ca049826 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 7 Feb 2020 14:20:04 -0800 Subject: [PATCH] Final CCollisionInfoList imps --- Runtime/Collision/CCollisionInfoList.hpp | 33 +++++++++++++++++++++--- Runtime/Collision/CMaterialList.hpp | 1 + Runtime/World/ScriptLoader.cpp | 5 +++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Runtime/Collision/CCollisionInfoList.hpp b/Runtime/Collision/CCollisionInfoList.hpp index 77c49f151..c41eaea3e 100644 --- a/Runtime/Collision/CCollisionInfoList.hpp +++ b/Runtime/Collision/CCollisionInfoList.hpp @@ -11,11 +11,36 @@ class CCollisionInfoList { public: CCollisionInfoList() = default; - void GetAverageLeftNormal() const; - void GetAveragePoint() const; - void GetUnionOfAllLeftMaterials() const; + zeus::CVector3f GetAverageLeftNormal() const { + zeus::CVector3f ret; + for (const auto& inf : x0_list) { + ret += inf.GetNormalLeft(); + } + + return ret / x0_list.size(); + } + zeus::CVector3f GetAveragePoint() const { + zeus::CVector3f ret; + for (const auto& inf : x0_list) { + ret += inf.GetPoint(); + } + + return ret / x0_list.size(); + } + CMaterialList GetUnionOfAllLeftMaterials() const { + CMaterialList list; + for (const auto& inf : x0_list) { + list.Union(inf.GetMaterialLeft()); + } + + return list; + } size_t GetCount() const { return x0_list.size(); } - void Swap(s32); + void Swap(s32 idx) { + if (idx >= x0_list.size()) + return; + x0_list[idx].Swap(); + } void Add(const CCollisionInfo& info, bool swap) { if (x0_list.size() == 32) diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index 8af658359..df798a8ea 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -134,6 +134,7 @@ public: constexpr u64 Intersection(const CMaterialList& other) const noexcept { return other.x0_list & x0_list; } constexpr u64 XOR(const CMaterialList& other) const noexcept { return x0_list ^ other.x0_list; } + void Union(const CMaterialList& other) noexcept { x0_list |= other.x0_list; } }; } // namespace urde diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index a61df5ae6..195be25a1 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -689,8 +689,11 @@ CEntity* ScriptLoader::LoadSound(CStateManager& mgr, CInputStream& in, int propC bool allowDuplicates = in.readBool(); s32 pitch = in.readInt32Big(); - if (soundId < 0) + if (soundId < 0) { + Log.report(logvisor::Warning, fmt("Invalid sound ID specified in Sound {} ({}), dropping..."), head.x0_name, + info.GetEditorId()); return nullptr; + } return new CScriptSound(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, u16(soundId), active, maxDist, distComp, startDelay, minVol, vol, 0, prio, pan, 0, loop, nonEmitter, autoStart,