Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_reaction/cr_engine.h @ 7839

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
Line 
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
12class CollisionHandle;
13class Collision;
14
15//! A default singleton class.
16class CREngine : public BaseObject
17{
18
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
33public:
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
39  CollisionHandle* subscribeReaction(WorldEntity* worldEntity, ClassId targets, CRType type);
40
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
51private:
52  CREngine(void);
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
57};
58
59#endif /* _CR_ENGINE_ */
Note: See TracBrowser for help on using the repository browser.