Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/coll_rect/src/lib/collision_reaction/collision_filter.h @ 9896

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

more design, thinner interface

File size: 3.0 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
26
[9896]27  /**
28   * A class for defining collision reactions and storing events (functional object)
29   *
30   * This class basically checks if the owner of this filter (a WorldEntity) is responsive for a certain other WorldEntity.
31   * The check is performed via the operator() (therefore it's a functional objects). For each CollisionReaction there is a list
32   * of WorldEntities (their ClassIDs) to which it listens to.
33   */
[9895]34  class CollisionFilter : public BaseObject
[9889]35  {
[9895]36    ObjectListDeclaration(CollisionFilter);
[9890]37
[9896]38
39    /* Constructor/Deconstructors */
[8190]40  public:
[9896]41    CollisionFilter(WorldEntity* owner);
[9895]42    virtual ~CollisionFilter();
[7841]43
[9896]44  private:
45    CollisionFilter(const CollisionFilter& collisionFilter) {}
46    WorldEntity*                  _owner;                   //!< the worldenity this reaction will be applied on
[7927]47
48
[9896]49    /* Defines Operators */
50    bool operator()(const WorldEntity* entity) const;
[7841]51
52
[9896]53    /* Collision Reaction subscription unsubscription Block */
54  public:
55    void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1);
56    void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2);
57    void subscribeReaction(CoRe::CREngine::ReactionType type, const ClassID& target1, const ClassID& target2, const ClassID& target3);
[7841]58
[9896]59    void unsubscribeReaction(CoRe::CREngine::ReactionType type);
60    void unsubscribeReactions();
61
[8190]62  private:
[9896]63    std::vector<ClassID>          _filters[CREngine::CR_NUMBER];  //!< an array of filter targets: for each collision type a list of filter objects
[7841]64
65
[9896]66    /* Misc State Informations */
67  public:
68    /** @returns true if this handle should be pulled also if there are no collisions, can also be set with this function (reference)*/
69    inline bool& bContinousPoll() { return this->_bContinuousPoll; }
70    /** @returns true if this filter should be pulled always */
71    inline bool bContinousPoll() const { return this->_bContinuousPoll; }
72    /** @returns true if this @param type Collision Reaction type is a valid number */
73    inline bool validCRType(const CREngine::ReactionType& type) const {return (type >= 0 && type < CREngine::CR_NUMBER); }
74    /** @returns true if this filter is reactive i.e. at least one filter criterion installed */
75    inline bool bReactive() const { return this->_bReactive; }
[7841]76
[8190]77  private:
[9896]78    bool                          _bContinuousPoll;         //!< if this is true
79    bool                          _bStopOnFirstCollision;   //!< true if the cd of this object should be terminated after one match
80    bool                          _bReactive;               //!< true if this class has at least one filter criterion == one target
[8190]81
[9889]82  };
[7841]83
[9889]84}
[9895]85#endif /* _COLLISION_FILTER_H */
Note: See TracBrowser for help on using the repository browser.