Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9896 was 9895, checked in by patrick, 18 years ago

interface adjustements

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