Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
BoundingSphere.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_CORE_MATH_BOUNDINGVOLUMES_BOUNDINGSPHERE_H_
34#define DVD_CORE_MATH_BOUNDINGVOLUMES_BOUNDINGSPHERE_H_
35
36#include "BoundingBox.h"
37
38namespace Divide {
39namespace Attorney {
40 class BoundingSphereEditor;
41}
42
43class OBB;
44class PropertyWindow;
47
48 public:
49 BoundingSphere() noexcept;
50 explicit BoundingSphere(vec3<F32> center, F32 radius) noexcept;
51 explicit BoundingSphere(const vector<vec3<F32>>& points) noexcept;
52 explicit BoundingSphere(const std::array<vec3<F32>, 8>& points) noexcept;
53
54 void fromBoundingBox(const BoundingBox& bBox) noexcept;
55 void fromOBB(const OBB& box) noexcept;
56 void fromBoundingSphere(const BoundingSphere& bSphere) noexcept;
57 [[nodiscard]] bool containsPoint(const vec3<F32>& point) const noexcept;
58 [[nodiscard]] bool containsBoundingBox(const BoundingBox& AABB) const noexcept;
59
60 // https://code.google.com/p/qe3e/source/browse/trunk/src/BoundingSphere.h?r=28
61 void add(const BoundingSphere& bSphere) noexcept;
62 void add(const vec3<F32>& point) noexcept;
63 void addRadius(const BoundingSphere& bSphere) noexcept;
64 void addRadius(const vec3<F32>& point) noexcept;
65
66 void createFromPoints(const vector<vec3<F32>>& points) noexcept;
67 void createFromPoints(const std::array<vec3<F32>, 8>& points) noexcept;
68
69 void setRadius(F32 radius) noexcept;
70 void setCenter(const vec3<F32>& center) noexcept;
71
72 [[nodiscard]] const vec3<F32>& getCenter() const noexcept;
73 [[nodiscard]] F32 getRadius() const noexcept;
74 [[nodiscard]] F32 getDiameter() const noexcept;
75
76 [[nodiscard]] F32 getDistanceFromPoint(const vec3<F32>& point) const noexcept;
77 [[nodiscard]] F32 getDistanceSQFromPoint(const vec3<F32>& point) const noexcept;
78
79 void reset() noexcept;
80 [[nodiscard]] vec4<F32> asVec4() const noexcept;
81
82 [[nodiscard]] bool collision(const BoundingSphere& sphere2) const noexcept;
83
84 [[nodiscard]] RayResult intersect(const Ray& r, F32 tMin, F32 tMax) const noexcept;
85
86
87 private:
90};
91
92namespace Attorney {
94 static F32* center(BoundingSphere& bs) noexcept {
95 return bs._center._v;
96 }
97 static F32& radius(BoundingSphere& bs) noexcept {
98 return bs._radius;
99 }
101 };
102} //namespace Attorney
103
104} // namespace Divide
105
106#endif //_CORE_MATH_BOUNDINGVOLUMES_BOUNDINGSPHERE_H_
107
108#include "BoundingSphere.inl"
static F32 & radius(BoundingSphere &bs) noexcept
static F32 * center(BoundingSphere &bs) noexcept
void fromBoundingBox(const BoundingBox &bBox) noexcept
bool containsPoint(const vec3< F32 > &point) const noexcept
RayResult intersect(const Ray &r, F32 tMin, F32 tMax) const noexcept
void addRadius(const BoundingSphere &bSphere) noexcept
void createFromPoints(const vector< vec3< F32 > > &points) noexcept
const vec3< F32 > & getCenter() const noexcept
F32 getDistanceFromPoint(const vec3< F32 > &point) const noexcept
void fromBoundingSphere(const BoundingSphere &bSphere) noexcept
void setRadius(F32 radius) noexcept
F32 getRadius() const noexcept
vec4< F32 > asVec4() const noexcept
bool collision(const BoundingSphere &sphere2) const noexcept
void add(const BoundingSphere &bSphere) noexcept
void fromOBB(const OBB &box) noexcept
F32 getDiameter() const noexcept
void setCenter(const vec3< F32 > &center) noexcept
bool containsBoundingBox(const BoundingBox &AABB) const noexcept
F32 getDistanceSQFromPoint(const vec3< F32 > &point) const noexcept
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
eastl::vector< Type > vector
Definition: Vector.h:42