TurtleBrains  0.2.1
High quality, portable, C++ API for native application and game development.
tbu_bounding_volume.h
1 
9 #ifndef _TurtleBrainsUnstable_BoundingVolume_h_
10 #define _TurtleBrainsUnstable_BoundingVolume_h_
11 
12 #include "../../math/tb_vector.h" //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 
78  bool CheckCollisionWith(const tbMath::Vector2& objectPosition, const BoundingVolume& testVolume, const tbMath::Vector2& testVolumePosition) const;
79 
93  bool ResolveCollisionWithStatic(tbMath::Vector2& objectPosition, const BoundingVolume& staticVolume, const tbMath::Vector2& staticVolumePosition) const;
94 
99  float GetRadius(void) const { tb_error_if(false == IsCircle(), "tbExternalError: This bounding volume is not a circle."); return mWidth; }
100 
105  float GetWidth(void) const { tb_error_if(false == IsBox(), "tbExternalError: This bounding volume is not a box."); return mWidth; }
106 
111  float GetHeight(void) const { tb_error_if(false == IsBox(), "tbExternalError: This bounding volume is not a box."); return mHeight; }
112 
113  private:
114  float mWidth;
115  float mHeight;
116  };
117 
118  }; /* namespace Unstable */
119  }; /* namespace Math */
120 }; /* namespace TurtleBrains */
121 
122 namespace tbMath = TurtleBrains::Math;
123 
124 #endif /* _TurtleBrainsUnstable_BoundingVolume_h_ */
Definition: tb_vector.h:47
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.h:99
float GetWidth(void) const
Definition: tbu_bounding_volume.h:105
Contains all functions, classes and helpers related to game/application development written by Tim "B...
Definition: tb_application_dialog.h:21
float GetHeight(void) const
Definition: tbu_bounding_volume.h:111
bool ResolveCollisionWithStatic(tbMath::Vector2 &objectPosition, const BoundingVolume &staticVolume, const tbMath::Vector2 &staticVolumePosition) const
Definition: tbu_bounding_volume.h:24
#define tb_error_if(errorTest, message,...)
Definition: tb_error.h:37