BsBounds.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include "BsPrerequisitesUtil.h"
  3. #include "BsVector3.h"
  4. #include "BsAABox.h"
  5. #include "BsSphere.h"
  6. #include "BsMatrix4.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Math
  10. * @{
  11. */
  12. /** Bounds represented by an axis aligned box and a sphere. */
  13. class BS_UTILITY_EXPORT Bounds
  14. {
  15. public:
  16. Bounds();
  17. Bounds(const AABox& box, const Sphere& sphere);
  18. ~Bounds() { }
  19. /** Returns the axis aligned box representing the bounds. */
  20. const AABox& getBox() const { return mBox; }
  21. /** Returns the sphere representing the bounds. */
  22. const Sphere& getSphere() const { return mSphere; }
  23. /** Updates the bounds by setting the new bounding box and sphere. */
  24. void setBounds(const AABox& box, const Sphere& sphere);
  25. /** Merges the two bounds, creating a new bounds that encapsulates them both. */
  26. void merge(const Bounds& rhs);
  27. /** Expands the bounds so it includes the provided point. */
  28. void merge(const Vector3& point);
  29. /**
  30. * Transforms the bounds by the given matrix.
  31. *
  32. * @note
  33. * As the resulting box will no longer be axis aligned, an axis align box
  34. * is instead created by encompassing the transformed oriented bounding box.
  35. * Retrieving the value as an actual OBB would provide a tighter fit.
  36. */
  37. void transform(const Matrix4& matrix);
  38. /**
  39. * Transforms the bounds by the given matrix.
  40. *
  41. * @note
  42. * As the resulting box will no longer be axis aligned, an axis align box
  43. * is instead created by encompassing the transformed oriented bounding box.
  44. * Retrieving the value as an actual OBB would provide a tighter fit.
  45. *
  46. * @note
  47. * Provided matrix must be affine.
  48. */
  49. void transformAffine(const Matrix4& matrix);
  50. protected:
  51. AABox mBox;
  52. Sphere mSphere;
  53. };
  54. /** @} */
  55. }