Math/BoundingVolume: Add ExtendTo method

Former-commit-id: 5cfd681d5cd7adcc2bcf16184a2da821bf4eb477
This commit is contained in:
Lynix
2016-03-25 23:07:59 +01:00
parent d2e3bb36a6
commit b28ab414c9
2 changed files with 48 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ namespace Nz
BoundingVolume(const BoundingVolume& volume) = default; BoundingVolume(const BoundingVolume& volume) = default;
~BoundingVolume() = default; ~BoundingVolume() = default;
BoundingVolume& ExtendTo(const BoundingVolume& volume);
bool IsFinite() const; bool IsFinite() const;
bool IsInfinite() const; bool IsInfinite() const;
bool IsNull() const; bool IsNull() const;

View File

@@ -124,6 +124,52 @@ namespace Nz
Set(volume); Set(volume);
} }
/*!
* \brief Extends the bounding volume to contain another bounding volume
* \return A reference to the the bounding volume
*
* \param volume Other volume to contain
*
* \remark Extending to a null bounding volume has no effect while extending to a infinite bounding volume will set it as infinite
*/
template<typename T>
BoundingVolume<T>& BoundingVolume<T>::BoundingVolume<T>::ExtendTo(const BoundingVolume& volume)
{
switch (extend)
{
case Extend_Finite:
{
switch (volume.extend)
{
case Extend_Finite:
{
// Extend the OBB local box
obb.localBox.ExtendTo(volume.localBox);
break;
}
case Extend_Infinite:
MakeInfinite();
break;
case Extend_Null:
break;
}
break;
}
case Extend_Infinite:
break; //< We already contain the bounding volume
case Extend_Null:
Set(volume);
break;
}
return *this;
}
/*! /*!
* \brief Checks whether the volume is finite * \brief Checks whether the volume is finite
* \return true if extend is Extend_Finite * \return true if extend is Extend_Finite