OrientedBox.h 1.4 KB

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