Rev | Line | |
---|
[7934] | 1 | /*! |
---|
[5039] | 2 | * @file collision.h |
---|
[7959] | 3 | * Definition of a collision as a two WE hit each other |
---|
[7934] | 4 | */ |
---|
[4510] | 5 | |
---|
[4511] | 6 | #ifndef _COLLISION_H |
---|
| 7 | #define _COLLISION_H |
---|
[4510] | 8 | |
---|
[4520] | 9 | #include "vector.h" |
---|
[7964] | 10 | #include <vector> |
---|
[4510] | 11 | |
---|
[4520] | 12 | class WorldEntity; |
---|
| 13 | class BoundingVolume; |
---|
[7959] | 14 | class CollisionEvent; |
---|
[4510] | 15 | |
---|
[4511] | 16 | //! A class representing a simple collision |
---|
[7968] | 17 | class Collision |
---|
| 18 | { |
---|
[4510] | 19 | |
---|
[7968] | 20 | public: |
---|
| 21 | Collision(); |
---|
| 22 | virtual ~Collision(); |
---|
[4510] | 23 | |
---|
[7968] | 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; } |
---|
[7934] | 26 | |
---|
| 27 | |
---|
[7968] | 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; } |
---|
[7940] | 32 | |
---|
[8029] | 33 | /** @returns true if this Collision has already been dispatched */ |
---|
| 34 | inline bool isDispatched() { return this->bDispatched; } |
---|
| 35 | |
---|
[7968] | 36 | /** registers a @param event CollisionEvent to take place */ |
---|
| 37 | inline void registerCollisionEvent(CollisionEvent* event) { this->collisionEvents.push_back(event); } |
---|
[8006] | 38 | /** @returns a vector of collision events */ |
---|
| 39 | inline const std::vector<CollisionEvent*>& getCollisionEvents() const { return this->collisionEvents; } |
---|
[7940] | 40 | |
---|
[7968] | 41 | void handleCollisionEvents(); |
---|
[7959] | 42 | |
---|
[7934] | 43 | |
---|
[7968] | 44 | private: |
---|
| 45 | void flushCollisionEvents(); |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | private: |
---|
| 49 | WorldEntity* entityA; //!< the collision body A |
---|
| 50 | WorldEntity* entityB; //!< the collision body B |
---|
| 51 | |
---|
[8029] | 52 | bool bDispatched; //!< true if this collision has already been dispatched |
---|
| 53 | |
---|
[7968] | 54 | std::vector<CollisionEvent*> collisionEvents; //!< the collision event list |
---|
[4510] | 55 | }; |
---|
| 56 | |
---|
[4511] | 57 | #endif /* _COLLISION_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.