Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 12, 2008, 2:00:15 AM (17 years ago)
Author:
landauf
Message:

Again some heavy changes in ObjectList and Iterator:
there are now two types of iterators:

Iterator<ClassName> can iterate through any objectlist, either given by ObjectList<AnyClassName>::begin() or anyidentifier→getObjects()→begin(). Important note Iterator<ClassName> uses dynamic_cast.
And yes, it's possible to do this: Iterator<WorldEntity> it = ObjectList<SpaceShip>::begin()

ObjectList<ClassName>::iterator is the second iterator - it uses the ObjectList in a templated manner and therefore doesn't need dynamic_cast. But the only thing you can do is iterating through exactly the right ObjectList: ObjectList<ClassName>::iterator it = ObjectList<ClassName>::begin(). Anything else fails.

Those changes bring, at my system, something around +12% FPS compared with trunk and +25% FPS compared with the last revision of core3. Although I have to admit the FPS gain is only that high because iterating through objects is the main thing we're doing ingame right now. It would look totally different with physics, sound, AI, scripts, triggers and so on.

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

Legend:

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

    r1586 r1591  
    4747#include "core/CoreIncludes.h"
    4848#include "core/ConfigValueIncludes.h"
     49#include "core/Iterator.h"
    4950#include "core/CommandExecutor.h"
    5051#include "core/ConsoleCommand.h"
     
    100101
    101102    if (this->detailLevelParticle_ != old)
    102       for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
     103      for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    103104        it->detailLevelChanged(this->detailLevelParticle_);
    104105  }
  • code/branches/core3/src/orxonox/Orxonox.cc

    r1586 r1591  
    5454// core
    5555#include "core/ConfigFileManager.h"
     56#include "core/Iterator.h"
    5657#include "core/ConsoleCommand.h"
    5758#include "core/Loader.h"
     
    7576#include "GraphicsEngine.h"
    7677#include "Settings.h"
     78
    7779
    7880// FIXME: is this really file scope?
     
    169171    Orxonox::getSingleton()->timefactor_ = factor;
    170172
    171     for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it)
     173    for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    172174        it->setSpeedFactor(it->getSpeedFactor() * change);
    173175  }
     
    462464      Core::tick((float)evt.timeSinceLastFrame);
    463465      // Call those objects that need the real time
    464       for (Iterator<TickableReal> it = ObjectList<TickableReal>::begin(); it; ++it)
     466      for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it)
    465467        it->tick((float)evt.timeSinceLastFrame);
    466468      // Call the scene objects
    467       for (Iterator<Tickable> it = ObjectList<Tickable>::begin(); it; ++it)
     469      for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    468470        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    469471      //AudioManager::tick();
  • code/branches/core3/src/orxonox/objects/NPC.cc

    r1574 r1591  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/Iterator.h"
    3334
    3435namespace orxonox {
     
    117118    int numberOfNeighbour = 0;  //number of observed neighbours
    118119    float distance = 0;  // distance to the actual element
    119     for(Iterator<WorldEntity> it = ObjectList<WorldEntity>::begin(); it; ++it) {  //go through all elements
     120    for(ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it; ++it) {  //go through all elements
    120121      distance = getDistance(*it);  //get distance between this and actual
    121122      if ((distance > 0) && (distance < SEPERATIONDISTANCE)) {  //do only if actual is inside detectionradius
     
    144145    //float distance = 0;
    145146    //go through all elements
    146     for(Iterator<NPC> it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
     147    for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
    147148      float distance = getDistance(*it);  //get distance between this and actual
    148149      if ((distance > 0) && (distance < ALIGNMENTDISTANCE)) {  //check if actual element is inside detectionradius
     
    164165    //float distance = 0;
    165166    //go through all elements
    166     for(Iterator<NPC> it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
     167    for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
    167168      float distance = getDistance(*it);  //get distance between this and actual
    168169      if ((distance > 0) && (distance < COHESIONDISTANCE)) {  //check if actual element is inside detectionradius
  • code/branches/core3/src/orxonox/objects/Projectile.cc

    r1584 r1591  
    3535#include "core/Executor.h"
    3636#include "core/ConfigValueIncludes.h"
     37#include "core/Iterator.h"
    3738#include "tools/ParticleInterface.h"
    3839
     
    8788
    8889        float radius;
    89         for (Iterator<Model> it = ObjectList<Model>::begin(); it; ++it)
     90        for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it)
    9091        {
    9192            if ((*it) != this->owner_)
  • code/branches/core3/src/orxonox/objects/SpaceShip.cc

    r1586 r1591  
    4141#include "core/CoreIncludes.h"
    4242#include "core/ConfigValueIncludes.h"
     43#include "core/Iterator.h"
    4344#include "core/input/InputManager.h"
    4445#include "core/XMLPort.h"
     
    7172
    7273    SpaceShip *SpaceShip::getLocalShip(){
    73       Iterator<SpaceShip> it;
     74      ObjectList<SpaceShip>::iterator it;
    7475      for(it = ObjectList<SpaceShip>::begin(); it; ++it){
    7576        if( (it)->myShip_ )
  • code/branches/core3/src/orxonox/objects/SpaceShipAI.cc

    r1566 r1591  
    7272    SpaceShipAI::~SpaceShipAI()
    7373    {
    74         for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; ++it)
     74        for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; ++it)
    7575            it->shipDied(this);
    7676    }
     
    111111    {
    112112        int i = 0;
    113         for (Iterator<SpaceShipAI> it = ObjectList<SpaceShipAI>::begin(); it; )
     113        for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; )
    114114        {
    115115            (it++)->kill();
     
    259259        this->forgetTarget();
    260260
    261         for (Iterator<SpaceShip> it = ObjectList<SpaceShip>::begin(); it; ++it)
     261        for (ObjectList<SpaceShip>::iterator it = ObjectList<SpaceShip>::begin(); it; ++it)
    262262        {
    263263            if (it->getTeamNr() != this->getTeamNr())
Note: See TracChangeset for help on using the changeset viewer.