1 | /*! |
---|
2 | \file cd_engine.h |
---|
3 | \brief Definition of the collision detection engine |
---|
4 | |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef _CD_ENGINE_H |
---|
8 | #define _CD_ENGINE_H |
---|
9 | |
---|
10 | #include "base_object.h" |
---|
11 | #include "collision_defs.h" |
---|
12 | |
---|
13 | template<class T> class tList; |
---|
14 | class WorldEntity; |
---|
15 | class OBBTree; |
---|
16 | |
---|
17 | |
---|
18 | //! featured state options, they are all additive |
---|
19 | typedef enum cdState |
---|
20 | { |
---|
21 | CD_DEBUG_DRAW_ALL = 1, |
---|
22 | CD_DEBUG_DRAW_POLYGONS = 1<<1, |
---|
23 | CD_DEBUG_DRAW_BLENDED = 1<<2, |
---|
24 | CD_DEBUG_DRAW_HIT_BV = 1<<3, |
---|
25 | CD_DEBUG_VERBOSE = 1<<4, |
---|
26 | |
---|
27 | CD_STORE_VERTICES = 1<<5 |
---|
28 | }; |
---|
29 | |
---|
30 | |
---|
31 | //! The class representing the collision detection system of orxonox |
---|
32 | class CDEngine : public BaseObject { |
---|
33 | |
---|
34 | public: |
---|
35 | virtual ~CDEngine(void); |
---|
36 | /** \returns a Pointer to the only object of this Class */ |
---|
37 | static CDEngine* getInstance(void) { if (!singletonRef) singletonRef = new CDEngine(); return singletonRef; } |
---|
38 | void init(); |
---|
39 | |
---|
40 | void setState(const int newState) { this->state = newState; } |
---|
41 | const int getState() const { return this->state; } |
---|
42 | void enable(const int options) { this->state |= options; } |
---|
43 | void disable(const int options) { int temp = this->state & options; this->state ^= temp; } |
---|
44 | |
---|
45 | void drawBV(int currentDepth, const int depth) const; |
---|
46 | void drawBVPolygon(int currentDepth, const int depth) const; |
---|
47 | void drawBVBlended(int currentDepth, const int depth) const; |
---|
48 | |
---|
49 | void checkCollisions(); |
---|
50 | |
---|
51 | void debug(); |
---|
52 | |
---|
53 | private: |
---|
54 | CDEngine(void); |
---|
55 | static CDEngine* singletonRef; |
---|
56 | |
---|
57 | void spawnBVTree(int depth = MAX_BV_TREE_DEPTH); |
---|
58 | |
---|
59 | void checkCollisionObjects(); |
---|
60 | void checkCollisionGround(); |
---|
61 | |
---|
62 | |
---|
63 | private: |
---|
64 | int state; //!< the current state of the cd engine |
---|
65 | tList<WorldEntity>* entityList; //!< pointer to the world entity list |
---|
66 | OBBTree* rootTree; //!< for testing purposes a root tree |
---|
67 | }; |
---|
68 | |
---|
69 | #endif /* _CD_ENGINE_H */ |
---|