Changeset 9896 in orxonox.OLD for branches/coll_rect/src/lib/collision_reaction/collision_filter.h
- Timestamp:
- Oct 20, 2006, 1:09:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/coll_rect/src/lib/collision_reaction/collision_filter.h
r9895 r9896 1 1 /*! 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 * 4 5 */ 5 6 … … 24 25 25 26 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 */ 27 34 class CollisionFilter : public BaseObject 28 35 { 29 36 ObjectListDeclaration(CollisionFilter); 30 37 38 39 /* Constructor/Deconstructors */ 31 40 public: 32 CollisionFilter(WorldEntity* owner , CREngine::ReactionType type);41 CollisionFilter(WorldEntity* owner); 33 42 virtual ~CollisionFilter(); 34 43 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 49 47 50 48 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; 55 51 56 52 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(); 57 61 58 62 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 61 64 62 bool bContinuousPoll; //!< if this is true63 bool bDispatched; //!< true if this handle has already been dispatched64 bool bStopOnFirstCollision; //!< true if the cd of this object should be terminated after one match65 bool bCollided; //!< true if the CollsionHandle has registered some new collisions66 65 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; } 69 76 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 71 81 72 82 };
Note: See TracChangeset
for help on using the changeset viewer.