2
0

OrientedBox.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Jolt/Geometry/Triangle.h>
  5. #include <Jolt/Geometry/IndexedTriangle.h>
  6. #include <Jolt/Geometry/AABox.h>
  7. #include <Jolt/Math/Mat44.h>
  8. JPH_NAMESPACE_BEGIN
  9. class AABox;
  10. /// Oriented box
  11. class [[nodiscard]] OrientedBox
  12. {
  13. public:
  14. JPH_OVERRIDE_NEW_DELETE
  15. /// Constructor
  16. OrientedBox() = default;
  17. OrientedBox(Mat44Arg inOrientation, Vec3Arg inHalfExtents) : mOrientation(inOrientation), mHalfExtents(inHalfExtents) { }
  18. /// Construct from axis aligned box and transform. Only works for rotation/translation matrix (no scaling / shearing).
  19. OrientedBox(Mat44Arg inOrientation, const AABox &inBox) : OrientedBox(inOrientation.PreTranslated(inBox.GetCenter()), inBox.GetExtent()) { }
  20. /// Test if oriented boxe overlaps with axis aligned box eachother
  21. bool Overlaps(const AABox &inBox, float inEpsilon = 1.0e-6f) const;
  22. /// Test if two oriented boxes overlap eachother
  23. bool Overlaps(const OrientedBox &inBox, float inEpsilon = 1.0e-6f) const;
  24. Mat44 mOrientation; ///< Transform that positions and rotates the local space axis aligned box into world space
  25. Vec3 mHalfExtents; ///< Half extents (half the size of the edge) of the local space axis aligned box
  26. };
  27. JPH_NAMESPACE_END