Merge pull request #199 from lioncash/octree

CPVSVisOctree: Use static qualifying name for ReadBoundingBoxBig()
This commit is contained in:
Phillip Stephens 2020-03-08 18:03:44 -07:00 committed by GitHub
commit a28b7a8df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 15 deletions

View File

@ -1,25 +1,32 @@
#include "Runtime/Graphics/CPVSVisOctree.hpp" #include "Runtime/Graphics/CPVSVisOctree.hpp"
#include <array>
namespace urde { namespace urde {
CPVSVisOctree CPVSVisOctree::MakePVSVisOctree(const u8* data) { CPVSVisOctree CPVSVisOctree::MakePVSVisOctree(const u8* data) {
CMemoryInStream r(data, 68); CMemoryInStream r(data, 68);
zeus::CAABox aabb = aabb.ReadBoundingBoxBig(r); const zeus::CAABox aabb = zeus::CAABox::ReadBoundingBoxBig(r);
u32 numObjects = r.readUint32Big(); const u32 numObjects = r.readUint32Big();
u32 numLights = r.readUint32Big(); const u32 numLights = r.readUint32Big();
r.readUint32Big(); r.readUint32Big();
return CPVSVisOctree(aabb, numObjects, numLights, data + r.position()); return CPVSVisOctree(aabb, numObjects, numLights, data + r.position());
} }
CPVSVisOctree::CPVSVisOctree(const zeus::CAABox& aabb, u32 numObjects, u32 numLights, const u8* c) CPVSVisOctree::CPVSVisOctree(const zeus::CAABox& aabb, u32 numObjects, u32 numLights, const u8* c)
: x0_aabb(aabb), x18_numObjects(numObjects), x1c_numLights(numLights), x20_bufferFlag(c != nullptr), x24_octreeData(c) { : x0_aabb(aabb)
x2c_searchAabb = x0_aabb; , x18_numObjects(numObjects)
x20_bufferFlag = 0; , x1c_numLights(numLights)
, x20_bufferFlag(c != nullptr)
, x24_octreeData(c)
, x2c_searchAabb(x0_aabb) {
x20_bufferFlag = false;
} }
static const u32 NumChildTable[] = {0, 2, 2, 4, 2, 4, 4, 8}; u32 CPVSVisOctree::GetNumChildren(u8 byte) const {
static constexpr std::array<u32, 8> numChildTable{0, 2, 2, 4, 2, 4, 4, 8};
u32 CPVSVisOctree::GetNumChildren(u8 byte) const { return NumChildTable[byte & 0x7]; } return numChildTable[byte & 0x7];
}
u32 CPVSVisOctree::GetChildIndex(const u8*, const zeus::CVector3f&) const { return 0; } u32 CPVSVisOctree::GetChildIndex(const u8*, const zeus::CVector3f&) const { return 0; }
@ -29,7 +36,7 @@ s32 CPVSVisOctree::IterateSearch(u8 nodeData, const zeus::CVector3f& tp) const {
zeus::CVector3f newMin = x2c_searchAabb.center(); zeus::CVector3f newMin = x2c_searchAabb.center();
zeus::CVector3f newMax; zeus::CVector3f newMax;
bool highFlags[3]; std::array<bool, 3> highFlags{};
if (tp.x() > newMin.x()) { if (tp.x() > newMin.x()) {
newMax.x() = x2c_searchAabb.max.x(); newMax.x() = x2c_searchAabb.max.x();
@ -58,7 +65,7 @@ s32 CPVSVisOctree::IterateSearch(u8 nodeData, const zeus::CVector3f& tp) const {
highFlags[2] = false; highFlags[2] = false;
} }
u8 axisCounts[2] = {1, 1}; std::array<u8, 2> axisCounts{1, 1};
if (nodeData & 0x1) if (nodeData & 0x1)
axisCounts[0] = 2; axisCounts[0] = 2;
if (nodeData & 0x2) if (nodeData & 0x2)

View File

@ -10,10 +10,10 @@ namespace urde {
class CPVSVisOctree { class CPVSVisOctree {
zeus::CAABox x0_aabb; zeus::CAABox x0_aabb;
u32 x18_numObjects; u32 x18_numObjects = 0;
u32 x1c_numLights; u32 x1c_numLights = 0;
bool x20_bufferFlag; bool x20_bufferFlag = false;
const u8* x24_octreeData; const u8* x24_octreeData = nullptr;
zeus::CAABox x2c_searchAabb; zeus::CAABox x2c_searchAabb;
public: public: