Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/jolt_physics/Jolt/Geometry/OrientedBox.h
9913 views
1
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3
// SPDX-License-Identifier: MIT
4
5
#pragma once
6
7
#include <Jolt/Geometry/Triangle.h>
8
#include <Jolt/Geometry/IndexedTriangle.h>
9
#include <Jolt/Geometry/AABox.h>
10
#include <Jolt/Math/Mat44.h>
11
12
JPH_NAMESPACE_BEGIN
13
14
class AABox;
15
16
/// Oriented box
17
class JPH_EXPORT_GCC_BUG_WORKAROUND [[nodiscard]] OrientedBox
18
{
19
public:
20
JPH_OVERRIDE_NEW_DELETE
21
22
/// Constructor
23
OrientedBox() = default;
24
OrientedBox(Mat44Arg inOrientation, Vec3Arg inHalfExtents) : mOrientation(inOrientation), mHalfExtents(inHalfExtents) { }
25
26
/// Construct from axis aligned box and transform. Only works for rotation/translation matrix (no scaling / shearing).
27
OrientedBox(Mat44Arg inOrientation, const AABox &inBox) : OrientedBox(inOrientation.PreTranslated(inBox.GetCenter()), inBox.GetExtent()) { }
28
29
/// Test if oriented box overlaps with axis aligned box each other
30
bool Overlaps(const AABox &inBox, float inEpsilon = 1.0e-6f) const;
31
32
/// Test if two oriented boxes overlap each other
33
bool Overlaps(const OrientedBox &inBox, float inEpsilon = 1.0e-6f) const;
34
35
Mat44 mOrientation; ///< Transform that positions and rotates the local space axis aligned box into world space
36
Vec3 mHalfExtents; ///< Half extents (half the size of the edge) of the local space axis aligned box
37
};
38
39
JPH_NAMESPACE_END
40
41