Changeset 7945 in orxonox.OLD for branches/cr
- Timestamp:
- May 29, 2006, 12:48:21 AM (19 years ago)
- Location:
- branches/cr/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cr/src/lib/collision_reaction/collision_handle.cc
r7933 r7945 72 72 } 73 73 74 /** 75 * flushes the collision list 76 */ 77 void CollisionHandle::flushCollisions() 78 { 79 std::vector<Collision*>::iterator it; 80 for( it = this->collisionList.begin(); it != this->collisionList.end(); it++) 81 CREngine::getInstance()->pushCollisionObject(*it); 82 this->collisionList.clear(); 83 } 74 84 85 86 /** 87 * handles the collisions and react according to algorithm 88 */ 89 void CollisionHandle::handleCollisions() 90 { 91 92 // collision reaction calculations 93 94 // now set state to dispatched 95 this->bDispatched = true; 96 this->flushCollisions(); 97 } -
branches/cr/src/lib/collision_reaction/collision_handle.h
r7934 r7945 20 20 21 21 //! A class for defining collision reactions and storing events 22 class CollisionHandle : public BaseObject { 22 class CollisionHandle : public BaseObject 23 { 23 24 24 public:25 CollisionHandle(WorldEntity* owner, CREngine::CRType type);26 virtual ~CollisionHandle();25 public: 26 CollisionHandle(WorldEntity* owner, CREngine::CRType type); 27 virtual ~CollisionHandle(); 27 28 28 29 29 void addTarget(long classID);30 void addTarget(long classID); 30 31 31 void registerCollision(Collision* collision);32 void registerCollision(Collision* collision); 32 33 33 void handleCollisions(); 34 void flushCollsions(); 34 void handleCollisions(); 35 35 36 36 37 private: 38 WorldEntity* owner; //!< the worldenity this reaction will be applied on 39 CREngine::CRType type; //!< the reaction type 37 private: 38 void flushCollisions(); 40 39 41 bool bDispatched; //!< true if this handle has already been dispatched42 bool bStopOnFirstCollision; //!< true if the cd of this object should be terminated after one match43 40 44 std::vector<Collision*> collisionList; //!< a list full of collisions 45 std::vector<long> targetList; //!< a list of target classes for filtering 41 private: 42 WorldEntity* owner; //!< the worldenity this reaction will be applied on 43 CREngine::CRType type; //!< the reaction type 44 45 bool bDispatched; //!< true if this handle has already been dispatched 46 bool bStopOnFirstCollision; //!< true if the cd of this object should be terminated after one match 47 48 std::vector<Collision*> collisionList; //!< a list full of collisions 49 std::vector<long> targetList; //!< a list of target classes for filtering 46 50 47 51 }; -
branches/cr/src/lib/collision_reaction/cr_engine.cc
r7944 r7945 19 19 20 20 #include "collision.h" 21 #include "collision_handle.h" 21 22 #include "cr_defs.h" 22 23 … … 51 52 } 52 53 53 54 /** 55 * inits the CREngine to a working state 56 */ 54 57 void CREngine::init() 55 58 { … … 62 65 63 66 void CREngine::reset() 64 {} 67 { 68 // first clear all CollisionHandles 69 std::vector<CollisionHandle*>::iterator it; 70 for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++) 71 delete *it; 72 this->collisionHandles.clear(); 73 } 65 74 66 75 … … 72 81 CollisionHandle* CREngine::subscribeReaction(WorldEntity* owner, CRType type) 73 82 { 83 CollisionHandle* ch = new CollisionHandle(owner, type); 84 this->collisionHandles.push_back(ch); 85 } 74 86 75 }76 87 77 88 bool CREngine::unsubscribeReaction(WorldEntity* worldEntity) -
branches/cr/src/lib/collision_reaction/cr_engine.h
r7944 r7945 41 41 inline static CREngine* getInstance() { if (!singletonRef) singletonRef = new CREngine(); return singletonRef; }; 42 42 43 void init();44 43 void reset(); 45 44 … … 60 59 void debug(); 61 60 61 62 62 private: 63 63 CREngine(); 64 void init(); 64 65 65 66 -
branches/cr/src/world_entities/world_entity.cc
r7944 r7945 33 33 34 34 #include "collision_handle.h" 35 #include "collision.h" 35 36 36 37 #include <stdarg.h> … … 68 69 this->objectListNumber = OM_INIT; 69 70 this->objectListIterator = NULL; 71 72 // reset all collision handles to NULL == unsubscribed state 73 for(int i = 0; i < CREngine::CR_NUMBER; ++i) 74 this->collisionHandles[i] = NULL; 70 75 71 76 this->toList(OM_NULL); … … 242 247 void WorldEntity::subscribeReaction(CREngine::CRType type, int nrOfTargets, long target...) 243 248 { 249 if( this->collisionHandles[type] != NULL) { 250 PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n"); 251 return; 252 } 244 253 245 254 this->collisionHandles[type] = CREngine::getInstance()->subscribeReaction(this, type); … … 257 266 * @param collisionEvent the event 258 267 */ 259 void WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BouningVolume* bvA, BoundingVolume* bvB)268 bool WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) 260 269 { 261 270 // create a collision event -
branches/cr/src/world_entities/world_entity.h
r7944 r7945 71 71 /* --- Collision Reaction Block --- */ 72 72 void subscribeReaction(CREngine::CRType type, int nrOfTargets, long target, ...); 73 voidregisterCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);73 bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB); 74 74 75 75
Note: See TracChangeset
for help on using the changeset viewer.