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

View File

@@ -5,6 +5,11 @@
#include "BSPUtil.h" #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 // BO2 uses a different coordinate system, so this converts it back from OpenGLs default
vec3_t BSPUtil::convertToBO2Coords(vec3_t OGL_coordinate) vec3_t BSPUtil::convertToBO2Coords(vec3_t OGL_coordinate)
{ {

View File

@@ -6,6 +6,7 @@
class BSPUtil class BSPUtil
{ {
public: public:
static std::string getFileNameForBSPAsset(std::string assetName);
static vec3_t convertToBO2Coords(vec3_t OGL_coordinate); static vec3_t convertToBO2Coords(vec3_t OGL_coordinate);
static vec3_t convertFromBO2Coords(vec3_t bo2_coordinate); static vec3_t convertFromBO2Coords(vec3_t bo2_coordinate);
static void calcNewBounds(vec3_t* newmins, vec3_t* newmaxs, vec3_t* currmins, vec3_t* currmaxs); 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. // 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 // 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 // what is expected when the game uses them
_ASSERT(node->u.node->axis == AXIS_Z); _ASSERT(node->node->axis == AXIS_Z);
currPlane->normal = normalY; currPlane->normal = normalY;
// converting OGL -> BO2 Z coords negates the z coords and sets it to the y coord. // 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 AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{ {
// custom maps must have a map_gfx file // 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()) if (!mapGfxFile.IsOpen())
return AssetCreationResult::NoAction(); return AssetCreationResult::NoAction();
BSPData* BSP = BSP::createBSPData(m_zone.m_name, m_search_path); std::unique_ptr<BSPData> bsp = BSP::createBSPData(m_zone.m_name, m_search_path);
if (BSP == nullptr) if (bsp == nullptr)
return AssetCreationResult::Failure(); return AssetCreationResult::Failure();
CustomMapLinker linker(m_memory, m_search_path, m_zone, context); CustomMapLinker linker(m_memory, m_search_path, m_zone, context);
bool result = linker.linkCustomMap(BSP); bool result = linker.linkCustomMap(bsp.get());
if (result) if (result)
{ {
auto gfxWorldAsset = context.LoadDependency<AssetGfxWorld>(BSP->bspName); auto gfxWorldAsset = context.LoadDependency<AssetGfxWorld>(bsp->bspName);
_ASSERT(gfxWorldAsset != nullptr); _ASSERT(gfxWorldAsset != nullptr);
return AssetCreationResult::Success(gfxWorldAsset); return AssetCreationResult::Success(gfxWorldAsset);
} }