Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/coll_rect/src/lib/collision_reaction/collision_handle.h @ 9890

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

intruducing new container collision_tube. which serves as a central collision registration tube.

File size: 2.6 KB
Line 
1/*!
2 * @file collision_handle.h
3 * @brief Definition of a collision handle: used for accessing per world entity collision events and reactions
4*/
5
6#ifndef _COLLISION_HANDLE_H
7#define _COLLISION_HANDLE_H
8
9#include "base_object.h"
10#include "cr_engine.h"
11
12#include <vector>
13#include <list>
14
15
16class Collision;
17class WorldEntity;
18
19namespace CoRe
20{
21
22  class CollisionReaction;
23
24
25
26  //! A class for defining collision reactions and storing events
27  class CollisionHandle : public BaseObject
28  {
29    ObjectListDeclaration(CollisionHandle);
30
31  public:
32    CollisionHandle(WorldEntity* owner, CREngine::CRType type);
33    virtual ~CollisionHandle();
34
35    void reset();
36
37    void addTarget(const ClassID& target);
38    Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB);
39    void registerSharedCollision(Collision* collision);
40    void registerCollisionEvent(CollisionEvent* collisionEvent);
41
42    /** @returns true if regiestered some new collision events in this tick frame */
43    inline bool isCollided() const { return this->bCollided; }
44    /** @returns true if this collision handle has already been dispatched */
45    inline bool isDispatched() const { return this->bDispatched; }
46    /** @returns true if this handle should be pulled also if there are no collisions */
47    inline bool isContinuousPoll() const { return this->bContinuousPoll; }
48    /** @returns the type */
49    inline CREngine::CRType getType() const { return this->type; }
50
51    void handleCollisions();
52
53
54  private:
55    void flushCollisions();
56    bool filterCollisionEvent(CollisionEvent* collisionEvent);
57    bool filterCollision(Collision* collision);
58
59
60
61  private:
62    WorldEntity*                  owner;                   //!< the worldenity this reaction will be applied on
63    CREngine::CRType              type;                    //!< the reaction type
64
65    bool                          bContinuousPoll;         //!< if this is true
66    bool                          bDispatched;             //!< true if this handle has already been dispatched
67    bool                          bStopOnFirstCollision;   //!< true if the cd of this object should be terminated after one match
68    bool                          bCollided;               //!< true if the CollsionHandle has registered some new collisions
69
70    std::vector<Collision*>       collisionList;           //!< a list full of collisions
71    std::vector<ClassID>          targetList;              //!< a list of target classes for filtering @TODO TAKE SET INSTEAD OF VECTOR HERE
72
73    CollisionReaction*            collisionReaction;       //!< reference to the collision reaction object
74
75  };
76
77}
78#endif /* _COLLISION_HANDLE_H */
Note: See TracBrowser for help on using the repository browser.