Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 7:28:48 PM (15 years ago)
Author:
rgrieder
Message:

Add a new core-feature: orxonox_cast<T>()
The functions casts objects like dynamic_cast, but uses the identifier instead for MSVC (much faster) and is just a redirection to dynamic_cast for GCC.
Also replaced almost all dynamic_casts (of course only those related to the class hierarchy).

Location:
code/branches/core4/src/orxonox/objects/pickup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/orxonox/objects/pickup/PickupCollection.cc

    r3196 r3223  
    6666            Identifier* ident = Class(UsableItem);
    6767            if(this->currentUsable_ == NULL && item->isA(ident))
    68                 this->currentUsable_ = dynamic_cast<UsableItem*>(item);
     68                this->currentUsable_ = orxonox_cast<UsableItem>(item);
    6969
    7070            this->items_.insert( std::pair<std::string, BaseItem*> (item->getPickupIdentifier(), item) );
     
    336336        {
    337337            if ((*it).second->isA(ident))
    338                 ret.push_back(dynamic_cast<EquipmentItem*>((*it).second));
     338                ret.push_back(orxonox_cast<EquipmentItem>((*it).second));
    339339        }
    340340
     
    353353        {
    354354            if ((*it).second->isA(ident))
    355                 ret.push_back(dynamic_cast<PassiveItem*>((*it).second));
     355                ret.push_back(orxonox_cast<PassiveItem>((*it).second));
    356356        }
    357357
     
    370370        {
    371371            if ((*it).second->isA(ident))
    372                 ret.push_back(dynamic_cast<UsableItem*>((*it).second));
     372                ret.push_back(orxonox_cast<UsableItem>((*it).second));
    373373        }
    374374
  • code/branches/core4/src/orxonox/objects/pickup/PickupSpawner.cc

    r3196 r3223  
    8686        //  = less delays while running
    8787        BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this);
    88         BaseItem* asItem = dynamic_cast<BaseItem*>(newObject);
     88        BaseItem* asItem = orxonox_cast<BaseItem>(newObject);
    8989        if (asItem)
    9090        {
     
    154154        {
    155155            BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this);
    156             BaseItem* asItem = dynamic_cast<BaseItem*>(newObject);
     156            BaseItem* asItem = orxonox_cast<BaseItem>(newObject);
    157157            if (asItem)
    158158            {
Note: See TracChangeset for help on using the changeset viewer.