2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-23 21:22:07 +00:00

Formatted all BSP loading files using clang.

This commit is contained in:
LJW-Dev
2025-10-27 20:43:30 +08:00
parent 0e19f365ff
commit 0fa473eadd
22 changed files with 384 additions and 402 deletions

View File

@@ -1,13 +1,12 @@
#pragma once #pragma once
#include <vector> #include "Game/T6/T6.h"
#include <string>
#include <memory>
#include <cassert>
#include "Utils/Logging/Log.h" #include "Utils/Logging/Log.h"
#include "Game/T6/T6.h" #include <cassert>
#include <memory>
#include <string>
#include <vector>
using namespace T6; using namespace T6;
namespace BSP namespace BSP
@@ -71,8 +70,7 @@ namespace BSP
BSP_DEFAULT_LIGHT_COUNT = 2 BSP_DEFAULT_LIGHT_COUNT = 2
}; };
inline const char* DEFENDER_SPAWN_POINT_NAMES[] = { inline const char* DEFENDER_SPAWN_POINT_NAMES[] = {"mp_ctf_spawn_allies",
"mp_ctf_spawn_allies",
"mp_ctf_spawn_allies_start", "mp_ctf_spawn_allies_start",
"mp_sd_spawn_defender", "mp_sd_spawn_defender",
"mp_dom_spawn_allies_start", "mp_dom_spawn_allies_start",
@@ -82,11 +80,9 @@ namespace BSP
"mp_tdm_spawn_allies_start", "mp_tdm_spawn_allies_start",
"mp_tdm_spawn_team1_start", "mp_tdm_spawn_team1_start",
"mp_tdm_spawn_team2_start", "mp_tdm_spawn_team2_start",
"mp_tdm_spawn_team3_start" "mp_tdm_spawn_team3_start"};
};
inline const char* ATTACKER_SPAWN_POINT_NAMES[] = { inline const char* ATTACKER_SPAWN_POINT_NAMES[] = {"mp_ctf_spawn_axis",
"mp_ctf_spawn_axis",
"mp_ctf_spawn_axis_start", "mp_ctf_spawn_axis_start",
"mp_sd_spawn_attacker", "mp_sd_spawn_attacker",
"mp_dom_spawn_axis_start", "mp_dom_spawn_axis_start",
@@ -96,15 +92,10 @@ namespace BSP
"mp_tdm_spawn_axis_start", "mp_tdm_spawn_axis_start",
"mp_tdm_spawn_team4_start", "mp_tdm_spawn_team4_start",
"mp_tdm_spawn_team5_start", "mp_tdm_spawn_team5_start",
"mp_tdm_spawn_team6_start" "mp_tdm_spawn_team6_start"};
};
inline const char* FFA_SPAWN_POINT_NAMES[] = { inline const char* FFA_SPAWN_POINT_NAMES[] = {"mp_tdm_spawn", "mp_dm_spawn", "mp_dom_spawn"};
"mp_tdm_spawn", } // namespace BSPGameConstants
"mp_dm_spawn",
"mp_dom_spawn"
};
}
// BSPLinkingConstants: // BSPLinkingConstants:
// These values are BSP linking constants that are required for the link to be successful // These values are BSP linking constants that are required for the link to be successful
@@ -134,7 +125,6 @@ namespace BSP
] ]
})"; })";
constexpr const char* DEFAULT_MAP_ENTS_STRING = R"({ constexpr const char* DEFAULT_MAP_ENTS_STRING = R"({
"entities": [ "entities": [
{ {
@@ -152,7 +142,7 @@ namespace BSP
} }
] ]
})"; })";
} } // namespace BSPLinkingConstants
// BSPEditableConstants: // BSPEditableConstants:
// These values are BSP constants that can be edited and may not break the linker/game if changed // These values are BSP constants that can be edited and may not break the linker/game if changed
@@ -190,5 +180,5 @@ namespace BSP
// Sunlight values // Sunlight values
constexpr vec4_t SUNLIGHT_COLOR = {0.75f, 0.75f, 0.75f, 1.0f}; constexpr vec4_t SUNLIGHT_COLOR = {0.75f, 0.75f, 0.75f, 1.0f};
constexpr vec3_t SUNLIGHT_DIRECTION = {0.0f, 0.0f, 0.0f}; constexpr vec3_t SUNLIGHT_DIRECTION = {0.0f, 0.0f, 0.0f};
}; }; // namespace BSPEditableConstants
} } // namespace BSP

View File

@@ -148,4 +148,4 @@ namespace BSP
} }
} }
} }
} } // namespace BSP

View File

@@ -28,7 +28,6 @@ namespace BSP
BSPObject(float xMin, float yMin, float zMin, float xMax, float yMax, float zMax, int objPartitionIndex); BSPObject(float xMin, float yMin, float zMin, float xMax, float yMax, float zMax, int objPartitionIndex);
}; };
class BSPLeaf class BSPLeaf
{ {
public: public:
@@ -69,4 +68,4 @@ namespace BSP
void splitTree(); void splitTree();
void addObjectToTree(std::shared_ptr<BSPObject> object); void addObjectToTree(std::shared_ptr<BSPObject> object);
}; };
} } // namespace BSP

View File

@@ -6,11 +6,8 @@ namespace
{ {
using namespace BSP; using namespace BSP;
void addFBXMeshToWorld(ufbx_node* node, void addFBXMeshToWorld(
std::vector<BSPSurface>& surfaceVec, ufbx_node* node, std::vector<BSPSurface>& surfaceVec, std::vector<BSPVertex>& vertexVec, std::vector<uint16_t>& indexVec, bool& hasTangentSpace)
std::vector<BSPVertex>& vertexVec,
std::vector<uint16_t>& indexVec,
bool& hasTangentSpace)
{ {
ufbx_mesh* mesh = node->mesh; ufbx_mesh* mesh = node->mesh;
@@ -187,7 +184,7 @@ namespace
if (hasTangentSpace == false) if (hasTangentSpace == false)
con::warn("warning: one or more meshes have no tangent space. Be sure to select the tangent space box when exporting the FBX."); con::warn("warning: one or more meshes have no tangent space. Be sure to select the tangent space box when exporting the FBX.");
} }
} } // namespace
namespace BSP namespace BSP
{ {

View File

@@ -6,4 +6,4 @@
namespace BSP namespace BSP
{ {
std::unique_ptr<BSPData> createBSPData(std::string& mapName, ISearchPath& searchPath); std::unique_ptr<BSPData> createBSPData(std::string& mapName, ISearchPath& searchPath);
}; }; // namespace BSP

View File

@@ -1,10 +1,12 @@
#pragma once #pragma once
#include "BSPUtil.h"
#include <cmath> #include <cmath>
#include <format> #include <format>
#include "BSPUtil.h" namespace BSP
{
std::string BSPUtil::getFileNameForBSPAsset(std::string& assetName) std::string BSPUtil::getFileNameForBSPAsset(std::string& assetName)
{ {
return std::format("BSP/{}", assetName); return std::format("BSP/{}", assetName);
@@ -167,3 +169,5 @@ std::string BSPUtil::convertVec3ToString(vec3_t& vec)
std::string result = std::format("{} {} {}", vec.x, vec.y, vec.z); std::string result = std::format("{} {} {}", vec.x, vec.y, vec.z);
return result; return result;
} }
} // namespace BSP

View File

@@ -2,7 +2,8 @@
#include "BSP.h" #include "BSP.h"
namespace BSP
{
class BSPUtil class BSPUtil
{ {
public: public:
@@ -20,3 +21,4 @@ public:
static vec3_t convertStringToVec3(std::string& str); static vec3_t convertStringToVec3(std::string& str);
static std::string convertVec3ToString(vec3_t& vec); static std::string convertVec3ToString(vec3_t& vec);
}; };
} // namespace BSP

View File

@@ -1,7 +1,6 @@
#include "BSPLinker.h" #include "BSPLinker.h"
#include "ComWorldLinker.h"
#include "ClipMapLinker.h" #include "ClipMapLinker.h"
#include "ComWorldLinker.h"
#include "GameWorldMpLinker.h" #include "GameWorldMpLinker.h"
#include "GfxWorldLinker.h" #include "GfxWorldLinker.h"
#include "MapEntsLinker.h" #include "MapEntsLinker.h"
@@ -93,5 +92,4 @@ namespace BSP
return result; return result;
} }
} } // namespace BSP

View File

@@ -21,4 +21,4 @@ namespace BSP
ISearchPath& m_search_path; ISearchPath& m_search_path;
AssetCreationContext& m_context; AssetCreationContext& m_context;
}; };
} } // namespace BSP

View File

@@ -1,5 +1,5 @@
#include "ClipMapLinker.h"
#include "../BSPUtil.h" #include "../BSPUtil.h"
#include "ClipMapLinker.h"
namespace BSP namespace BSP
{ {
@@ -428,7 +428,8 @@ namespace BSP
} }
BSPUtil::updateAABBWithPoint(vert, partitionMins, partitionMaxs); BSPUtil::updateAABBWithPoint(vert, partitionMins, partitionMaxs);
} }
std::shared_ptr<BSPObject> currObject = std::make_shared<BSPObject>(partitionMins.x, partitionMins.y, partitionMins.z, partitionMaxs.x, partitionMaxs.y, partitionMaxs.z, partitionIdx); std::shared_ptr<BSPObject> currObject =
std::make_shared<BSPObject>(partitionMins.x, partitionMins.y, partitionMins.z, partitionMaxs.x, partitionMaxs.y, partitionMaxs.z, partitionIdx);
tree->addObjectToTree(std::move(currObject)); tree->addObjectToTree(std::move(currObject));
} }
@@ -648,5 +649,4 @@ namespace BSP
auto clipMapAsset = m_context.AddAsset<AssetClipMap>(clipMap->name, clipMap); auto clipMapAsset = m_context.AddAsset<AssetClipMap>(clipMap->name, clipMap);
return AssetCreationResult::Success(clipMapAsset); return AssetCreationResult::Success(clipMapAsset);
} }
} } // namespace BSP

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include "../BSP.h" #include "../BSP.h"
#include "../BSPCalculation.h"
#include "Asset/IAssetCreator.h" #include "Asset/IAssetCreator.h"
#include "SearchPath/ISearchPath.h" #include "SearchPath/ISearchPath.h"
#include "Utils/MemoryManager.h" #include "Utils/MemoryManager.h"
#include "../BSPCalculation.h"
namespace BSP namespace BSP
{ {
@@ -36,4 +36,4 @@ namespace BSP
bool loadPartitions(clipMap_t* clipMap, BSPData* bsp); bool loadPartitions(clipMap_t* clipMap, BSPData* bsp);
bool loadWorldCollision(clipMap_t* clipMap, BSPData* bsp); bool loadWorldCollision(clipMap_t* clipMap, BSPData* bsp);
}; };
} } // namespace BSP

View File

@@ -35,5 +35,4 @@ namespace BSP
auto comWorldAsset = m_context.AddAsset<AssetComWorld>(comWorld->name, comWorld); auto comWorldAsset = m_context.AddAsset<AssetComWorld>(comWorld->name, comWorld);
return AssetCreationResult::Success(comWorldAsset); return AssetCreationResult::Success(comWorldAsset);
} }
} } // namespace BSP

View File

@@ -18,4 +18,4 @@ namespace BSP
ISearchPath& m_search_path; ISearchPath& m_search_path;
AssetCreationContext& m_context; AssetCreationContext& m_context;
}; };
} } // namespace BSP

View File

@@ -32,5 +32,4 @@ namespace BSP
auto gameWorldMpAsset = m_context.AddAsset<AssetGameWorldMp>(gameWorldMp->name, gameWorldMp); auto gameWorldMpAsset = m_context.AddAsset<AssetGameWorldMp>(gameWorldMp->name, gameWorldMp);
return AssetCreationResult::Success(gameWorldMpAsset); return AssetCreationResult::Success(gameWorldMpAsset);
} }
} } // namespace BSP

View File

@@ -18,4 +18,4 @@ namespace BSP
ISearchPath& m_search_path; ISearchPath& m_search_path;
AssetCreationContext& m_context; AssetCreationContext& m_context;
}; };
} } // namespace BSP

View File

@@ -1,5 +1,5 @@
#include "GfxWorldLinker.h"
#include "../BSPUtil.h" #include "../BSPUtil.h"
#include "GfxWorldLinker.h"
#include "Utils/Pack.h" #include "Utils/Pack.h"
namespace BSP namespace BSP
@@ -772,5 +772,4 @@ namespace BSP
auto gfxWorldAsset = m_context.AddAsset<AssetGfxWorld>(gfxWorld->name, gfxWorld); auto gfxWorldAsset = m_context.AddAsset<AssetGfxWorld>(gfxWorld->name, gfxWorld);
return AssetCreationResult::Success(gfxWorldAsset); return AssetCreationResult::Success(gfxWorldAsset);
} }
} } // namespace BSP

View File

@@ -34,4 +34,4 @@ namespace BSP
void loadSunData(GfxWorld* gfxWorld); void loadSunData(GfxWorld* gfxWorld);
void loadWorldBounds(GfxWorld* gfxWorld); void loadWorldBounds(GfxWorld* gfxWorld);
}; };
} } // namespace BSP

View File

@@ -1,5 +1,5 @@
#include "MapEntsLinker.h"
#include "../BSPUtil.h" #include "../BSPUtil.h"
#include "MapEntsLinker.h"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using namespace nlohmann; using namespace nlohmann;
@@ -59,11 +59,8 @@ namespace
} }
} }
std::string loadMapEnts() std::string loadMapEnts() {}
{ } // namespace
}
}
namespace BSP namespace BSP
{ {
@@ -138,5 +135,4 @@ namespace BSP
return AssetCreationResult::Failure(); return AssetCreationResult::Failure();
} }
} }
} } // namespace BSP

View File

@@ -18,4 +18,4 @@ namespace BSP
ISearchPath& m_search_path; ISearchPath& m_search_path;
AssetCreationContext& m_context; AssetCreationContext& m_context;
}; };
} } // namespace BSP

View File

@@ -22,5 +22,4 @@ namespace BSP
auto skinnedVertsAsset = m_context.AddAsset<AssetSkinnedVerts>(assetName, skinnedVerts); auto skinnedVertsAsset = m_context.AddAsset<AssetSkinnedVerts>(assetName, skinnedVerts);
return AssetCreationResult::Success(skinnedVertsAsset); return AssetCreationResult::Success(skinnedVertsAsset);
} }
} } // namespace BSP

View File

@@ -18,4 +18,4 @@ namespace BSP
ISearchPath& m_search_path; ISearchPath& m_search_path;
AssetCreationContext& m_context; AssetCreationContext& m_context;
}; };
} } // namespace BSP

View File

@@ -1,7 +1,7 @@
#include "LoaderBSP_T6.h"
#include "BSPCreator.h" #include "BSPCreator.h"
#include "BSPUtil.h" #include "BSPUtil.h"
#include "Linker/BSPLinker.h" #include "Linker/BSPLinker.h"
#include "LoaderBSP_T6.h"
namespace namespace
{ {