From 07619d5ec40a41d100cdf13d6a4ba7df8209c7fa Mon Sep 17 00:00:00 2001 From: LJW-Dev <48092720+LJW-Dev@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:41:40 +0800 Subject: [PATCH] Minor clipmap improvements --- src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp | 13 ++++++++++--- src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp index 56be1b95..7d162429 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp +++ b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.cpp @@ -402,7 +402,7 @@ namespace BSP } } - void ClipMapLinker::loadBSPTree(clipMap_t* clipMap, BSPData* bsp) + bool ClipMapLinker::loadBSPTree(clipMap_t* clipMap, BSPData* bsp) { vec3_t worldMins; vec3_t worldMaxs; @@ -418,7 +418,11 @@ namespace BSP BSPUtil::updateAABBWithPoint(vertex, worldMins, worldMaxs); } std::unique_ptr tree = std::make_unique(worldMins.x, worldMins.y, worldMins.z, worldMaxs.x, worldMaxs.y, worldMaxs.z, 0); - assert(!tree->isLeaf); + if (!tree->isLeaf) + { + con::error("Map size is too small for BSP generation!"); + return false; + } for (int partitionIdx = 0; partitionIdx < clipMap->partitionCount; partitionIdx++) { @@ -466,6 +470,8 @@ namespace BSP clipMap->nodes[nodeIdx].plane = &clipMap->info.planes[nodeIdx]; con::info("Highest leaf object count: {}", highestLeafObjectCount); + + return true; } bool ClipMapLinker::loadPartitions(clipMap_t* clipMap, BSPData* bsp) @@ -600,7 +606,8 @@ namespace BSP if (!loadPartitions(clipMap, bsp)) return false; - loadBSPTree(clipMap, bsp); + if (!loadBSPTree(clipMap, bsp)) + return false; return true; } diff --git a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.h b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.h index 4b6dcd6e..459eac42 100644 --- a/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.h +++ b/src/ObjLoading/Game/T6/BSP/Linker/ClipMapLinker.h @@ -33,7 +33,7 @@ namespace BSP size_t highestLeafObjectCount = 0; void addAABBTreeFromLeaf(clipMap_t* clipMap, BSPTree* tree, size_t* out_parentCount, size_t* out_parentStartIndex); int16_t loadBSPNode(clipMap_t* clipMap, BSPTree* tree); - void loadBSPTree(clipMap_t* clipMap, BSPData* bsp); + bool loadBSPTree(clipMap_t* clipMap, BSPData* bsp); bool loadPartitions(clipMap_t* clipMap, BSPData* bsp); bool loadWorldCollision(clipMap_t* clipMap, BSPData* bsp); };