2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-06-06 16:52:35 +00:00

Extended BSP creation to support X, Y and Z splitting and simplified clipmap BSP generation.

This commit is contained in:
LJW-Dev
2025-11-04 17:13:55 +08:00
committed by Jan Laupetin
parent 23fc37b1c6
commit 726809c2cb
2 changed files with 25 additions and 36 deletions
+11 -2
View File
@@ -86,8 +86,6 @@ namespace BSP
splitTree();
}
// For simplicity, only split across the X and Z axis.
// It is unlikely that there are many layers to a map, and is instead mostly flat
void BSPTree::splitTree()
{
std::unique_ptr<BSPTree> front;
@@ -105,6 +103,17 @@ namespace BSP
node = std::make_unique<BSPNode>(std::move(front), std::move(back), AXIS_X, halfLength);
leaf = nullptr;
}
else if (max.y - min.y > MAX_NODE_SIZE)
{
// split along the x axis
halfLength = (min.y + max.y) * 0.5f;
front = std::make_unique<BSPTree>(min.x, halfLength, min.z, max.x, max.y, max.z, level + 1);
back = std::make_unique<BSPTree>(min.x, min.y, min.z, max.x, halfLength, max.z, level + 1);
isLeaf = false;
node = std::make_unique<BSPNode>(std::move(front), std::move(back), AXIS_Y, halfLength);
leaf = nullptr;
}
else if (max.z - min.z > MAX_NODE_SIZE)
{
// split along the z axis