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/network
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/network/ConnectionManager.cc

    r1574 r1591  
    4444#include "core/CoreIncludes.h"
    4545#include "core/BaseObject.h"
     46#include "core/Iterator.h"
    4647#include "objects/SpaceShip.h"
    4748#include "util/Math.h"
     
    337338  bool ConnectionManager::removeShip(ClientInformation *client){
    338339    int id=client->getShipID();
    339     orxonox::Iterator<orxonox::SpaceShip> it;
     340    orxonox::ObjectList<orxonox::SpaceShip>::iterator it;
    340341    for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){
    341342      if(it->objectID!=id)
  • code/branches/core3/src/network/GameStateClient.cc

    r1574 r1591  
    3333#include "core/CoreIncludes.h"
    3434#include "core/BaseObject.h"
     35#include "core/Iterator.h"
    3536#include "Synchronisable.h"
    3637
     
    137138  * @return iterator pointing to the next object in the list
    138139  */
    139   void GameStateClient::removeObject(orxonox::Iterator<Synchronisable> &it) {
    140     orxonox::Iterator<Synchronisable> temp=it;
     140  void GameStateClient::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
     141    orxonox::ObjectList<Synchronisable>::iterator temp=it;
    141142    ++it;
    142143    delete  *temp;
     
    151152    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
    152153    // get the start of the Synchronisable list
    153     orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::begin();
     154    orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
    154155    syncData sync;
    155156    // loop as long as we have some data ;)
     
    222223    int tempsize=0;
    223224    // get the start of the Synchronisable list
    224     orxonox::Iterator<Synchronisable> it;
     225    orxonox::ObjectList<Synchronisable>::iterator it;
    225226    // struct for return value of Synchronisable::getData()
    226227    syncData sync;
  • code/branches/core3/src/network/GameStateClient.h

    r1505 r1591  
    4242
    4343#include <map>
    44 // 
     44//
    4545#include "NetworkPrereqs.h"
    4646#include "core/CorePrereqs.h"
     
    5858    GameStateClient();
    5959    ~GameStateClient();
    60    
     60
    6161    void addGameState(GameStateCompressed *gs);
    6262    int processGameState();
     
    7272    GameState *decode(GameState *old, GameStateCompressed *diff);
    7373    GameState *decode(GameStateCompressed *x);
    74     void removeObject(orxonox::Iterator<Synchronisable> &it);
     74    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
    7575    void printGameStateMap();
    7676    bool saveShipCache();
     
    8383    orxonox::SpaceShip *myShip_;
    8484    syncData shipCache_;
    85    
    86    
    87    
    88    
     85
     86
     87
     88
    8989  public:
    9090    //#### ADDED FOR TESTING PURPOSE ####
  • code/branches/core3/src/network/GameStateManager.cc

    r1574 r1591  
    4848#include "core/CoreIncludes.h"
    4949#include "core/BaseObject.h"
     50#include "core/Iterator.h"
    5051#include "ClientInformation.h"
    5152#include "Synchronisable.h"
     
    180181    int tempsize=0;
    181182    // get the start of the Synchronisable list
    182     orxonox::Iterator<Synchronisable> it;
     183    orxonox::ObjectList<Synchronisable>::iterator it;
    183184    // struct for return value of Synchronisable::getData()
    184185    syncData sync;
     
    246247    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
    247248    // get the start of the Synchronisable list
    248     orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::begin();
     249    orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
    249250    syncData sync;
    250251    /*ClientInformation *client = head_->findClient(clientID);
  • code/branches/core3/src/network/Server.cc

    r1574 r1591  
    5252#include "objects/SpaceShip.h"
    5353#include "core/ConsoleCommand.h"
     54#include "core/Iterator.h"
    5455
    5556namespace network
     
    400401
    401402    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
    402     orxonox::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
     403    orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
    403404    ClientInformation *client = clients->findClient(&event->peer->address);
    404405    if(!client)
     
    409410        continue;
    410411      }
    411       orxonox::Iterator<orxonox::SpaceShip> temp=it;
     412      orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it;
    412413      ++it;
    413414      delete  *temp;
  • code/branches/core3/src/network/Synchronisable.h

    r1534 r1591  
    8585    Synchronisable();
    8686  private:
    87     /*  bool removeObject(Iterator<Synchronisable> it);*/
     87    /*  bool removeObject(ObjectList<Synchronisable>::iterator it);*/
    8888
    8989    std::list<synchronisableVariable *> *syncList;
Note: See TracChangeset for help on using the changeset viewer.