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