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

WIP: Prepared project for updating CustomMapLinker.h

This commit is contained in:
LJW-Dev
2025-10-22 16:42:12 +08:00
parent e53779517d
commit a81944a7be
5 changed files with 16 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
#include "BSPCreator.h"
#include "BSPUtil.h"
#include "fbx/ufbx.h"
namespace
@@ -192,7 +193,7 @@ namespace BSP
{
std::unique_ptr<BSPData> createBSPData(std::string& mapName, ISearchPath& searchPath)
{
std::string gfxFbxPath = "BSP/map_gfx.fbx";
std::string gfxFbxPath = BSPUtil::getFileNameForBSPAsset("map_gfx.fbx");
auto gfxFile = searchPath.Open(gfxFbxPath);
if (!gfxFile.IsOpen())
{
@@ -221,7 +222,7 @@ namespace BSP
}
ufbx_scene* colScene;
std::string colFbxPath = "BSP/map_col.fbx";
std::string colFbxPath = BSPUtil::getFileNameForBSPAsset("map_col.fbx");
auto colFile = searchPath.Open(colFbxPath);
if (!colFile.IsOpen())
{
@@ -252,7 +253,7 @@ namespace BSP
}
}
std::unique_ptr<BSPData> bsp;
std::unique_ptr<BSPData> bsp = std::make_unique<BSPData>();
bsp->name = mapName;
bsp->bspName = "maps/mp/" + mapName + ".d3dbsp";

View File

@@ -5,6 +5,11 @@
#include "BSPUtil.h"
std::string BSPUtil::getFileNameForBSPAsset(std::string assetName)
{
return std::format("BSP/{}", assetName);
}
// BO2 uses a different coordinate system, so this converts it back from OpenGLs default
vec3_t BSPUtil::convertToBO2Coords(vec3_t OGL_coordinate)
{

View File

@@ -6,6 +6,7 @@
class BSPUtil
{
public:
static std::string getFileNameForBSPAsset(std::string assetName);
static vec3_t convertToBO2Coords(vec3_t OGL_coordinate);
static vec3_t convertFromBO2Coords(vec3_t bo2_coordinate);
static void calcNewBounds(vec3_t* newmins, vec3_t* newmaxs, vec3_t* currmins, vec3_t* currmaxs);

View File

@@ -1168,7 +1168,7 @@ namespace BSP
// converting OGL -> BO2 Z coords negates the z coords and sets it to the y coord.
// convert the z normal to the y normal, but don't negate it. Negative normals don't do
// what is expected when the game uses them
_ASSERT(node->u.node->axis == AXIS_Z);
_ASSERT(node->node->axis == AXIS_Z);
currPlane->normal = normalY;
// converting OGL -> BO2 Z coords negates the z coords and sets it to the y coord.

View File

@@ -19,20 +19,20 @@ namespace
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
// custom maps must have a map_gfx file
auto mapGfxFile = m_search_path.Open("BSP/map_gfx.fbx");
auto mapGfxFile = m_search_path.Open(BSPUtil::getFileNameForBSPAsset("map_gfx.fbx"));
if (!mapGfxFile.IsOpen())
return AssetCreationResult::NoAction();
BSPData* BSP = BSP::createBSPData(m_zone.m_name, m_search_path);
if (BSP == nullptr)
std::unique_ptr<BSPData> bsp = BSP::createBSPData(m_zone.m_name, m_search_path);
if (bsp == nullptr)
return AssetCreationResult::Failure();
CustomMapLinker linker(m_memory, m_search_path, m_zone, context);
bool result = linker.linkCustomMap(BSP);
bool result = linker.linkCustomMap(bsp.get());
if (result)
{
auto gfxWorldAsset = context.LoadDependency<AssetGfxWorld>(BSP->bspName);
auto gfxWorldAsset = context.LoadDependency<AssetGfxWorld>(bsp->bspName);
_ASSERT(gfxWorldAsset != nullptr);
return AssetCreationResult::Success(gfxWorldAsset);
}