Last change
on this file since 7839 was
7839,
checked in by patrick, 18 years ago
|
trunk: collision reaction main structure
|
File size:
1.7 KB
|
Rev | Line | |
---|
[7819] | 1 | /*! |
---|
| 2 | * @file cr_engine.h |
---|
| 3 | * @brief The collision reaction engine, defining generic collision reactions to collision events |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _CR_ENGINE_ |
---|
| 7 | #define _CR_ENGINE_ |
---|
| 8 | |
---|
| 9 | #include "base_object.h" |
---|
| 10 | |
---|
| 11 | // FORWARD DECLARATION |
---|
[7839] | 12 | class CollisionHandle; |
---|
| 13 | class Collision; |
---|
[7819] | 14 | |
---|
| 15 | //! A default singleton class. |
---|
[7839] | 16 | class CREngine : public BaseObject |
---|
| 17 | { |
---|
[7819] | 18 | |
---|
[7839] | 19 | typedef enum CRType { |
---|
| 20 | CR_CONSERVATION_OF_MOMENTUM = 0, |
---|
| 21 | |
---|
| 22 | CR_OBJECT_DAMAGE, |
---|
| 23 | CR_OBJECT_PICKUP, |
---|
| 24 | |
---|
| 25 | CR_VERTEX_TRAFO, |
---|
| 26 | |
---|
| 27 | CR_CALLBACK, |
---|
| 28 | |
---|
| 29 | CR_NUMBER |
---|
| 30 | }; |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | public: |
---|
[7819] | 34 | virtual ~CREngine(void); |
---|
| 35 | /** @returns a Pointer to the only object of this Class */ |
---|
| 36 | inline static CREngine* getInstance(void) { if (!singletonRef) singletonRef = new CREngine(); return singletonRef; }; |
---|
| 37 | |
---|
| 38 | |
---|
[7839] | 39 | CollisionHandle* subscribeReaction(WorldEntity* worldEntity, ClassId targets, CRType type); |
---|
[7819] | 40 | |
---|
[7839] | 41 | bool unsubscribeReaction(WorldEntity* worldEntity); |
---|
| 42 | bool unsubscribeReaction(CollisionHandle* collisionHandle); |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | /** @returns an instance to a collision object. instead of creating new object this ones can be resycled */ |
---|
| 46 | inline Collision* getCollisionObject() { /* return the first element of the cache list*/ } |
---|
| 47 | /** @param collision: returns the Collision object back to the cache list */ |
---|
| 48 | inline void putCollisionObject(Collision* collision) { this->cachedCollisions.push_back(collision); } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | private: |
---|
[7819] | 52 | CREngine(void); |
---|
[7839] | 53 | static CREngine* singletonRef; //!< the reference to the CREngine object (singleton) |
---|
| 54 | |
---|
| 55 | std::vector<CollisionHandle*> collisionHandles; //!< list with the collision handles |
---|
| 56 | std::vector<Collision*> cachedCollisions; //!< a list of unused, cached collision events |
---|
[7819] | 57 | }; |
---|
| 58 | |
---|
| 59 | #endif /* _CR_ENGINE_ */ |
---|
Note: See
TracBrowser
for help on using the repository browser.