-
Notifications
You must be signed in to change notification settings - Fork 0
/
AABB.h
57 lines (40 loc) · 1.05 KB
/
AABB.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef LTBL_AABB_H
#define LTBL_AABB_H
#include "Vec2f.h"
class AABB
{
private:
Vec2f m_center;
Vec2f m_halfDims;
public:
Vec2f m_lowerBound;
Vec2f m_upperBound;
void CalculateHalfDims();
void CalculateCenter();
void CalculateBounds();
// Constructor
AABB();
AABB(const Vec2f &lowerBound, const Vec2f &upperBound);
// Accessors
const Vec2f &GetCenter() const;
Vec2f GetDims() const;
const Vec2f &GetHalfDims() const;
const Vec2f &GetLowerBound() const;
const Vec2f &GetUpperBound() const;
AABB GetRotatedAABB(float angleRads) const;
// Modifiers
void SetLowerBound(const Vec2f &newLowerBound);
void SetUpperBound(const Vec2f &newUpperBound);
void SetCenter(const Vec2f &newCenter);
void IncCenter(const Vec2f &increment);
void SetDims(const Vec2f &newDims);
void SetHalfDims(const Vec2f &newDims);
void SetRotatedAABB(float angleRads);
// Utility
bool Intersects(const AABB &other) const;
bool Contains(const AABB &other) const;
// Render the AABB for debugging purposes
void DebugRender();
// friend class AABB;
};
#endif