diff --git a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp index 67e5a72e..6d014c71 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp @@ -98,7 +98,7 @@ namespace blenderCoords.x = static_cast(transformedPos.x); blenderCoords.y = static_cast(transformedPos.y); blenderCoords.z = static_cast(transformedPos.z); - vertex.pos = BSPUtil::convertToBO2Coords(blenderCoords); + vertex.pos = ConvertToBO2Coords(blenderCoords); if (surface.material.materialType == BSPMaterialType::MATERIAL_TYPE_TEXTURE || surface.material.materialType == BSPMaterialType::MATERIAL_TYPE_EMPTY) @@ -203,7 +203,7 @@ namespace BSP { std::unique_ptr createBSPData(const std::string& mapName, ISearchPath& searchPath) { - const auto gfxFbxPath = BSPUtil::getFileNameForBSPAsset("map_gfx.fbx"); + const auto gfxFbxPath = GetFileNameForBSPAsset("map_gfx.fbx"); const auto gfxFile = searchPath.Open(gfxFbxPath); if (!gfxFile.IsOpen()) { @@ -232,7 +232,7 @@ namespace BSP } ufbx_scene* colScene; - const auto colFbxPath = BSPUtil::getFileNameForBSPAsset("map_col.fbx"); + const auto colFbxPath = GetFileNameForBSPAsset("map_col.fbx"); const auto colFile = searchPath.Open(colFbxPath); if (!colFile.IsOpen()) { diff --git a/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp b/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp index b931a680..9a9ae931 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPUtil.cpp @@ -9,12 +9,12 @@ using namespace T6; namespace BSP { - std::string BSPUtil::getFileNameForBSPAsset(const std::string& assetName) + std::string GetFileNameForBSPAsset(const std::string& assetName) { return std::format("BSP/{}", assetName); } - vec3_t BSPUtil::convertToBO2Coords(const vec3_t& coordinate) + vec3_t ConvertToBO2Coords(const vec3_t& coordinate) { vec3_t result; result.x = coordinate.x; @@ -23,7 +23,7 @@ namespace BSP return result; } - vec3_t BSPUtil::convertFromBO2Coords(const vec3_t& coordinate) + vec3_t ConvertFromBO2Coords(const vec3_t& coordinate) { vec3_t result; result.x = coordinate.x; @@ -32,7 +32,7 @@ namespace BSP return result; } - void BSPUtil::updateAABB(const vec3_t& newAABBMins, const vec3_t& newAABBMaxs, vec3_t& AABBMins, vec3_t& AABBMaxs) + void UpdateAABB(const vec3_t& newAABBMins, const vec3_t& newAABBMaxs, vec3_t& AABBMins, vec3_t& AABBMaxs) { AABBMins.x = std::min(AABBMins.x, newAABBMins.x); AABBMaxs.x = std::max(AABBMaxs.x, newAABBMaxs.x); @@ -44,7 +44,7 @@ namespace BSP AABBMaxs.z = std::max(AABBMaxs.z, newAABBMaxs.z); } - void BSPUtil::updateAABBWithPoint(const vec3_t& point, vec3_t& AABBMins, vec3_t& AABBMaxs) + void UpdateAABBWithPoint(const vec3_t& point, vec3_t& AABBMins, vec3_t& AABBMaxs) { AABBMins.x = std::min(AABBMins.x, point.x); AABBMaxs.x = std::max(AABBMaxs.x, point.x); @@ -56,7 +56,7 @@ namespace BSP AABBMaxs.z = std::max(AABBMaxs.z, point.z); } - vec3_t BSPUtil::calcMiddleOfAABB(const vec3_t& mins, const vec3_t& maxs) + vec3_t CalcMiddleOfAABB(const vec3_t& mins, const vec3_t& maxs) { vec3_t result; result.x = (mins.x + maxs.x) * 0.5f; @@ -66,7 +66,7 @@ namespace BSP return result; } - vec3_t BSPUtil::calcHalfSizeOfAABB(const vec3_t& mins, const vec3_t& maxs) + vec3_t CalcHalfSizeOfAABB(const vec3_t& mins, const vec3_t& maxs) { vec3_t result; result.x = (maxs.x - mins.x) * 0.5f; @@ -76,7 +76,7 @@ namespace BSP return result; } - float BSPUtil::distBetweenPoints(const vec3_t& p1, const vec3_t& p2) + float DistBetweenPoints(const vec3_t& p1, const vec3_t& p2) { const auto x = p2.x - p1.x; const auto y = p2.y - p1.y; @@ -86,7 +86,7 @@ namespace BSP } // angles are in euler degrees - void BSPUtil::convertAnglesToAxis(const vec3_t* angles, vec3_t* axis) + void ConvertAnglesToAxis(const vec3_t* angles, vec3_t* axis) { constexpr auto conversionValue = std::numbers::pi_v / 180.0f; const auto xRadians = angles->x * conversionValue; @@ -111,7 +111,7 @@ namespace BSP axis[2].z = cosZ * cosX; } - void BSPUtil::matrixTranspose3x3(const vec3_t* in, vec3_t* out) + void MatrixTranspose3x3(const vec3_t* in, vec3_t* out) { out[0].x = in[0].x; out[0].y = in[1].x; diff --git a/src/ObjLoading/Game/T6/BSP/BSPUtil.h b/src/ObjLoading/Game/T6/BSP/BSPUtil.h index fadc929f..98f14fda 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPUtil.h +++ b/src/ObjLoading/Game/T6/BSP/BSPUtil.h @@ -4,18 +4,20 @@ namespace BSP { - class BSPUtil - { - public: - static std::string getFileNameForBSPAsset(const std::string& assetName); - static T6::vec3_t convertToBO2Coords(const T6::vec3_t& OGL_coordinate); - static T6::vec3_t convertFromBO2Coords(const T6::vec3_t& bo2_coordinate); - static void updateAABB(const T6::vec3_t& newAABBMins, const T6::vec3_t& newAABBMaxs, T6::vec3_t& AABBMins, T6::vec3_t& AABBMaxs); - static void updateAABBWithPoint(const T6::vec3_t& point, T6::vec3_t& AABBMins, T6::vec3_t& AABBMaxs); - static T6::vec3_t calcMiddleOfAABB(const T6::vec3_t& mins, const T6::vec3_t& maxs); - static T6::vec3_t calcHalfSizeOfAABB(const T6::vec3_t& mins, const T6::vec3_t& maxs); - static float distBetweenPoints(const T6::vec3_t& p1, const T6::vec3_t& p2); - static void convertAnglesToAxis(const T6::vec3_t* angles, T6::vec3_t* axis); - static void matrixTranspose3x3(const T6::vec3_t* in, T6::vec3_t* out); - }; + std::string GetFileNameForBSPAsset(const std::string& assetName); + + T6::vec3_t ConvertToBO2Coords(const T6::vec3_t& OGL_coordinate); + T6::vec3_t ConvertFromBO2Coords(const T6::vec3_t& bo2_coordinate); + + void UpdateAABB(const T6::vec3_t& newAABBMins, const T6::vec3_t& newAABBMaxs, T6::vec3_t& AABBMins, T6::vec3_t& AABBMaxs); + void UpdateAABBWithPoint(const T6::vec3_t& point, T6::vec3_t& AABBMins, T6::vec3_t& AABBMaxs); + + T6::vec3_t CalcMiddleOfAABB(const T6::vec3_t& mins, const T6::vec3_t& maxs); + T6::vec3_t CalcHalfSizeOfAABB(const T6::vec3_t& mins, const T6::vec3_t& maxs); + + float DistBetweenPoints(const T6::vec3_t& p1, const T6::vec3_t& p2); + + void ConvertAnglesToAxis(const T6::vec3_t* angles, T6::vec3_t* axis); + + void MatrixTranspose3x3(const T6::vec3_t* in, T6::vec3_t* out); } // namespace BSP diff --git a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp index 1441519c..5f2a8556 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp @@ -146,7 +146,7 @@ namespace BSP clipMap.cmodels[0].maxs.x = gfxModel->bounds[1].x; clipMap.cmodels[0].maxs.y = gfxModel->bounds[1].y; clipMap.cmodels[0].maxs.z = gfxModel->bounds[1].z; - clipMap.cmodels[0].radius = BSPUtil::distBetweenPoints(clipMap.cmodels[0].mins, clipMap.cmodels[0].maxs) / 2; + clipMap.cmodels[0].radius = DistBetweenPoints(clipMap.cmodels[0].mins, clipMap.cmodels[0].maxs) / 2; // The world sub model has no leafs associated with it clipMap.cmodels[0].leaf.firstCollAabbIndex = 0; @@ -262,14 +262,14 @@ namespace BSP parentMaxs = vert; } - BSPUtil::updateAABBWithPoint(vert, parentMins, parentMaxs); + UpdateAABBWithPoint(vert, parentMins, parentMaxs); } } size_t childObjectStartIndex = AABBTreeVec.size(); CollisionAabbTree parentAABB; - parentAABB.origin = BSPUtil::calcMiddleOfAABB(parentMins, parentMaxs); - parentAABB.halfSize = BSPUtil::calcHalfSizeOfAABB(parentMins, parentMaxs); + parentAABB.origin = CalcMiddleOfAABB(parentMins, parentMaxs); + parentAABB.halfSize = CalcHalfSizeOfAABB(parentMins, parentMaxs); parentAABB.materialIndex = 0; // always use the first material parentAABB.childCount = static_cast(childObjectCount); parentAABB.u.firstChildIndex = static_cast(childObjectStartIndex); @@ -294,15 +294,15 @@ namespace BSP childMaxs = vert; } - BSPUtil::updateAABBWithPoint(vert, childMins, childMaxs); + UpdateAABBWithPoint(vert, childMins, childMaxs); } CollisionAabbTree childAABBTree{}; childAABBTree.materialIndex = 0; // always use the first material childAABBTree.childCount = 0; childAABBTree.u.partitionIndex = partitionIndex; - childAABBTree.origin = BSPUtil::calcMiddleOfAABB(childMins, childMaxs); - childAABBTree.halfSize = BSPUtil::calcHalfSizeOfAABB(childMins, childMaxs); + childAABBTree.origin = CalcMiddleOfAABB(childMins, childMaxs); + childAABBTree.halfSize = CalcHalfSizeOfAABB(childMins, childMaxs); AABBTreeVec.emplace_back(childAABBTree); } @@ -428,7 +428,7 @@ namespace BSP worldMins = vertex; worldMaxs = vertex; } - BSPUtil::updateAABBWithPoint(vertex, worldMins, worldMaxs); + UpdateAABBWithPoint(vertex, worldMins, worldMaxs); } const auto tree = std::make_unique(worldMins.x, worldMins.y, worldMins.z, worldMaxs.x, worldMaxs.y, worldMaxs.z, 0); assert(!tree->isLeaf); @@ -448,7 +448,7 @@ namespace BSP partitionMins = vert; partitionMaxs = vert; } - BSPUtil::updateAABBWithPoint(vert, partitionMins, partitionMaxs); + UpdateAABBWithPoint(vert, partitionMins, partitionMaxs); } auto currObject = std::make_shared(partitionMins.x, partitionMins.y, partitionMins.z, partitionMaxs.x, partitionMaxs.y, partitionMaxs.z, partitionIdx); diff --git a/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp index a5623981..498765c4 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp @@ -110,7 +110,7 @@ namespace BSP for (size_t indexIdx = 0; indexIdx < static_cast(gfxSurface->tris.triCount * 3); indexIdx++) { uint16_t vertIndex = gfxWorld.draw.indices[gfxSurface->tris.baseIndex + indexIdx]; - BSPUtil::updateAABBWithPoint(firstVert[vertIndex].xyz, gfxSurface->bounds[0], gfxSurface->bounds[1]); + UpdateAABBWithPoint(firstVert[vertIndex].xyz, gfxSurface->bounds[0], gfxSurface->bounds[1]); } // unused values @@ -500,7 +500,7 @@ namespace BSP for (int surfIdx = 0; surfIdx < gfxWorld.surfaceCount; surfIdx++) { - BSPUtil::updateAABB(gfxWorld.dpvs.surfaces[surfIdx].bounds[0], gfxWorld.dpvs.surfaces[surfIdx].bounds[1], gfxWorld.mins, gfxWorld.maxs); + UpdateAABB(gfxWorld.dpvs.surfaces[surfIdx].bounds[0], gfxWorld.dpvs.surfaces[surfIdx].bounds[1], gfxWorld.mins, gfxWorld.maxs); } } diff --git a/src/ObjLoading/Game/T6/BSP/Linker/MapEntsLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/MapEntsLinker.cpp index 081ba825..e5399889 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/MapEntsLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/MapEntsLinker.cpp @@ -77,7 +77,7 @@ namespace BSP try { json entJs; - const auto entityFilePath = BSPUtil::getFileNameForBSPAsset("entities.json"); + const auto entityFilePath = GetFileNameForBSPAsset("entities.json"); const auto entFile = m_search_path.Open(entityFilePath); if (!entFile.IsOpen()) { @@ -93,7 +93,7 @@ namespace BSP return nullptr; json spawnJs; - const auto spawnFilePath = BSPUtil::getFileNameForBSPAsset("spawns.json"); + const auto spawnFilePath = GetFileNameForBSPAsset("spawns.json"); const auto spawnFile = m_search_path.Open(spawnFilePath); if (!spawnFile.IsOpen()) {