Ocular Engine
BoundsSphere.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_MATH_BOUNDS_SPHERE__H__
19 #define __H__OCULAR_MATH_BOUNDS_SPHERE__H__
20 
21 #include "Math/Bounds/Bounds.hpp"
22 #include "Graphics/Mesh/Vertex.hpp"
23 
24 #include "Math/Matrix4x4.hpp"
25 #include "Math/Vector4.hpp"
26 
27 #include <list>
28 #include <vector>
29 
30 //------------------------------------------------------------------------------------------
31 
36 namespace Ocular
37 {
42  namespace Math
43  {
44  class Ray;
45  class BoundsAABB;
46  class BoundsOBB;
47  class Plane;
48 
52  class BoundsSphere : public Bounds
53  {
54  public:
55 
56  BoundsSphere(std::list<Point3f> const& points, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
57  BoundsSphere(std::vector<Graphics::Vertex> const& vertices, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
58  BoundsSphere(Vector3f const& center, float radius);
59  BoundsSphere();
60  ~BoundsSphere();
61 
66  void construct(std::list<Vector3f> const& points, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
67 
71  void construct(std::vector<Graphics::Vertex> const& vertices, Math::Matrix4x4 const& matrix = Math::Matrix4x4());
72 
77  void setCenter(Vector3f const& center);
78 
83  void setRadius(float radius);
84 
88  Vector3f const& getCenter() const;
89 
93  float getRadius() const;
94 
99  void expand(float const amount);
100 
107  void expandToContain(Vector3f const& point);
108 
115  void expandToContain(BoundsSphere const& other);
116 
117  //------------------------------------------------------------------------------
118  // Intersection and Containment Testing
119  //------------------------------------------------------------------------------
120 
127  bool intersects(Ray const& ray) const;
128 
142  bool intersects(Ray const& ray, Vector3f& point, float& distance) const;
143 
150  bool intersects(BoundsSphere const& bounds) const;
151 
158  bool intersects(BoundsAABB const& bounds) const;
159 
166  bool intersects(BoundsOBB const& bounds) const;
167 
191  bool intersects(Plane const& plane, IntersectionType* result = nullptr) const;
192 
201  bool contains(Vector3f const& point, IntersectionType* result = nullptr) const;
202 
211  bool contains(BoundsSphere const& sphere, IntersectionType* result = nullptr) const;
212 
213  protected:
214 
215  private:
216 
217  Vector3f m_Center;
218  float m_Radius;
219 
220  };
221  }
225 }
230 //------------------------------------------------------------------------------------------
231 
232 #endif
void setRadius(float radius)
Definition: BoundsSphere.cpp:380
Definition: Ray.hpp:47
void expandToContain(Vector3f const &point)
Definition: BoundsSphere.cpp:400
bool intersects(Ray const &ray) const
Definition: BoundsSphere.cpp:449
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: BoundsOBB.hpp:56
void expand(float const amount)
Definition: BoundsSphere.cpp:395
void construct(std::list< Vector3f > const &points, Math::Matrix4x4 const &matrix=Math::Matrix4x4())
Definition: BoundsSphere.cpp:67
Definition: Plane.hpp:50
float getRadius() const
Definition: BoundsSphere.cpp:390
A 4x4 column-major float matrix.
Definition: Matrix4x4.hpp:64
Definition: Bounds.hpp:45
Definition: BoundsAABB.hpp:63
bool contains(Vector3f const &point, IntersectionType *result=nullptr) const
Definition: BoundsSphere.cpp:553
Definition: BoundsSphere.hpp:52
Vector3f const & getCenter() const
Definition: BoundsSphere.cpp:385
void setCenter(Vector3f const &center)
Definition: BoundsSphere.cpp:375