Changeset 9988 in orxonox.OLD for branches/coll_rect/src
- Timestamp:
- Dec 3, 2006, 4:55:19 PM (18 years ago)
- Location:
- branches/coll_rect/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/coll_rect/src/lib/collision_reaction/collision.h
r9985 r9988 31 31 class Collision 32 32 { 33 34 typedef std::vector<CollisionEvent*> CollisionVector; //!< the vector containing all collision events 35 typedef std::vector<CollisionEvent*>::iterator Iterator; //!< iterator definition 36 typedef std::vector<CollisionEvent*>::const_iterator ConstIterator; //!< constant iterator definition 37 38 33 39 public: 34 40 … … 37 43 38 44 /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */ 39 inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this-> entityA = entityA; this->entityB = entityB; this->bDispatched = false; }45 inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this->_entityA = entityA; this->_entityB = entityB; } 40 46 41 47 42 48 /* list stuff */ 43 49 public: 44 typedef std::vector<CollisionEvent*> CollisionVector; //!< the vector containing all collision events45 typedef std::vector<CollisionEvent*>::iterator Iterator; //!< iterator definition46 typedef std::vector<CollisionEvent*>::const_iterator ConstIterator; //!< constant iterator definition47 50 48 51 /** registers a @param event CollisionEvent to take place */ 49 inline void registerCollisionEvent(CollisionEvent* event) { this->_collisionEvents.push_back(event); this->bDispatched = false;}52 inline void registerCollisionEvent(CollisionEvent* event) { this->_collisionEvents.push_back(event); } 50 53 51 54 void reset(); … … 87 90 bool _entityBCollide; //!< true if entity B is subscribed for collision reaction 88 91 89 collisionVector _collisionEvents; //!< the collision event list92 CollisionVector _collisionEvents; //!< the collision event list 90 93 91 94 }; -
branches/coll_rect/src/lib/collision_reaction/collision_filter.cc
r9980 r9988 21 21 #include "collision.h" 22 22 #include "collision_event.h" 23 #include "collision_reaction.h"24 23 25 #include "cr_object_damage.h"26 #include "cr_physics_ground_walk.h"27 #include "cr_physics_full_walk.h"28 24 29 25 #include "debug.h" … … 112 108 if( likely(this->validCRType( type))) 113 109 this->_filters[type].clear(); 110 111 for( int i = 0; i < CREngine::CR_NUMBER; i++) 112 { 113 if( this->_filters[i].size() > 0) 114 { 115 this->_bReactive = true; 116 break; 117 } 118 } 119 114 120 } 115 121 … … 121 127 for(int i = 0; i < CREngine::CR_NUMBER; i++) 122 128 this->_filters[i].clear(); 129 130 this->_bReactive = false; 123 131 } 124 132 … … 135 143 { 136 144 // if there are no installed criterions just ommit and 137 if( this-> bReactive())145 if( this->isReactive()) 138 146 return false; 139 147 … … 142 150 { 143 151 TargetIterator it = this->_filters[i].begin(); 144 for(; it != this->_filters[i].end(); i++ ) 145 if( unlikely(entity.isA(*it))) 146 return true; 152 153 154 // for(; it != this->_filters[i].end(); i++ ) 155 // if( unlikely(entity.isA(*it) ) ) 156 // return true; 147 157 } 148 158 … … 161 171 { 162 172 // if there are no installed criterions just omit and return 163 if( !this-> bReactive())173 if( !this->isReactive()) 164 174 return false; 165 175 -
branches/coll_rect/src/lib/collision_reaction/collision_filter.h
r9980 r9988 63 63 void unsubscribeReactions(); 64 64 65 inline bool isSubscribed(CREngine::ReactionType type) const { /*if( this->validCRType(type)) return this->_filters[type] != NULL; else return false;*/}66 67 65 private: 68 66 std::vector<ClassID> _filters[CREngine::CR_NUMBER]; //!< an array of filter targets: for each collision type a list of filter objects … … 72 70 public: 73 71 /** @returns true if this handle should be pulled also if there are no collisions, can also be set with this function (reference)*/ 74 inline bool & bContinousPoll() { return this->_bContinuousPoll; }72 inline bool isContinousPoll() { return this->_bContinuousPoll; } 75 73 /** @returns true if this filter should be pulled always */ 76 inline bool bContinousPoll() const { return this->_bContinuousPoll; } 74 inline bool isContinousPoll() const { return this->_bContinuousPoll; } 75 /** @returns true if this filter is reactive i.e. at least one filter criterion installed */ 76 inline bool isReactive() const { return this->_bReactive; } 77 78 79 private: 77 80 /** @returns true if this @param type Collision Reaction type is a valid number */ 78 81 inline bool validCRType(const CREngine::ReactionType& type) const {return (type >= 0 && type < CREngine::CR_NUMBER); } 79 /** @returns true if this filter is reactive i.e. at least one filter criterion installed */ 80 inline bool bReactive() const { return this->_bReactive; } 82 81 83 82 84 private: -
branches/coll_rect/src/lib/collision_reaction/collision_tube.h
r9986 r9988 49 49 50 50 typedef std::vector<Collision*>::iterator CollisionIterator; 51 typedef std::vector<Collision*> CollisionVector; 52 51 53 52 54 /* Constructor/Deconstructor/Singleton Interface */ … … 59 61 CollisionTube(const CollisionTube& tube) {} 60 62 61 static CollisionTube* instance; //!< the singleton instance63 static CollisionTube* instance; //!< the singleton instance 62 64 63 65 … … 69 71 70 72 /** @returns an iterator pointing to the beginning of the list */ 71 CollisionIterator &begin() { return this->_collisionList.begin(); }73 CollisionIterator begin() { return this->_collisionList.begin(); } 72 74 /** @returns an iterator pointing to the end of the list */ 73 CollisionIterator &end() { return this->_collisionList.end(); }75 CollisionIterator end() { return this->_collisionList.end(); } 74 76 75 77 76 78 private: 77 std::vector<Collision*>_collisionList; //!< the list of collisions since the last processing79 CollisionVector _collisionList; //!< the list of collisions since the last processing 78 80 79 81 -
branches/coll_rect/src/lib/collision_reaction/cr_engine.cc
r9985 r9988 17 17 18 18 19 #include "cr_object_damage.h" 20 #include "cr_physics_full_walk.h" 21 #include "cr_physics_ground_walk.h" 19 22 20 23 #include "collision.h" 21 24 #include "collision_event.h" 22 25 #include "collision_filter.h" 26 #include "collision_tube.h" 23 27 #include "cr_defs.h" 24 28 … … 62 66 PRINTF(0)("CollisionReaction Error: CollisionEvent cache size missmatch: %i of %i\n", this->collisionEventsUnused.size(), CR_MAX_COLLISION_EVENTS); 63 67 64 this->reset();65 68 this->flushCollisions(); 66 69 67 Collision Listit1 = this->collisionsUnused.begin();70 CollisionIterator it1 = this->collisionsUnused.begin(); 68 71 for(; it1 < this->collisionsUnused.end(); it1++) 69 72 delete *it1; 70 CollisionEvent Listit2 = this->collisionEventsUnused.begin();73 CollisionEventIterator it2 = this->collisionEventsUnused.begin(); 71 74 for(; it2 < this->collisionEventsUnused.end(); it2++) 72 75 delete *it2; … … 146 149 for(; ci < CollisionTube::getInstance()->end(); ++ci) 147 150 { 148 for( int i = CREngine::CR_PHYSICS_MOMENTUM; i < CREngine::CR_NU BER; i++)151 for( int i = CREngine::CR_PHYSICS_MOMENTUM; i < CREngine::CR_NUMBER; i++) 149 152 { 150 153 // check if entity A or B is subscibed for this event 151 if( (*ci)->getEntityA()->bReactibe((*it)->getEnityB(), i) || (*ci)->getEntityB()->bReactibe((*it)->getEnityA(), i)) 152 (*ci)->reactToCollision(*ci); 154 if( (*ci)->getEntityA()->isReactive(*(*ci)->getEntityB(), (CREngine::ReactionType)i) || 155 (*ci)->getEntityB()->isReactive(*(*ci)->getEntityA(), (CREngine::ReactionType)i)) 156 this->_reactionList[i]->reactToCollision(*ci); 153 157 154 158 (*ci)->reset(); -
branches/coll_rect/src/lib/collision_reaction/cr_engine.h
r9986 r9988 31 31 ObjectListDeclaration(CREngine); 32 32 33 typedef std::vector<CollisionEvent*> CollisionEventVector; 34 typedef std::vector<Collision*> CollisionVector; 33 35 typedef std::vector<Collision*>::iterator CollisionIterator; 34 36 typedef std::vector<CollisionEvent*>::iterator CollisionEventIterator; … … 90 92 static CREngine* singletonRef; //!< the reference to the CREngine object (singleton) 91 93 92 std::vector<Collision*>collisionsUsed; //!< a list of used, cached collisions93 std::vector<Collision*>collisionsUnused; //!< a list of unused, cached collisions94 CollisionVector collisionsUsed; //!< a list of used, cached collisions 95 CollisionVector collisionsUnused; //!< a list of unused, cached collisions 94 96 95 std::vector<CollisionEvent*>collisionEventsUsed; //!< a list of used, cached collision events96 std::vector<CollisionEvent*>collisionEventsUnused; //!< a list of unused, cached collision events97 CollisionEventVector collisionEventsUsed; //!< a list of used, cached collision events 98 CollisionEventVector collisionEventsUnused; //!< a list of unused, cached collision events 97 99 98 100 CollisionReaction* _reactionList[CREngine::CR_NUMBER]; //!< the collision reaction list containing all reactions types -
branches/coll_rect/src/lib/collision_reaction/cr_object_damage.cc
r9889 r9988 74 74 } 75 75 76 collision->flushCollisionEvents();77 collision->dispatched();78 79 76 // const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents()); 80 77 // std::vector<CollisionEvent*>::const_iterator it = collisionEvents->begin(); -
branches/coll_rect/src/lib/collision_reaction/cr_physics_ground_walk.cc
r9982 r9988 79 79 80 80 81 const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents()); 82 std::vector<CollisionEvent*>::const_iterator it = collisionEvents->begin(); 83 for(; it != collisionEvents->end(); it++) 81 std::vector<CollisionEvent*>::const_iterator it = collision->begin(); 82 for(; it != collision->end(); it++) 84 83 { 85 84 -
branches/coll_rect/src/world_entities/world_entity.cc
r9896 r9988 77 77 this->lastObjectListNumber = OM_INIT; 78 78 79 // reset all collision handles to NULL == unsubscribed state 80 this->bReactive = false; 81 this->bOnGround = false; 79 this->_bOnGround = false; 82 80 83 81 // registering default reactions: -
branches/coll_rect/src/world_entities/world_entity.h
r9986 r9988 88 88 void unsubscribeReactions(); 89 89 90 inline bool isSubscribed(CoRe::CREngine::ReactionType type) const { return this->_collisionFilter.isSubscribed( type); }91 92 90 /** @return true if there is at least on collision reaction subscribed */ 93 inline bool isReactive() const { return this-> bReactive; }91 inline bool isReactive() const { return this->_collisionFilter.isReactive(); } 94 92 95 93 /** @param worldEntity the world entity to be checked @returns true if there is a collisionreaction registered for the worldEntity */ 96 inline bool isReactive( const WorldEntity& worldEntity) const { return this-> isReactive() || (this->_collisionFilter(worldEntity)); }94 inline bool isReactive( const WorldEntity& worldEntity) const { return this->_collisionFilter.isReactive() || (this->_collisionFilter(worldEntity)); } 97 95 /** @param worldEntity the world entity to be checked @param type special reaction type @returns true if collision reaction reg. */ 98 inline bool isReactive( const WorldEntity& worldEntity, CoRe::CREngine::ReactionTypetype) const99 { return this-> isReactive() || (this->_collisionFilter(worldEntity, type)); }96 inline bool isReactive( const WorldEntity& worldEntity, const CoRe::CREngine::ReactionType& type) const 97 { return this->_collisionFilter.isReactive() || (this->_collisionFilter(worldEntity, type)); } 100 98 101 99 … … 103 101 104 102 /** @returns true if this entity is standing on ground (BSP model) */ 105 bool isOnGround() const { return this-> bOnGround; }103 bool isOnGround() const { return this->_bOnGround; } 106 104 /** @param flag: marks if this entity is standing on ground */ 107 void setOnGround(bool flag) { this-> bOnGround = flag; }105 void setOnGround(bool flag) { this->_bOnGround = flag; } 108 106 109 107 virtual void destroy( WorldEntity* killer ); … … 201 199 /* collision reaction stuff */ 202 200 CoRe::CollisionFilter _collisionFilter; //!< filter for collision event filtering (not every entity listens to all collisions) 203 bool bReactive; //!< true if there is at least one collision reaction subscibed 204 201 bool _bOnGround; //!< flag true if the object is on the ground 205 202 206 203 PhysicsInterface physicsInterface; //!< the physics object of the WorldEntity 207 bool bOnGround; //!< true if this entity is standing on the ground208 204 209 205 /* network help structures */
Note: See TracChangeset
for help on using the changeset viewer.