Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_reaction/collision.h @ 9968

Last change on this file since 9968 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.0 KB
RevLine 
[7934]1/*!
[5039]2 * @file collision.h
[7959]3 *  Definition of a collision as a two WE hit each other
[8124]4 *
5 *  A is shared between two WorldEntity's CollisionHandles if both are subscribed to this event. In this case only one
6 *  of the two CollisionHandles will calculate the CollisionReaction and the bDispatched flag will be set afterwards
7 *  to signal that it's already cared about and should be ignored.
[7934]8 */
[4510]9
[4511]10#ifndef _COLLISION_H
11#define _COLLISION_H
[4510]12
[4520]13#include "vector.h"
[7964]14#include <vector>
[4510]15
[4520]16class WorldEntity;
17class BoundingVolume;
[7959]18class CollisionEvent;
[4510]19
[4511]20//! A class representing a simple collision
[7968]21class Collision
22{
23  public:
24    Collision();
25    virtual ~Collision();
[4510]26
[7968]27    /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
[8490]28    inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this->entityA = entityA; this->entityB = entityB; this->bDispatched = false; }
[7934]29
30
[7968]31    /** @return Collision WorldEntity A */
32    inline WorldEntity* getEntityA() const { return this->entityA; }
33    /** @return Collision WorldEntity B */
34    inline WorldEntity* getEntityB() const { return this->entityB; }
[8106]35    /** @return true if Entity A collides */
[8108]36    inline bool isEntityACollide() const { return this->entityACollide; }
37    /** sets the flag if it reacts @param flag true if it should react on entityA*/
38    inline void setEntityACollide(bool flag) { this->entityACollide = flag; }
[8106]39    /** @return true if Entity B collides */
[8108]40    inline bool isEntityBCollide() const { return this->entityBCollide; }
41    /** sets the flag if it reacts @param flag true if it should react on entityB*/
42    inline void setEntityBCollide(bool flag) { this->entityACollide = flag; }
[7940]43
[8490]44
[8029]45    /** @returns true if this Collision has already been dispatched */
46    inline bool isDispatched() { return this->bDispatched; }
[8129]47    /** sets the dispatched flag to true */
48    inline void dispatched() { this->bDispatched = true; }
[8029]49
[7968]50    /** registers a @param event CollisionEvent to take place */
[8108]51    inline void registerCollisionEvent(CollisionEvent* event) { this->collisionEvents.push_back(event); this->bDispatched = false;}
[8006]52    /** @returns a vector of collision events */
53    inline const std::vector<CollisionEvent*>& getCollisionEvents() const { return this->collisionEvents; }
[7940]54
[8106]55
[7968]56    void flushCollisionEvents();
57
58
59  private:
60    WorldEntity*                 entityA;                       //!< the collision body A
61    WorldEntity*                 entityB;                       //!< the collision body B
[8106]62    bool                         entityACollide;                //!< true if entity A is subscribed for collision reaction
63    bool                         entityBCollide;                //!< true if entity B is subscribed for collision reaction
[7968]64
[8029]65    bool                         bDispatched;                   //!< true if this collision has already been dispatched
66
[7968]67    std::vector<CollisionEvent*> collisionEvents;               //!< the collision event list
[4510]68};
69
[4511]70#endif /* _COLLISION_H */
Note: See TracBrowser for help on using the repository browser.