Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 12, 2008, 2:00:15 AM (16 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/ObjectList.h

    r1574 r1591  
    4141
    4242#include "Identifier.h"
    43 #include "Iterator.h"
     43#include "ObjectListIterator.h"
    4444
    4545namespace orxonox
     
    5151    /**
    5252        Wraps the ObjectListBase of the corresponding Identifier.
    53         Use Iterator<class> to iterate through all objects in the list.
     53        Use ObjectListIterator<class> to iterate through all objects in the list.
    5454    */
    5555    template <class T>
     
    5757    {
    5858        public:
     59            typedef ObjectListIterator<T> iterator;
     60
    5961            /** @brief Returns an Iterator to the first element in the list. @return The Iterator */
    60             inline static Iterator<T> begin()
    61                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->begin()); }
     62            inline static ObjectListElement<T>* begin()
     63                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->begin().element_); }
    6264
    6365            /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */
    64             inline static Iterator<T> end()
    65                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->end()); }
     66            inline static ObjectListElement<T>* end()
     67                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->end().element_); }
    6668
    6769            /** @brief Returns an Iterator to the last element in the list. @return The Iterator */
    68             inline static Iterator<T> rbegin()
    69                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin()); }
     70            inline static ObjectListElement<T>* rbegin()
     71                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin().element_); }
    7072
    7173            /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */
    72             inline static Iterator<T> rend()
    73                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->rend()); }
     74            inline static ObjectListElement<T>* rend()
     75                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rend().element_); }
    7476    };
    7577}
Note: See TracChangeset for help on using the changeset viewer.