Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/coll_rect/src/lib/collision_reaction/cr_engine.h @ 9986

Last change on this file since 9986 was 9986, checked in by patrick, 17 years ago

fixed a compile bug… more to come but not today:)

File size: 3.9 KB
Line 
1/*!
2 * @file cr_engine.h
3 * @brief The collision reaction engine, defining generic collision reactions to collision events
4 *
5 * some parts of this module are tuned for efficiency. They are probably not self-explenatory anymore :D
6 *  - Collision/ CollisionEvent objects recycling: This class contains a class of precached objects of these types
7 *      they are used for fast registration of collision events: These objects can be get by the interface functions and
8 *      are returned after one cycle automaticly by reseting the cached lists to its initial state. So do not wonder :D
9 */
10
11#ifndef _CR_ENGINE_
12#define _CR_ENGINE_
13
14#include "base_object.h"
15
16#include <vector>
17
18class WorldEntity;
19
20
21namespace CoRe
22{
23  class Collision;
24  class CollisionEvent;
25  class CollisionReaction;
26
27
28  //! A default singleton class.
29  class CREngine : public BaseObject
30  {
31    ObjectListDeclaration(CREngine);
32
33    typedef std::vector<Collision*>::iterator        CollisionIterator;
34    typedef std::vector<CollisionEvent*>::iterator   CollisionEventIterator;
35
36
37  public:
38    typedef enum ReactionType {
39      CR_PHYSICS_MOMENTUM   = 0,           //!< physical reaction: conservervation of momentum
40      CR_PHYSICS_STEP_BACK,                //!< physical reaction: just go to the last position without collisions
41      CR_PHYSICS_GROUND_WALK,              //!< physical reaction: stand on the ground, no movement: simple normal force away from the gravity force
42      CR_PHYSICS_FULL_WALK,                //!< physical reaction: walking on the ground (inkl. hills etc)
43      CR_PHYSICS_DAMAGE,                   //!< physical reaction: daling damage according to the object energy and their structural stability
44
45      CR_OBJECT_DAMAGE,                    //!< object raction: deals damage according to the objects specific damage potential (like weapons, nukes, etc.)
46      CR_OBJECT_PICKUP,                    //!< object rection: calling the objects pickup functions, let them handle the collision (once!)
47
48      CR_VERTEX_TRAFO,                     //!< vertex trafo: transforming the vertex according to the damage
49
50      CR_SPECIAL_CALLBACK,                 //!< special: call a callback function
51
52      CR_NUMBER
53    };
54
55    typedef enum CollisionType {
56      CR_COLLISION_TYPE_AXIS_X       = 0,  //!< collision on x axis
57      CR_COLLISION_TYPE_AXIS_X_NEG,        //!< collision on negative x axis
58      CR_COLLISION_TYPE_AXIS_Y,            //!< collision on y axis
59      CR_COLLISION_TYPE_AXIS_Y_NEG,        //!< collision on negative y axis
60      CR_COLLISION_TYPE_AXIS_Z,            //!< collision on z axis
61      CR_COLLISION_TYPE_AXIS_Z_NEG,        //!< collision on negative z axis
62      CR_COLLISION_TYPE_OBB,               //!< object aligned bounding box collide
63
64      CR_COLLISION_TYPE_NUMBER
65    };
66
67
68    virtual ~CREngine(void);
69
70    /** @returns a Pointer to the only object of this Class */
71    inline static CREngine* getInstance() { if (!singletonRef) singletonRef = new CREngine();  return singletonRef; };
72
73
74    Collision* popCollisionObject();
75    CollisionEvent* popCollisionEventObject();
76
77    void handleCollisions();
78
79    void debug();
80
81
82  private:
83    CREngine();
84    void init();
85
86    void flushCollisions();
87
88
89  private:
90    static CREngine*                    singletonRef;             //!< the reference to the CREngine object (singleton)
91
92    std::vector<Collision*>             collisionsUsed;           //!< a list of used, cached collisions
93    std::vector<Collision*>             collisionsUnused;         //!< a list of unused, cached collisions
94
95    std::vector<CollisionEvent*>        collisionEventsUsed;      //!< a list of used, cached collision events
96    std::vector<CollisionEvent*>        collisionEventsUnused;    //!< a list of unused, cached collision events
97
98    CollisionReaction*                  _reactionList[CREngine::CR_NUMBER];  //!< the collision reaction list containing all reactions types
99
100
101  };
102
103}
104#endif /* _CR_ENGINE_ */
Note: See TracBrowser for help on using the repository browser.