TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tbu_bounding_volume.hpp
1 
9 #ifndef _TurtleBrainsUnstable_BoundingVolume_hpp
10 #define _TurtleBrainsUnstable_BoundingVolume_hpp
11 
12 #include <turtle_brains/math/tb_vector.hpp> //For Vector2
13 
14 namespace TurtleBrains
15 {
16  namespace Math
17  {
18  namespace Unstable
19  {
20 
25  {
26  public:
33  explicit BoundingVolume(float radius);
34 
43  explicit BoundingVolume(float width, float height);
44 
49  ~BoundingVolume(void);
50 
54  bool IsCircle(void) const;
55 
59  bool IsBox(void) const;
60 
68  bool CheckCollisionWith(const tbMath::Vector2& objectPosition, const tbMath::Vector2& testPoint) const;
69 
70 
71  //This is WAY unstable, added during LD40 as a point in oobb to point collision.
72  bool CheckCollisionWith(const tbMath::Vector2& objectPosition, const float objectRotation, const tbMath::Vector2& testPoint) const;
73 
82  bool CheckCollisionWith(const tbMath::Vector2& objectPosition, const BoundingVolume& testVolume, const tbMath::Vector2& testVolumePosition) const;
83 
97  bool ResolveCollisionWithStatic(tbMath::Vector2& objectPosition, const BoundingVolume& staticVolume, const tbMath::Vector2& staticVolumePosition) const;
98 
103  float GetRadius(void) const { tb_error_if(false == IsCircle(), "tbExternalError: This bounding volume is not a circle."); return mWidth; }
104 
109  float GetWidth(void) const { tb_error_if(false == IsBox(), "tbExternalError: This bounding volume is not a box."); return mWidth; }
110 
115  float GetHeight(void) const { tb_error_if(false == IsBox(), "tbExternalError: This bounding volume is not a box."); return mHeight; }
116 
117  private:
118  float mWidth;
119  float mHeight;
120  };
121 
122  }; /* namespace Unstable */
123  }; /* namespace Math */
124 }; /* namespace TurtleBrains */
125 
126 namespace tbMath = TurtleBrains::Math;
127 
128 #endif /* _TurtleBrainsUnstable_BoundingVolume_hpp */
Definition: tb_vector.hpp:48
bool CheckCollisionWith(const tbMath::Vector2 &objectPosition, const tbMath::Vector2 &testPoint) const
Contains objects and functions for dealing with Vector and Matrix math.
float GetRadius(void) const
Definition: tbu_bounding_volume.hpp:103
float GetWidth(void) const
Definition: tbu_bounding_volume.hpp:109
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
float GetHeight(void) const
Definition: tbu_bounding_volume.hpp:115
bool ResolveCollisionWithStatic(tbMath::Vector2 &objectPosition, const BoundingVolume &staticVolume, const tbMath::Vector2 &staticVolumePosition) const
Definition: tbu_bounding_volume.hpp:24
#define tb_error_if(errorTest, message,...)
Definition: tb_error.hpp:42