Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

freeing collision reaction engine from unused functions

File size: 3.7 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
26  //! A default singleton class.
27  class CREngine : public BaseObject
28  {
29    ObjectListDeclaration(CREngine);
30
31
32
33  public:
34    typedef enum ReactionType {
35      CR_PHYSICS_MOMENTUM   = 0,           //!< physical reaction: conservervation of momentum
36      CR_PHYSICS_STEP_BACK,                //!< physical reaction: just go to the last position without collisions
37      CR_PHYSICS_GROUND_WALK,              //!< physical reaction: stand on the ground, no movement: simple normal force away from the gravity force
38      CR_PHYSICS_FULL_WALK,                //!< physical reaction: walking on the ground (inkl. hills etc)
39      CR_PHYSICS_DAMAGE,                   //!< physical reaction: daling damage according to the object energy and their structural stability
40
41      CR_OBJECT_DAMAGE,                    //!< object raction: deals damage according to the objects specific damage potential (like weapons, nukes, etc.)
42      CR_OBJECT_PICKUP,                    //!< object rection: calling the objects pickup functions, let them handle the collision (once!)
43
44      CR_VERTEX_TRAFO,                     //!< vertex trafo: transforming the vertex according to the damage
45
46      CR_SPECIAL_CALLBACK,                 //!< special: call a callback function
47
48      CR_NUMBER
49    };
50
51    typedef enum CollisionType {
52      CR_COLLISION_TYPE_AXIS_X       = 0,  //!< collision on x axis
53      CR_COLLISION_TYPE_AXIS_X_NEG,        //!< collision on negative x axis
54      CR_COLLISION_TYPE_AXIS_Y,            //!< collision on y axis
55      CR_COLLISION_TYPE_AXIS_Y_NEG,        //!< collision on negative y axis
56      CR_COLLISION_TYPE_AXIS_Z,            //!< collision on z axis
57      CR_COLLISION_TYPE_AXIS_Z_NEG,        //!< collision on negative z axis
58      CR_COLLISION_TYPE_OBB,               //!< object aligned bounding box collide
59
60      CR_COLLISION_TYPE_NUMBER
61    };
62
63
64    virtual ~CREngine(void);
65
66    /** @returns a Pointer to the only object of this Class */
67    inline static CREngine* getInstance() { if (!singletonRef) singletonRef = new CREngine();  return singletonRef; };
68
69
70    Collision* popCollisionObject();
71    CollisionEvent* popCollisionEventObject();
72    void reset();
73
74    void handleCollisions();
75
76    void debug();
77
78
79  private:
80    CREngine();
81    void init();
82
83    void flushCollisions();
84
85
86  private:
87    //std::vector<CollisionHandle*>       collisionHandles;         //!< list with the collision handles
88
89    std::vector<Collision*>             collisionsUsed;           //!< a list of used, cached collisions
90    std::vector<Collision*>             collisionsUnused;         //!< a list of unused, cached collisions
91
92    std::vector<CollisionEvent*>        collisionEventsUsed;      //!< a list of used, cached collision events
93    std::vector<CollisionEvent*>        collisionEventsUnused;    //!< a list of unused, cached collision events
94
95    static CREngine*                    singletonRef;             //!< the reference to the CREngine object (singleton)
96  };
97
98}
99#endif /* _CR_ENGINE_ */
Note: See TracBrowser for help on using the repository browser.