Math/BoundingVolume: Add ExtendTo method
Former-commit-id: 5cfd681d5cd7adcc2bcf16184a2da821bf4eb477
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user