Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2008, 4:35:38 AM (16 years ago)
Author:
landauf
Message:

big change in ObjectList: separated the class into a non-template base and a template wrapper for the base. this also changes the Iterator, there is now a non-template IteratorBase. this brings much more flexibility, like iterating through all objects of a given identifier without knowing the type. however this needs a dynamic_cast, which isn't quite optimal, but I think there are much worser things than that out there. ;)

there isn't much you have to know about this, except there is no more ObjectList<myClass>::start() function but a ObjectList<myClass>::begin() to be more STLish. another thing: ObjectList<myClass>::end() points now to the element _after_ the last element, so it's possible to iterate in a for-loop until (it != ObjectList<myClass>::end()). the reason is the same as above. however, (it) as a boolean still works perfectly fine.

Location:
code/branches/core3/src/orxonox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/orxonox/Orxonox.cc

    r1567 r1574  
    462462      Core::tick((float)evt.timeSinceLastFrame);
    463463      // Call those objects that need the real time
    464       for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     464      for (Iterator<TickableReal> it = ObjectList<TickableReal>::begin(); it; ++it)
    465465        it->tick((float)evt.timeSinceLastFrame);
    466466      // Call the scene objects
    467       for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
     467      for (Iterator<Tickable> it = ObjectList<Tickable>::begin(); it; ++it)
    468468        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    469469      //AudioManager::tick();
  • code/branches/core3/src/orxonox/objects/NPC.cc

    r1505 r1574  
    6161    movable_ = movable;
    6262  }
    63  
     63
    6464  void NPC::registerAllVariables(){
    6565    Model::registerAllVariables();
    6666    registerVar(&movable_, sizeof(movable_), network::DATA);
    6767  }
    68  
     68
    6969
    7070  /**
     
    117117    int numberOfNeighbour = 0;  //number of observed neighbours
    118118    float distance = 0;  // distance to the actual element
    119     for(Iterator<WorldEntity> it = ObjectList<WorldEntity>::start(); it; ++it) {  //go through all elements
     119    for(Iterator<WorldEntity> it = ObjectList<WorldEntity>::begin(); it; ++it) {  //go through all elements
    120120      distance = getDistance(*it);  //get distance between this and actual
    121121      if ((distance > 0) && (distance < SEPERATIONDISTANCE)) {  //do only if actual is inside detectionradius
     
    144144    //float distance = 0;
    145145    //go through all elements
    146     for(Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it) {  //just working with 3 elements at the moment
     146    for(Iterator<NPC> it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
    147147      float distance = getDistance(*it);  //get distance between this and actual
    148148      if ((distance > 0) && (distance < ALIGNMENTDISTANCE)) {  //check if actual element is inside detectionradius
     
    164164    //float distance = 0;
    165165    //go through all elements
    166     for(Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it) {  //just working with 3 elements at the moment
     166    for(Iterator<NPC> it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
    167167      float distance = getDistance(*it);  //get distance between this and actual
    168168      if ((distance > 0) && (distance < COHESIONDISTANCE)) {  //check if actual element is inside detectionradius
  • code/branches/core3/src/orxonox/objects/Projectile.cc

    r1563 r1574  
    8686
    8787        float radius;
    88         for (Iterator<Model> it = ObjectList<Model>::start(); it; ++it)
     88        for (Iterator<Model> it = ObjectList<Model>::begin(); it; ++it)
    8989        {
    9090            if ((*it) != this->owner_)
  • code/branches/core3/src/orxonox/objects/SpaceShip.cc

    r1564 r1574  
    7272    SpaceShip *SpaceShip::getLocalShip(){
    7373      Iterator<SpaceShip> it;
    74       for(it = ObjectList<SpaceShip>::start(); it; ++it){
     74      for(it = ObjectList<SpaceShip>::begin(); it; ++it){
    7575        if( (it)->myShip_ )
    7676          return *it;
Note: See TracChangeset for help on using the changeset viewer.