Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 20, 2006, 1:09:03 AM (18 years ago)
Author:
patrick
Message:

more design, thinner interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/coll_rect/src/lib/collision_reaction/collision_filter.h

    r9895 r9896  
    11/*!
    2  * @file collision_handle.h
    3  * @brief Definition of a collision handle: used for accessing per world entity collision events and reactions
     2 * @file collision_filter.h
     3 * @brief Definition of a collision filter: checks if a certain WorldEntity is responsive for another WorldEntity
     4 *
    45*/
    56
     
    2425
    2526
    26   //! A class for defining collision reactions and storing events
     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   */
    2734  class CollisionFilter : public BaseObject
    2835  {
    2936    ObjectListDeclaration(CollisionFilter);
    3037
     38
     39    /* Constructor/Deconstructors */
    3140  public:
    32     CollisionFilter(WorldEntity* owner, CREngine::ReactionType type);
     41    CollisionFilter(WorldEntity* owner);
    3342    virtual ~CollisionFilter();
    3443
    35     void reset();
    36 
    37     void addTarget(const ClassID& target);
    38 
    39     /** @returns true if regiestered some new collision events in this tick frame */
    40     inline bool isCollided() const { return this->bCollided; }
    41     /** @returns true if this collision handle has already been dispatched */
    42     inline bool isDispatched() const { return this->bDispatched; }
    43     /** @returns true if this handle should be pulled also if there are no collisions */
    44     inline bool isContinuousPoll() const { return this->bContinuousPoll; }
    45     /** @returns the type */
    46     inline CREngine::ReactionType getType() const { return this->type; }
    47 
    48     void handleCollisions();
     44  private:
     45    CollisionFilter(const CollisionFilter& collisionFilter) {}
     46    WorldEntity*                  _owner;                   //!< the worldenity this reaction will be applied on
    4947
    5048
    51   private:
    52     void flushCollisions();
    53     bool filterCollisionEvent(CollisionEvent* collisionEvent);
    54     bool filterCollision(Collision* collision);
     49    /* Defines Operators */
     50    bool operator()(const WorldEntity* entity) const;
    5551
    5652
     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);
     58
     59    void unsubscribeReaction(CoRe::CREngine::ReactionType type);
     60    void unsubscribeReactions();
    5761
    5862  private:
    59     WorldEntity*                  owner;                   //!< the worldenity this reaction will be applied on
    60     CREngine::ReactionType              type;                    //!< the reaction type
     63    std::vector<ClassID>          _filters[CREngine::CR_NUMBER];  //!< an array of filter targets: for each collision type a list of filter objects
    6164
    62     bool                          bContinuousPoll;         //!< if this is true
    63     bool                          bDispatched;             //!< true if this handle has already been dispatched
    64     bool                          bStopOnFirstCollision;   //!< true if the cd of this object should be terminated after one match
    65     bool                          bCollided;               //!< true if the CollsionHandle has registered some new collisions
    6665
    67     std::vector<Collision*>       collisionList;           //!< a list full of collisions
    68     std::vector<ClassID>          targetList;              //!< a list of target classes for filtering @TODO TAKE SET INSTEAD OF VECTOR HERE
     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; }
    6976
    70     CollisionReaction*            collisionReaction;       //!< reference to the collision reaction object
     77  private:
     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
    7181
    7282  };
Note: See TracChangeset for help on using the changeset viewer.