Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cr/src/lib/collision_reaction/collision.h @ 8108

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

cr: double sidded collision events updated

File size: 2.6 KB
Line 
1/*!
2 * @file collision.h
3 *  Definition of a collision as a two WE hit each other
4 */
5
6#ifndef _COLLISION_H
7#define _COLLISION_H
8
9#include "vector.h"
10#include <vector>
11
12class WorldEntity;
13class BoundingVolume;
14class CollisionEvent;
15
16//! A class representing a simple collision
17class Collision
18{
19
20  public:
21    Collision();
22    virtual ~Collision();
23
24    /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
25    inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this->entityA = entityA; this->entityB = entityB; }
26
27
28    /** @return Collision WorldEntity A */
29    inline WorldEntity* getEntityA() const { return this->entityA; }
30    /** @return Collision WorldEntity B */
31    inline WorldEntity* getEntityB() const { return this->entityB; }
32    /** @return true if Entity A collides */
33    inline bool isEntityACollide() const { return this->entityACollide; }
34    /** sets the flag if it reacts @param flag true if it should react on entityA*/
35    inline void setEntityACollide(bool flag) { this->entityACollide = flag; }
36    /** @return true if Entity B collides */
37    inline bool isEntityBCollide() const { return this->entityBCollide; }
38    /** sets the flag if it reacts @param flag true if it should react on entityB*/
39    inline void setEntityBCollide(bool flag) { this->entityACollide = flag; }
40
41    /** @returns true if this Collision has already been dispatched */
42    inline bool isDispatched() { return this->bDispatched; }
43
44    /** registers a @param event CollisionEvent to take place */
45    inline void registerCollisionEvent(CollisionEvent* event) { this->collisionEvents.push_back(event); this->bDispatched = false;}
46    /** @returns a vector of collision events */
47    inline const std::vector<CollisionEvent*>& getCollisionEvents() const { return this->collisionEvents; }
48
49
50    void handleCollisionEvents();
51
52
53  private:
54    void flushCollisionEvents();
55
56
57  private:
58    WorldEntity*                 entityA;                       //!< the collision body A
59    WorldEntity*                 entityB;                       //!< the collision body B
60    bool                         entityACollide;                //!< true if entity A is subscribed for collision reaction
61    bool                         entityBCollide;                //!< true if entity B is subscribed for collision reaction
62
63    bool                         bDispatched;                   //!< true if this collision has already been dispatched
64
65    std::vector<CollisionEvent*> collisionEvents;               //!< the collision event list
66};
67
68#endif /* _COLLISION_H */
Note: See TracBrowser for help on using the repository browser.