Pyrogenesis  trunk
BoundingSphere.h
Go to the documentation of this file.
1 /* Copyright (C) 2019 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_BOUNDINGSPHERE
19 #define INCLUDED_BOUNDINGSPHERE
20 
21 #include "maths/Vector3D.h"
22 
24 
26 {
27 public:
28  CBoundingSphere() : m_Radius(0.0f) { }
29 
30  CBoundingSphere(const CVector3D& center, float radius) : m_Center(center), m_Radius(radius) { }
31 
32  const CVector3D& GetCenter() const
33  {
34  return m_Center;
35  }
36 
37  float GetRadius() const
38  {
39  return m_Radius;
40  }
41 
42  /**
43  * Construct a bounding sphere that encompasses a bounding box
44  * swept through all possible rotations around the origin.
45  */
47 
48  /**
49  * Check if the ray, defined by an origin point and a direction unit vector
50  * interesects with the sphere. The direction should be normalized.
51  */
52  bool RayIntersect(const CVector3D& origin, const CVector3D& dir) const;
53 
54 private:
56  float m_Radius;
57 };
58 
59 #endif // INCLUDED_BOUNDINGSPHERE
const CVector3D & GetCenter() const
Definition: BoundingSphere.h:32
static CBoundingSphere FromSweptBox(const CBoundingBoxAligned &bbox)
Construct a bounding sphere that encompasses a bounding box swept through all possible rotations arou...
Definition: BoundingSphere.cpp:23
Definition: Vector3D.h:30
CBoundingSphere()
Definition: BoundingSphere.h:28
bool RayIntersect(const CVector3D &origin, const CVector3D &dir) const
Check if the ray, defined by an origin point and a direction unit vector interesects with the sphere...
Definition: BoundingSphere.cpp:34
float GetRadius() const
Definition: BoundingSphere.h:37
CBoundingSphere(const CVector3D &center, float radius)
Definition: BoundingSphere.h:30
Definition: BoundingSphere.h:25
Definition: BoundingBoxAligned.h:33
CVector3D m_Center
Definition: BoundingSphere.h:55
float m_Radius
Definition: BoundingSphere.h:56