2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-06-26 01:11:09 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Collision/CCollisionInfo.hpp"
|
2016-06-26 01:11:09 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
|
|
|
class CCollisionInfoList {
|
|
|
|
rstl::reserved_vector<CCollisionInfo, 32> x0_list;
|
|
|
|
|
2016-06-26 01:11:09 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CCollisionInfoList() = default;
|
2016-06-26 01:11:09 +00:00
|
|
|
|
2020-02-07 22:20:04 +00:00
|
|
|
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;
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
size_t GetCount() const { return x0_list.size(); }
|
2020-02-07 22:20:04 +00:00
|
|
|
void Swap(s32 idx) {
|
|
|
|
if (idx >= x0_list.size())
|
|
|
|
return;
|
|
|
|
x0_list[idx].Swap();
|
|
|
|
}
|
2016-06-26 01:11:09 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void Add(const CCollisionInfo& info, bool swap) {
|
|
|
|
if (x0_list.size() == 32)
|
|
|
|
return;
|
|
|
|
if (!swap)
|
|
|
|
x0_list.push_back(info);
|
|
|
|
else
|
|
|
|
x0_list.push_back(info.GetSwapped());
|
|
|
|
}
|
|
|
|
void Clear() { x0_list.clear(); }
|
|
|
|
const CCollisionInfo& Front() const { return x0_list.front(); }
|
|
|
|
const CCollisionInfo& GetItem(int i) const { return x0_list[i]; }
|
2020-03-18 01:40:00 +00:00
|
|
|
|
|
|
|
auto end() noexcept { return x0_list.end(); }
|
|
|
|
auto end() const noexcept { return x0_list.end(); }
|
|
|
|
auto begin() noexcept { return x0_list.begin(); }
|
|
|
|
auto begin() const noexcept { return x0_list.begin(); }
|
2020-06-26 02:37:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AccumulateNewContactsInto(CCollisionInfoList& other_list) {
|
|
|
|
for (CCollisionInfo const& cur_info : x0_list) {
|
|
|
|
bool dont_add_new_info = false;
|
|
|
|
for (CCollisionInfo& other_info : other_list) {
|
|
|
|
if (!zeus::close_enough(other_info.GetPoint(), cur_info.GetPoint(), 0.1f)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
zeus::CVector3f norm = other_info.GetNormalLeft().normalized();
|
|
|
|
if (zeus::close_enough(norm, cur_info.GetNormalLeft(), 1.2f)) {
|
|
|
|
dont_add_new_info = true;
|
|
|
|
other_info.x0_point = (other_info.x0_point + cur_info.x0_point) * 0.5f;
|
|
|
|
other_info.x38_materialLeft.Add(cur_info.x38_materialLeft);
|
|
|
|
other_info.x40_materialRight.Add(cur_info.x40_materialRight);
|
|
|
|
other_info.x48_normalLeft = other_info.x48_normalLeft + cur_info.x48_normalLeft;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!dont_add_new_info) {
|
|
|
|
other_list.Add(cur_info, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (CCollisionInfo& other_info : other_list.x0_list) {
|
|
|
|
other_info.x48_normalLeft.normalize();
|
|
|
|
other_info.x54_normalRight = -other_info.x48_normalLeft;
|
|
|
|
}
|
|
|
|
}
|
2016-06-26 01:11:09 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|