Extend AABB class

This commit is contained in:
Georg Hagen
2024-07-13 14:22:41 +02:00
parent 33bf5cd6e3
commit 0b8d889c86
2 changed files with 17 additions and 1 deletions

View File

@@ -35,6 +35,12 @@ namespace OpenVulkano::Math
this->min = min;
this->max = max;
}
void Init(const Math::Vector3f& point, float radius)
{
min = point - radius;
max = point + radius;
}
/**
* \brief Initiates the AABB from some other AABB
@@ -83,6 +89,16 @@ namespace OpenVulkano::Math
return !(other.min.x > max.x || other.max.x < min.x || other.min.y > max.y ||
other.max.y < min.y || other.min.z > max.z || other.max.z < min.z);
}
[[nodiscard]] bool InBounds(const Math::Vector3f& position) const
{
return min >= position && position <= max;
}
[[nodiscard]] bool Inside(const Math::Vector3f& position) const
{
return min > position && position < max;
}
/**
* \brief Resets the AABB to min=Inf, max=-Inf, same as Init()