Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/collision_reaction/cr_engine.h @ 7889

Last change on this file since 7889 was 7865, checked in by patrick, 19 years ago

trunk: removed compiler error

File size: 1.8 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#include <stdarg.h>
11#include <vector>
12
13// FORWARD DECLARATION
14class CollisionHandle;
15class Collision;
16class WorldEntity;
17
18//! A default singleton class.
19class CREngine : public BaseObject
20{
21
22  typedef enum CRType {
23    CR_CONSERVATION_OF_MOMENTUM   = 0,
24
25    CR_OBJECT_DAMAGE,
26    CR_OBJECT_PICKUP,
27
28    CR_VERTEX_TRAFO,
29
30    CR_CALLBACK,
31
32    CR_NUMBER
33  };
34
35
36public:
37  virtual ~CREngine(void);
38  /** @returns a Pointer to the only object of this Class */
39  inline static CREngine* getInstance(void) { if (!singletonRef) singletonRef = new CREngine();  return singletonRef; };
40
41
42  CollisionHandle* subscribeReaction(WorldEntity* worldEntity, CRType type, int nrOfTargets, ...);
43
44  bool unsubscribeReaction(WorldEntity* worldEntity);
45  bool unsubscribeReaction(CollisionHandle* collisionHandle);
46
47
48  void handleCollisions();
49
50  /** @returns an instance to a collision object. instead of creating new object this ones can be resycled */
51inline Collision* getCollisionObject() { /* return the first element of the cache list*/ }
52  /** @param collision: returns the Collision object back to the cache list */
53  inline void putCollisionObject(Collision* collision) { this->cachedCollisions.push_back(collision); }
54
55
56private:
57  CREngine(void);
58
59private:
60  std::vector<CollisionHandle*>       collisionHandles;         //!< list with the collision handles
61  std::vector<Collision*>             cachedCollisions;         //!< a list of unused, cached collision events
62  std::vector<int>                    targetList;
63
64  static CREngine*                    singletonRef;             //!< the reference to the CREngine object (singleton)
65};
66
67#endif /* _CR_ENGINE_ */
Note: See TracBrowser for help on using the repository browser.