Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7946 in orxonox.OLD for branches/cr/src


Ignore:
Timestamp:
May 29, 2006, 1:04:39 AM (19 years ago)
Author:
patrick
Message:

cr: more cr cleanup

Location:
branches/cr/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/cr/src/lib/collision_reaction/collision_handle.cc

    r7945 r7946  
    4343{
    4444  // delete what has to be deleted here
     45}
     46
     47/**
     48 * restores the CollisionHandle to its initial state
     49 */
     50void CollisionHandle::reset()
     51{
     52  this->flushCollisions();
    4553}
    4654
  • branches/cr/src/lib/collision_reaction/collision_handle.h

    r7945 r7946  
    2727    virtual ~CollisionHandle();
    2828
     29    void reset();
    2930
    3031    void addTarget(long classID);
    31 
    3232    void registerCollision(Collision* collision);
    3333
  • branches/cr/src/lib/collision_reaction/cr_engine.cc

    r7945 r7946  
    6464
    6565
     66/**
     67 * flushes the CollisionHandles and restores the CREngine to the initial state
     68 */
    6669void CREngine::reset()
    6770{
     
    6972  std::vector<CollisionHandle*>::iterator it;
    7073  for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)
     74  {
     75    (*it)->reset();
    7176    delete *it;
     77  }
    7278  this->collisionHandles.clear();
    7379}
     
    7884 *  @param owner: the WE to subscribe
    7985 *  @param type: the type of collision reaction to perform
     86 *  @return the newly created CollisionHandle
    8087 */
    8188CollisionHandle* CREngine::subscribeReaction(WorldEntity* owner, CRType type)
     
    8693
    8794
    88 bool CREngine::unsubscribeReaction(WorldEntity* worldEntity)
    89 {}
    90 
    91 
     95/**
     96 * unsubscribe reaction from the reaction list
     97 *  @param collisionHandle the CollisionHandle to remove
     98 *  @param returns true if worked collrectly
     99 */
    92100bool CREngine::unsubscribeReaction(CollisionHandle* collisionHandle)
    93 {}
     101{
     102  std::vector<CollisionHandle*>::iterator it;
     103  for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)
     104  {
     105    if( *it == collisionHandle)
     106    {
     107      this->collisionHandles.erase(it);
     108      delete collisionHandle;
     109      return true;
     110    }
     111  }
     112  return false;
     113}
    94114
    95115
  • branches/cr/src/lib/collision_reaction/cr_engine.h

    r7945 r7946  
    4646  CollisionHandle* subscribeReaction(WorldEntity* worldEntity, CRType type);
    4747
    48   bool unsubscribeReaction(WorldEntity* worldEntity);
    4948  bool unsubscribeReaction(CollisionHandle* collisionHandle);
    5049
  • branches/cr/src/world_entities/world_entity.cc

    r7945 r7946  
    9494  if (this->healthWidget != NULL)
    9595    delete this->healthWidget;
     96
     97  this->unsubscribeReaction();
    9698}
    9799
     
    263265
    264266/**
     267 * unsubscribes a specific reaction from the worldentity
     268 *  @param type the reaction to unsubscribe
     269 */
     270void WorldEntity::unsubscribeReaction(CREngine::CRType type)
     271{
     272  if( this->collisionHandles[type] == NULL)
     273    return;
     274
     275  CREngine::getInstance()->unsubscribeReaction(this->collisionHandles[type]);
     276  this->collisionHandles[type] = NULL;
     277}
     278
     279
     280/**
     281 * unsubscribes all collision reactions
     282 */
     283void WorldEntity::unsubscribeReaction()
     284{
     285  for( int i = 0; i < CREngine::CR_NUMBER; i++)
     286    this->unsubscribeReaction((CREngine::CRType)i);
     287}
     288
     289
     290/**
    265291 * registers a new collision to this world entity
    266292 *  @param collisionEvent the event
  • branches/cr/src/world_entities/world_entity.h

    r7945 r7946  
    7171  /* --- Collision Reaction Block --- */
    7272  void subscribeReaction(CREngine::CRType type, int nrOfTargets, long target, ...);
     73  void unsubscribeReaction(CREngine::CRType type);
     74  void unsubscribeReaction();
    7375  bool registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB);
    7476
Note: See TracChangeset for help on using the changeset viewer.