Changeset 9939 in orxonox.OLD for branches/coll_rect
- Timestamp:
- Nov 20, 2006, 12:53:27 AM (18 years ago)
- Location:
- branches/coll_rect/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/coll_rect/src/lib/collision_detection/obb_tree_node.cc
r9896 r9939 477 477 { 478 478 if( unlikely(treeNode == NULL || nodeA == NULL || nodeB == NULL)) 479 return; 480 481 if( !CoRe::CollisionTube::getInstance()->isReactive( *nodeA, *nodeB) ) 479 482 return; 480 483 -
branches/coll_rect/src/lib/collision_reaction/collision.h
r9892 r9939 32 32 { 33 33 public: 34 34 35 Collision(); 35 36 virtual ~Collision(); … … 39 40 40 41 42 /* list stuff */ 43 public: 44 typedef std::vector<CollisionEvent*> collisionVector; //!< the vector containing all collision events 45 typedef std::vector<CollisionEvent*>::iterator iterator; //!< iterator definition 46 typedef std::vector<CollisionEvent*>::const_iterator const_iterator; //!< constant iterator definition 47 48 /** registers a @param event CollisionEvent to take place */ 49 inline void registerCollisionEvent(CollisionEvent* event) { this->_collisionEvents.push_back(event); this->bDispatched = false;} 50 /** @returns a vector of collision events */ 51 inline const std::vector<CollisionEvent*>& getCollisionEvents() const { return this->_collisionEvents; } 52 53 void flushCollisionEvents(); 54 55 56 /** @returns iterator pointing to the beginning of the collision event vector */ 57 inline iterator begin() { return this->_collisionEvents.begin(); } 58 /** @returns const iterator pointing to the beginning of the collision event vector */ 59 inline const_iterator begin() const { return this->_collisionEvents.begin(); } 60 /** @returns iterator pointing to the end of the collision event vector */ 61 inline iterator end() { return this->_collisionEvents.end(); } 62 /** @returns const iterator pointing to the end of the collision event vector */ 63 inline const_iterator end() const { return this->_collisionEvents.end(); } 64 65 66 private: 67 collisionVector _collisionEvents; //!< the collision event list 68 69 70 71 /* misc interface functions */ 72 public: 41 73 /** @return Collision WorldEntity A */ 42 74 inline WorldEntity* getEntityA() const { return this->entityA; } 43 75 /** @return Collision WorldEntity B */ 44 76 inline WorldEntity* getEntityB() const { return this->entityB; } 77 inline bool match(const WorldEntity& entityA, WorldEntity& entityB) const { 78 return ((this->entityA == &entityA && this->entityB == &entityB) || (this->entityA == &entityB && this->entityB == &entityA)); } 79 45 80 /** @return true if Entity A collides */ 46 81 inline bool isEntityACollide() const { return this->entityACollide; } … … 53 88 54 89 55 inline bool match(const WorldEntity& entityA, WorldEntity& entityB) const { 56 return ((this->entityA == &entityA && this->entityB == &entityB) || (this->entityA == &entityB && this->entityB == &entityA)); } 90 57 91 /** @returns true if this Collision has already been dispatched */ 58 92 inline bool isDispatched() { return this->bDispatched; } 59 93 /** sets the dispatched flag to true */ 60 94 inline void dispatched() { this->bDispatched = true; } 61 62 /** registers a @param event CollisionEvent to take place */63 inline void registerCollisionEvent(CollisionEvent* event) { this->collisionEvents.push_back(event); this->bDispatched = false;}64 /** @returns a vector of collision events */65 inline const std::vector<CollisionEvent*>& getCollisionEvents() const { return this->collisionEvents; }66 67 68 void flushCollisionEvents();69 70 95 71 96 private: … … 77 102 bool bDispatched; //!< true if this collision has already been dispatched 78 103 79 std::vector<CollisionEvent*> collisionEvents; //!< the collision event list80 104 }; 81 105 } -
branches/coll_rect/src/lib/collision_reaction/collision_filter.cc
r9898 r9939 70 70 if( likely(this->validCRType( type))) 71 71 { 72 //check if this or any parentclass isn't already registered72 //check if this class isn't already registered 73 73 std::vector<ClassID>::iterator it = this->_filters[type].begin(); 74 74 for(; it != this->_filters[type].end(); it++) … … 78 78 } 79 79 80 // so subscribe the reaction final y80 // so subscribe the reaction finally 81 81 this->_filters[type].push_back(target1); 82 82 this->_bReactive = true; … … 132 132 * if the WorldEntity entity is actualy responsive for a certain other WorldEntity 133 133 */ 134 bool CollisionFilter::operator()(const WorldEntity *entity) const134 bool CollisionFilter::operator()(const WorldEntity& entity) const 135 135 { 136 136 // if there are no installed criterions just ommit and … … 143 143 std::vector<ClassID>::const_iterator it = this->_filters[i].begin(); 144 144 for(; it != this->_filters[i].end(); i++ ) 145 if( unlikely(entity ->isA(*it)))145 if( unlikely(entity.isA(*it))) 146 146 return true; 147 147 } … … 158 158 * if the WorldEntity entity is actualy responsive for a certain other WorldEntity 159 159 */ 160 bool CollisionFilter::operator()(const WorldEntity *entity, const CREngine::ReactionType type) const160 bool CollisionFilter::operator()(const WorldEntity& entity, const CREngine::ReactionType type) const 161 161 { 162 162 // if there are no installed criterions just ommit and … … 166 166 // goes through all registered filter criterions and looks for matches 167 167 std::vector<ClassID>::const_iterator it = this->_filters[type].begin(); 168 for(; it != this->_filters[type].end(); i ++ )169 if( unlikely(entity ->isA(*it)))168 for(; it != this->_filters[type].end(); it++ ) 169 if( unlikely(entity.isA(*it))) 170 170 return true; 171 171 -
branches/coll_rect/src/lib/collision_reaction/collision_filter.h
r9898 r9939 46 46 47 47 48 public: 48 49 /* Defines Operators */ 49 bool operator()(const WorldEntity *entity) const;50 bool operator()(const WorldEntity *entity, const CREngine::ReactionType type) const;50 bool operator()(const WorldEntity& entity) const; 51 bool operator()(const WorldEntity& entity, const CREngine::ReactionType type) const; 51 52 52 53 … … 59 60 void unsubscribeReaction(CREngine::ReactionType type); 60 61 void unsubscribeReactions(); 62 63 inline bool isSubscribed(CREngine::ReactionType type) const { /*if( this->validCRType(type)) return this->_filters[type] != NULL; else return false;*/} 61 64 62 65 private: -
branches/coll_rect/src/lib/collision_reaction/collision_tube.cc
r9898 r9939 95 95 const Vector& normal, const Vector& position, bool bInWall) 96 96 { 97 // get last collision 97 98 Collision* collision = this->_collisionList.back(); 98 99 99 100 // check if there is already a collision defined between these objects 100 if( !collision->match(*entity, *groundEntity))101 if( collision != NULL && !collision->match(*entity, *groundEntity)) 101 102 { 103 // get a new collision object 102 104 collision = CREngine::getInstance()->popCollisionObject(); 103 105 collision->collide( entity, groundEntity); … … 117 119 void CollisionTube::handleCollisions() 118 120 { 119 // 121 // for all collisions: 122 std::vector<Collision*>::iterator collisions = this->_collisionList.begin(); 123 for(; collisions < this->_collisionList.end(); collisions++) 124 { 125 126 127 // for all collision events of each collision: 128 Collision::iterator events = (*collisions)->begin(); 129 for(; events < (*collisions)->end(); events++) 130 { 131 132 } 133 } 120 134 } 121 135 122 136 123 /**124 * checks if two objects are125 */126 bool CollisionTube::needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB)127 {128 //if( !this->isReactive( entityA, entityB) )129 // return false;130 137 131 //if( entityA->)132 133 }134 138 135 139 -
branches/coll_rect/src/lib/collision_reaction/collision_tube.h
r9898 r9939 75 75 /* Misc State Informations */ 76 76 public: 77 /** @returns true if at least one of both WorldEntities are subscribed for a collision check*/77 /** @returns true if at least one of both WorldEntities are subscribed for a collision reaction */ 78 78 inline bool isReactive(const WorldEntity& entityA, const WorldEntity& entityB) const 79 { return (entityA.isReactive() && entityB.isReactive()); } 80 bool needCollisionChecking(const WorldEntity& entityA, const WorldEntity& entityB); 79 { return (entityA.isReactive(entityB) && entityB.isReactive(entityA)); } 81 80 82 81 }; -
branches/coll_rect/src/world_entities/world_entity.h
r9896 r9939 88 88 void unsubscribeReactions(); 89 89 90 inline bool isSubscribed(CoRe::CREngine::ReactionType type) const { return this->_collisionFilter.isSubscribed( type); } 91 90 92 /** @return true if there is at least on collision reaction subscribed */ 91 93 inline bool isReactive() const { return this->bReactive; } 92 93 const CoRe::CollisionFilter& getCollisionFilter(CoRe::CREngine::ReactionType type) const { return this->collisionFilter; } 94 inline bool isReactive( const WorldEntity& worldEntity) const { return this->isReactive() || (this->_collisionFilter(worldEntity)); } 95 96 const CoRe::CollisionFilter& getCollisionFilter(CoRe::CREngine::ReactionType type) const { return this->_collisionFilter; } 94 97 95 98 /** @returns true if this entity is standing on ground (BSP model) */ … … 191 194 192 195 /* collision reaction stuff */ 193 CoRe::CollisionFilter collisionFilter;//!< filter for collision event filtering (not every entity listens to all collisions)196 CoRe::CollisionFilter _collisionFilter; //!< filter for collision event filtering (not every entity listens to all collisions) 194 197 bool bReactive; //!< true if there is at least one collision reaction subscibed 195 198
Note: See TracChangeset
for help on using the changeset viewer.