From 4034e3b31fb041f72bdcf9e77562d209f179f2b3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 7 Mar 2020 04:50:16 -0500 Subject: [PATCH] CPVSVisOctree: Make use of std::array where applicable Makes the arrays strongly typed. --- Runtime/Graphics/CPVSVisOctree.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Runtime/Graphics/CPVSVisOctree.cpp b/Runtime/Graphics/CPVSVisOctree.cpp index 67bd7f231..e08440d85 100644 --- a/Runtime/Graphics/CPVSVisOctree.cpp +++ b/Runtime/Graphics/CPVSVisOctree.cpp @@ -1,5 +1,7 @@ #include "Runtime/Graphics/CPVSVisOctree.hpp" +#include + namespace urde { CPVSVisOctree CPVSVisOctree::MakePVSVisOctree(const u8* data) { @@ -17,9 +19,10 @@ CPVSVisOctree::CPVSVisOctree(const zeus::CAABox& aabb, u32 numObjects, u32 numLi x20_bufferFlag = 0; } -static const u32 NumChildTable[] = {0, 2, 2, 4, 2, 4, 4, 8}; - -u32 CPVSVisOctree::GetNumChildren(u8 byte) const { return NumChildTable[byte & 0x7]; } +u32 CPVSVisOctree::GetNumChildren(u8 byte) const { + static constexpr std::array numChildTable{0, 2, 2, 4, 2, 4, 4, 8}; + return numChildTable[byte & 0x7]; +} u32 CPVSVisOctree::GetChildIndex(const u8*, const zeus::CVector3f&) const { return 0; } @@ -29,7 +32,7 @@ s32 CPVSVisOctree::IterateSearch(u8 nodeData, const zeus::CVector3f& tp) const { zeus::CVector3f newMin = x2c_searchAabb.center(); zeus::CVector3f newMax; - bool highFlags[3]; + std::array highFlags{}; if (tp.x() > newMin.x()) { newMax.x() = x2c_searchAabb.max.x(); @@ -58,7 +61,7 @@ s32 CPVSVisOctree::IterateSearch(u8 nodeData, const zeus::CVector3f& tp) const { highFlags[2] = false; } - u8 axisCounts[2] = {1, 1}; + std::array axisCounts{1, 1}; if (nodeData & 0x1) axisCounts[0] = 2; if (nodeData & 0x2)