BsBounds.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /**
  10. * @brief Bounds represented by an axis aligned box and a sphere.
  11. */
  12. class BS_UTILITY_EXPORT Bounds
  13. {
  14. public:
  15. Bounds();
  16. Bounds(const AABox& box, const Sphere& sphere);
  17. ~Bounds() { }
  18. /**
  19. * @brief Returns the axis aligned box representing the bounds.
  20. */
  21. const AABox& getBox() const { return mBox; }
  22. /**
  23. * @brief Returns the sphere representing the bounds.
  24. */
  25. const Sphere& getSphere() const { return mSphere; }
  26. /**
  27. * @brief Updates the bounds by setting the new bounding box and sphere.
  28. */
  29. void setBounds(const AABox& box, const Sphere& sphere);
  30. /**
  31. * @brief Merges the two bounds, creating a new bounds that encapsulates
  32. * them both.
  33. */
  34. void merge(const Bounds& rhs);
  35. /**
  36. * @brief Expands the bounds so it includes the provided point.
  37. */
  38. void merge(const Vector3& point);
  39. /**
  40. * @brief Transforms the bounds by the given matrix.
  41. *
  42. * @note 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. void transform(const Matrix4& matrix);
  47. /**
  48. * @brief Transforms the bounds by the given matrix.
  49. *
  50. * @note As the resulting box will no longer be axis aligned, an axis align box
  51. * is instead created by encompassing the transformed oriented bounding box.
  52. * Retrieving the value as an actual OBB would provide a tighter fit.
  53. *
  54. * Provided matrix must be affine.
  55. */
  56. void transformAffine(const Matrix4& matrix);
  57. protected:
  58. AABox mBox;
  59. Sphere mSphere;
  60. };
  61. }