Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/heathaze/src/lib/collision_reaction/collision_handle.h @ 10611

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