MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / BoundingBox

Class BoundingBox

include/BoundingBox.hpp:11–78  ·  view source on GitHub ↗

* Bounding box type */

Source from the content-addressed store, hash-verified

9 * Bounding box type
10 */
11class BoundingBox : public ::BoundingBox {
12public:
13 /*
14 * Copy a bounding box from another bounding box.
15 */
16 constexpr BoundingBox(const ::BoundingBox& box) : ::BoundingBox{box.min, box.max} {
17 // Nothing.
18 }
19
20 /**
21 * Compute mesh bounding box limits
22 */
23 BoundingBox(const ::Mesh& mesh) { set(::GetMeshBoundingBox(mesh)); }
24
25 constexpr BoundingBox(::Vector3 minMax = ::Vector3{0.0f, 0.0f, 0.0f}) : ::BoundingBox{minMax, minMax} {}
26 constexpr BoundingBox(::Vector3 min, ::Vector3 max) : ::BoundingBox{min, max} {}
27
28 GETTERSETTER(::Vector3, Min, min)
29 GETTERSETTER(::Vector3, Max, max)
30
31 BoundingBox& operator=(const ::BoundingBox& box) {
32 set(box);
33 return *this;
34 }
35
36 [[nodiscard]] std::string ToString() const {
37 return TextFormat(
38 "BoundingBox(min=(%f, %f, %f), max=(%f, %f, %f))",
39 min.x, min.y, min.z, max.x, max.y, max.z
40 );
41 }
42
43 operator std::string() const { return ToString(); }
44
45 /**
46 * Draw a bounding box with wires
47 */
48 void Draw(::Color color = {255, 255, 255, 255}) const { ::DrawBoundingBox(*this, color); }
49
50 /**
51 * Detect collision between two boxes
52 */
53 RLCPP_NODISCARD bool CheckCollision(const ::BoundingBox& box2) const { return CheckCollisionBoxes(*this, box2); }
54
55 /**
56 * Detect collision between box and sphere
57 */
58 RLCPP_NODISCARD bool CheckCollision(::Vector3 center, float radius) const { return CheckCollisionBoxSphere(*this, center, radius); }
59
60 /**
61 * Detect collision between ray and bounding box
62 */
63 RLCPP_NODISCARD bool CheckCollision(const ::Ray& ray) const { return GetRayCollisionBox(ray, *this).hit; }
64
65 /**
66 * Get collision information between ray and bounding box
67 */
68 RayCollision GetCollision(const ::Ray& ray) const { return GetRayCollisionBox(ray, *this); }

Callers 2

MeshUnmanagedClass · 0.85
BoundingBoxMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected