1 | /*! |
---|
2 | * @file cd_engine.h |
---|
3 | * 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 | #include "model.h" |
---|
13 | |
---|
14 | #include <list> |
---|
15 | |
---|
16 | class WorldEntity; |
---|
17 | class OBBTree; |
---|
18 | class Terrain; |
---|
19 | //class Player; |
---|
20 | |
---|
21 | |
---|
22 | //! featured state options, they are all additive |
---|
23 | typedef enum cdState |
---|
24 | { |
---|
25 | CD_DEBUG_DRAW_ALL = 1, |
---|
26 | CD_DEBUG_DRAW_POLYGONS = 1<<1, |
---|
27 | CD_DEBUG_DRAW_BLENDED = 1<<2, |
---|
28 | CD_DEBUG_DRAW_HIT_BV = 1<<3, |
---|
29 | CD_DEBUG_VERBOSE = 1<<4, |
---|
30 | |
---|
31 | CD_STORE_VERTICES = 1<<5 |
---|
32 | }; |
---|
33 | |
---|
34 | |
---|
35 | //! The class representing the collision detection system of orxonox |
---|
36 | class CDEngine : public BaseObject { |
---|
37 | |
---|
38 | friend class WorldEntity; |
---|
39 | |
---|
40 | public: |
---|
41 | virtual ~CDEngine(); |
---|
42 | /** @returns a Pointer to the only object of this Class */ |
---|
43 | static CDEngine* getInstance() { if (!singletonRef) singletonRef = new CDEngine(); return singletonRef; } |
---|
44 | void init(); |
---|
45 | |
---|
46 | inline void setState(const int newState) { this->state = newState; } |
---|
47 | inline const int getState() const { return this->state; } |
---|
48 | inline void enable(const int options) { this->state |= options; } |
---|
49 | inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; } |
---|
50 | |
---|
51 | inline void setTerrain(Terrain* terrain) { this->terrain = terrain; } |
---|
52 | |
---|
53 | void checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2); |
---|
54 | |
---|
55 | void drawBV(const std::list<WorldEntity*>& drawList ) const; |
---|
56 | void debug(); |
---|
57 | |
---|
58 | |
---|
59 | private: |
---|
60 | CDEngine(); |
---|
61 | static CDEngine* singletonRef; |
---|
62 | |
---|
63 | void spawnBVTree(int depth = MAX_BV_TREE_DEPTH); |
---|
64 | |
---|
65 | void checkCollisionObjects(); |
---|
66 | void checkCollisionGround(); |
---|
67 | |
---|
68 | void debugSpawnTree(int depth, sVec3D* vertices, int numVertices); |
---|
69 | void debugDraw(int depth, int drawMode); |
---|
70 | |
---|
71 | |
---|
72 | private: |
---|
73 | int state; //!< the current state of the cd engine |
---|
74 | OBBTree* rootTree; //!< for testing purposes a root tree |
---|
75 | |
---|
76 | Terrain* terrain; //!< this it a ref to the terrain, serving as a ground for all WE |
---|
77 | // Player* player; |
---|
78 | }; |
---|
79 | |
---|
80 | #endif /* _CD_ENGINE_H */ |
---|