Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
aabb.h
1 #pragma once
2 
3 #include <list>
4 #include <glm/glm.hpp>
5 
6 #include "axis.h"
7 #include "abstractshape.h"
8 
9 class Ray;
10 class Line;
11 class Sphere;
12 class Transform;
13 
14 template<typename T>
15 class TAABB: public AbstractShape {
16 public:
17  TAABB();
18  TAABB(const glm::detail::tvec3<T> &llf, const glm::detail::tvec3<T> &urb);
19  template<typename OtherT> TAABB(const TAABB<OtherT>& other);
20 
21  inline const glm::detail::tvec3<T> &llf() const;
22  inline void setLLF(const glm::detail::tvec3<T> &llf);
23 
24  inline const glm::detail::tvec3<T> &urb() const;
25  inline void setURB(const glm::detail::tvec3<T> &urb);
26 
27  T axisMin(Axis axis) const;
28  T axisMax(Axis axis) const;
29 
30  glm::detail::tvec3<T> middle() const;
31 
32  virtual T extent(Axis axis) const;
33  T diameter() const;
34 
35  TAABB<T> moved(Axis axis, T delta) const;
36  TAABB<T> moved(const glm::detail::tvec3<T> &delta) const;
37 
38  void move(Axis axis, T delta);
39  void move(const glm::detail::tvec3<T> &delta);
40 
41  void expand(Axis axis, T delta);
42  TAABB<T> expanded(Axis axis, T delta) const;
43 
44  template<typename OtherT> bool intersects(const TAABB<OtherT> &other) const;
45 
46  bool contains(const TAABB<T> &other) const;
47  template<typename OtherT> bool contains(const glm::detail::tvec3<OtherT> &vec) const;
48 
49  virtual bool intersects(const Sphere& sphere) const override;
50  virtual bool nearTo(const TAABB<int>& other) const override;
51  virtual bool containedBy(const TAABB<int>& other) const override;
52 
53  TAABB<T> united(const TAABB<T> &other) const;
54  void unite(const TAABB<T> &other);
55 
56  std::list<TAABB<T>> split(Axis axis) const;
57  void split(TAABB<T> &a, TAABB<T> &b, Axis axis) const;
58  std::list<TAABB<T>> recursiveSplit(int recursions, Axis axis) const;
59 
60  bool operator==(const TAABB<T> &other) const;
61 
62  void extend(const glm::detail::tvec3<T> & point);
63 
64  static TAABB<float> containing(const Sphere &sphere);
65 
66 
67 protected:
68  glm::detail::tvec3<T> m_llf, m_urb;
69 };
70 
72 typedef TAABB<int> IAABB;
74 
75 
76 #include "aabb.inl"
Definition: transform.h:9
Definition: line.h:12
Definition: aabb.h:15
Definition: sphere.h:11
Definition: ray.h:12
Definition: abstractshape.h:7