mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 05:12:05 +00:00
chore: use std min and std max in bsp utils
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "BSPUtil.h"
|
#include "BSPUtil.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <format>
|
#include <format>
|
||||||
|
|
||||||
@@ -32,44 +33,26 @@ namespace BSP
|
|||||||
|
|
||||||
void BSPUtil::updateAABB(vec3_t& newAABBMins, vec3_t& newAABBMaxs, vec3_t& AABBMins, vec3_t& AABBMaxs)
|
void BSPUtil::updateAABB(vec3_t& newAABBMins, vec3_t& newAABBMaxs, vec3_t& AABBMins, vec3_t& AABBMaxs)
|
||||||
{
|
{
|
||||||
if (AABBMins.x > newAABBMins.x)
|
AABBMins.x = std::min(AABBMins.x, newAABBMins.x);
|
||||||
AABBMins.x = newAABBMins.x;
|
AABBMaxs.x = std::max(AABBMaxs.x, newAABBMaxs.x);
|
||||||
|
|
||||||
if (newAABBMaxs.x > AABBMaxs.x)
|
AABBMins.y = std::min(AABBMins.y, newAABBMins.y);
|
||||||
AABBMaxs.x = newAABBMaxs.x;
|
AABBMaxs.y = std::max(AABBMaxs.y, newAABBMaxs.y);
|
||||||
|
|
||||||
if (AABBMins.y > newAABBMins.y)
|
AABBMins.z = std::min(AABBMins.z, newAABBMins.z);
|
||||||
AABBMins.y = newAABBMins.y;
|
AABBMaxs.z = std::max(AABBMaxs.z, newAABBMaxs.z);
|
||||||
|
|
||||||
if (newAABBMaxs.y > AABBMaxs.y)
|
|
||||||
AABBMaxs.y = newAABBMaxs.y;
|
|
||||||
|
|
||||||
if (AABBMins.z > newAABBMins.z)
|
|
||||||
AABBMins.z = newAABBMins.z;
|
|
||||||
|
|
||||||
if (newAABBMaxs.z > AABBMaxs.z)
|
|
||||||
AABBMaxs.z = newAABBMaxs.z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BSPUtil::updateAABBWithPoint(vec3_t& point, vec3_t& AABBMins, vec3_t& AABBMaxs)
|
void BSPUtil::updateAABBWithPoint(vec3_t& point, vec3_t& AABBMins, vec3_t& AABBMaxs)
|
||||||
{
|
{
|
||||||
if (AABBMins.x > point.x)
|
AABBMins.x = std::min(AABBMins.x, point.x);
|
||||||
AABBMins.x = point.x;
|
AABBMaxs.x = std::max(AABBMaxs.x, point.x);
|
||||||
|
|
||||||
if (point.x > AABBMaxs.x)
|
AABBMins.y = std::min(AABBMins.y, point.y);
|
||||||
AABBMaxs.x = point.x;
|
AABBMaxs.y = std::max(AABBMaxs.y, point.y);
|
||||||
|
|
||||||
if (AABBMins.y > point.y)
|
AABBMins.z = std::min(AABBMins.z, point.z);
|
||||||
AABBMins.y = point.y;
|
AABBMaxs.z = std::max(AABBMaxs.z, point.z);
|
||||||
|
|
||||||
if (point.y > AABBMaxs.y)
|
|
||||||
AABBMaxs.y = point.y;
|
|
||||||
|
|
||||||
if (AABBMins.z > point.z)
|
|
||||||
AABBMins.z = point.z;
|
|
||||||
|
|
||||||
if (point.z > AABBMaxs.z)
|
|
||||||
AABBMaxs.z = point.z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3_t BSPUtil::calcMiddleOfAABB(vec3_t& mins, vec3_t& maxs)
|
vec3_t BSPUtil::calcMiddleOfAABB(vec3_t& mins, vec3_t& maxs)
|
||||||
|
|||||||
@@ -217,8 +217,7 @@ namespace BSP
|
|||||||
|
|
||||||
size_t leafObjectCount = tree->leaf->getObjectCount();
|
size_t leafObjectCount = tree->leaf->getObjectCount();
|
||||||
assert(leafObjectCount > 0);
|
assert(leafObjectCount > 0);
|
||||||
if (leafObjectCount > highestLeafObjectCount)
|
highestLeafObjectCount = std::max(leafObjectCount, highestLeafObjectCount);
|
||||||
highestLeafObjectCount = leafObjectCount;
|
|
||||||
|
|
||||||
// BO2 has a maximum limit of 128 children per AABB tree (essentially),
|
// BO2 has a maximum limit of 128 children per AABB tree (essentially),
|
||||||
// so this is fixed by adding multiple parent AABB trees that hold 128 children each
|
// so this is fixed by adding multiple parent AABB trees that hold 128 children each
|
||||||
|
|||||||
Reference in New Issue
Block a user