Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7967 in orxonox.OLD for branches/cr/src/lib/collision_reaction


Ignore:
Timestamp:
May 30, 2006, 1:22:05 AM (19 years ago)
Author:
patrick
Message:

cr: more memory handling now

Location:
branches/cr/src/lib/collision_reaction
Files:
3 edited

Legend:

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

    r7966 r7967  
    7474/**
    7575 * registers a new Collision Object
     76 * if a there is already a collision object with the same stats
     77 * registration will be skipped and the last collision object is returned
    7678 */
    7779Collision* CollisionHandle::registerCollision(WorldEntity* entityA, WorldEntity* entityB)
    7880{
    79   // get the new collision object
    80   Collision* c = CREngine::getInstance()->popCollisionObject();
     81  //first get the collision object, multiple sources
     82  Collision* c;
     83  if( this->collisionList.empty() ||
     84      ((this->collisionList.back())->getEntityA() != entityA && (this->collisionList.back())->getEntityB() != entityB ))
     85    c = CREngine::getInstance()->popCollisionObject();
     86  else
     87    c = this->collisionList.back();
    8188
    82   c->collide(collisionEvent->getEntityA(), collisionEvent->getEntityB());
     89  c->collide(entityA, entityB);
    8390  this->collisionList.push_back(c);
     91
     92  return c;
    8493}
    8594
     
    92101{
    93102  // first element only
    94   if( this->collisionList.empty())
    95   {
    96     return;
    97   }
    98 
    99   if( ((this->collisionList.back())->getEntityA() == collisionEvent->getEntityA()) &&
    100         ((this->collisionList.back())->getEntityB() == collisionEvent->getEntityB()))
    101   {
    102     (this->collisionList.back())->registerCollisionEvent(collisionEvent);
    103   }
     103 Collision* c = this->registerCollision(collisionEvent->getEntityA(), collisionEvent->getEntityB());
     104 c->registerCollisionEvent(collisionEvent);
    104105}
    105106
  • branches/cr/src/lib/collision_reaction/collision_handle.h

    r7966 r7967  
    2929
    3030    void addTarget(long classID);
    31     Collision registerCollision(WorldEntity* entityA, WorldEntity* entityB);
     31    Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB);
    3232    void registerCollisionEvent(CollisionEvent* collisionEvent);
    3333    /** @returns true if regiestered some new collision events in this tick frame */
  • branches/cr/src/lib/collision_reaction/cr_engine.cc

    r7966 r7967  
    149149}
    150150
     151
    151152/**
    152153 * flushes all the collision lists and puts them to their initial state
    153154 */
    154 void CREngeine::flushCollisions()
     155void CREngine::flushCollisions()
    155156{
     157  vector<Collision*>::iterator it = this->collisionsUsed.begin();
     158  for(; it < this->collisionsUsed.end(); it++)
     159    this->collisionsUnused.push_back(*it);
    156160
     161  this->collisionsUsed.clear();
    157162}
    158163
Note: See TracChangeset for help on using the changeset viewer.