From b754be5a68d50f853186d5c6d91b81286daf9d3d Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 4 Nov 2025 21:30:05 +0000 Subject: [PATCH] chore: do not use class wrapper for bsp utils methods --- src/ObjLoading/Game/T6/BSP/BSPCreator.cpp | 6 ++-- src/ObjLoading/Game/T6/BSP/BSPUtil.cpp | 20 ++++++------- src/ObjLoading/Game/T6/BSP/BSPUtil.h | 30 ++++++++++--------- .../Game/T6/BSP/Linker/ClipMapLinker.cpp | 18 +++++------ .../Game/T6/BSP/Linker/GfxWorldLinker.cpp | 4 +-- .../Game/T6/BSP/Linker/MapEntsLinker.cpp | 4 +-- 6 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp index 98aff9bf..9de19d55 100644 --- a/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp +++ b/src/ObjLoading/Game/T6/BSP/BSPCreator.cpp @@ -96,7 +96,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 == MATERIAL_TYPE_TEXTURE || surface.material.materialType == MATERIAL_TYPE_EMPTY) { @@ -199,7 +199,7 @@ namespace BSP std::unique_ptr createBSPData(const std::string& mapName, ISearchPath& searchPath) { std::string gfxFbxFileName = "map_gfx.fbx"; - std::string gfxFbxPath = BSPUtil::getFileNameForBSPAsset(gfxFbxFileName); + std::string gfxFbxPath = GetFileNameForBSPAsset(gfxFbxFileName); auto gfxFile = searchPath.Open(gfxFbxPath); if (!gfxFile.IsOpen()) { @@ -229,7 +229,7 @@ namespace BSP ufbx_scene* colScene; std::string colFbxFileName = "map_col.fbx"; - const auto colFbxPath = BSPUtil::getFileNameForBSPAsset(colFbxFileName); + const auto colFbxPath = GetFileNameForBSPAsset(colFbxFileName); 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 18f08de1..8a58c731 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; @@ -65,7 +65,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; @@ -75,7 +75,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; @@ -85,7 +85,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; @@ -110,7 +110,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 9fe2a787..e0968998 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp @@ -144,7 +144,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; @@ -260,14 +260,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); @@ -292,15 +292,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); } @@ -418,7 +418,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); @@ -438,7 +438,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 6b8dcb7d..4f00b8f8 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/GfxWorldLinker.cpp @@ -109,7 +109,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 @@ -499,7 +499,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 89410deb..e3a71400 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/MapEntsLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/MapEntsLinker.cpp @@ -80,7 +80,7 @@ namespace BSP { json entJs; std::string entityFileName = "entities.json"; - std::string entityFilePath = BSPUtil::getFileNameForBSPAsset(entityFileName); + std::string entityFilePath = GetFileNameForBSPAsset(entityFileName); const auto entFile = m_search_path.Open(entityFilePath); if (!entFile.IsOpen()) { @@ -97,7 +97,7 @@ namespace BSP json spawnJs; std::string spawnFileName = "spawns.json"; - std::string spawnFilePath = BSPUtil::getFileNameForBSPAsset(spawnFileName); + std::string spawnFilePath = GetFileNameForBSPAsset(spawnFileName); const auto spawnFile = m_search_path.Open(spawnFilePath); if (!spawnFile.IsOpen()) {