Final CCollisionInfoList imps

This commit is contained in:
Phillip Stephens 2020-02-07 14:20:04 -08:00
parent 6ac01741a4
commit 60f8dfb9d1
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
3 changed files with 34 additions and 5 deletions

View File

@ -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)

View File

@ -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

View File

@ -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,