Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_reaction/collision_filter.h

Last change on this file was 10013, checked in by patrick, 17 years ago

merged the collision reaction branche back to trunk

File size: 3.3 KB
RevLine 
[7841]1/*!
[9896]2 * @file collision_filter.h
3 * @brief Definition of a collision filter: checks if a certain WorldEntity is responsive for another WorldEntity
4 *
[7841]5*/
6
[9895]7#ifndef _COLLISION_FILTER_H
8#define _COLLISION_FILTER_H
[7841]9
10#include "base_object.h"
[7927]11#include "cr_engine.h"
[7841]12
[7927]13#include <vector>
[8190]14#include <list>
[7927]15
16
[7841]17class Collision;
[7927]18class WorldEntity;
[7841]19
[9889]20namespace CoRe
21{
[7927]22
[9889]23  class CollisionReaction;
[7927]24
[9889]25
[9896]26  /**
27   * A class for defining collision reactions and storing events (functional object)
28   *
29   * This class basically checks if the owner of this filter (a WorldEntity) is responsive for a certain other WorldEntity.
30   * The check is performed via the operator() (therefore it's a functional objects). For each CollisionReaction there is a list
31   * of WorldEntities (their ClassIDs) to which it listens to.
32   */
[9895]33  class CollisionFilter : public BaseObject
[9889]34  {
[9895]35    ObjectListDeclaration(CollisionFilter);
[9890]36
[9896]37
[9990]38    typedef std::vector<ClassID>::iterator        TargetIterator;
39    typedef std::vector<ClassID>::const_iterator  TargetIteratorConst;
[9980]40
[9896]41    /* Constructor/Deconstructors */
[8190]42  public:
[9896]43    CollisionFilter(WorldEntity* owner);
[9895]44    virtual ~CollisionFilter();
[7841]45
[9896]46  private:
47    CollisionFilter(const CollisionFilter& collisionFilter) {}
48    WorldEntity*                  _owner;                   //!< the worldenity this reaction will be applied on
[7927]49
50
[9939]51  public:
[9896]52    /* Defines Operators */
[9939]53    bool operator()(const WorldEntity& entity) const;
54    bool operator()(const WorldEntity& entity, const CREngine::ReactionType type) const;
[7841]55
56
[9896]57    /* Collision Reaction subscription unsubscription Block */
58  public:
[9898]59    void subscribeReaction(CREngine::ReactionType type, const ClassID& target1);
60    void subscribeReaction(CREngine::ReactionType type, const ClassID& target1, const ClassID& target2);
61    void subscribeReaction(CREngine::ReactionType type, const ClassID& target1, const ClassID& target2, const ClassID& target3);
[7841]62
[9898]63    void unsubscribeReaction(CREngine::ReactionType type);
[9896]64    void unsubscribeReactions();
65
[8190]66  private:
[9896]67    std::vector<ClassID>          _filters[CREngine::CR_NUMBER];  //!< an array of filter targets: for each collision type a list of filter objects
[7841]68
69
[9896]70    /* Misc State Informations */
71  public:
72    /** @returns true if this handle should be pulled also if there are no collisions, can also be set with this function (reference)*/
[9988]73    inline bool isContinousPoll() { return this->_bContinuousPoll; }
[9896]74    /** @returns true if this filter should be pulled always */
[9988]75    inline bool isContinousPoll() const { return this->_bContinuousPoll; }
76    /** @returns true if this filter is reactive i.e. at least one filter criterion installed */
77    inline bool isReactive() const { return this->_bReactive; }
78
79
80  private:
[9896]81    /** @returns true if this @param type Collision Reaction type is a valid number */
82    inline bool validCRType(const CREngine::ReactionType& type) const {return (type >= 0 && type < CREngine::CR_NUMBER); }
[7841]83
[9988]84
[8190]85  private:
[9896]86    bool                          _bContinuousPoll;         //!< if this is true
87    bool                          _bStopOnFirstCollision;   //!< true if the cd of this object should be terminated after one match
88    bool                          _bReactive;               //!< true if this class has at least one filter criterion == one target
[8190]89
[9889]90  };
[7841]91
[9889]92}
[9895]93#endif /* _COLLISION_FILTER_H */
Note: See TracBrowser for help on using the repository browser.