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/worldentities
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/orxonox/objects/worldentities/Attacher.cc

    r3110 r3223  
    111111            return;
    112112
    113         WorldEntity* entity = dynamic_cast<WorldEntity*>(object);
     113        WorldEntity* entity = orxonox_cast<WorldEntity>(object);
    114114        if (entity && entity->getName() == this->targetname_)
    115115        {
  • code/branches/core4/src/orxonox/objects/worldentities/BigExplosion.cc

    r3196 r3223  
    9999        Identifier* idDE1 = Class(MovableEntity);
    100100        BaseObject* oDE1 = idDE1->fabricate(this);
    101         this->debrisEntity1_ = dynamic_cast<MovableEntity*>(oDE1);
     101        this->debrisEntity1_ = orxonox_cast<MovableEntity>(oDE1);
    102102
    103103        Identifier* idDE2 = Class(MovableEntity);
    104104        BaseObject* oDE2 = idDE2->fabricate(this);
    105         this->debrisEntity2_ = dynamic_cast<MovableEntity*>(oDE2);
     105        this->debrisEntity2_ = orxonox_cast<MovableEntity>(oDE2);
    106106
    107107        Identifier* idDE3 = Class(MovableEntity);
    108108        BaseObject* oDE3 = idDE3 ->fabricate(this);
    109         this->debrisEntity3_ = dynamic_cast<MovableEntity*>(oDE3);
     109        this->debrisEntity3_ = orxonox_cast<MovableEntity>(oDE3);
    110110
    111111        Identifier* idDE4 = Class(MovableEntity);
    112112        BaseObject* oDE4 = idDE4->fabricate(this);
    113         this->debrisEntity4_ = dynamic_cast<MovableEntity*>(oDE4);
     113        this->debrisEntity4_ = orxonox_cast<MovableEntity>(oDE4);
    114114
    115115        Identifier* idD1 = Class(Model);
    116116        BaseObject* oD1 = idD1->fabricate(this);
    117         this->debris1_ = dynamic_cast<Model*>(oD1);
     117        this->debris1_ = orxonox_cast<Model>(oD1);
    118118
    119119        Identifier* idD2 = Class(Model);
    120120        BaseObject* oD2 = idD2->fabricate(this);
    121         this->debris2_ = dynamic_cast<Model*>(oD2);
     121        this->debris2_ = orxonox_cast<Model>(oD2);
    122122
    123123        Identifier* idD3 = Class(Model);
    124124        BaseObject* oD3 = idD3->fabricate(this);
    125         this->debris3_ = dynamic_cast<Model*>(oD3);
     125        this->debris3_ = orxonox_cast<Model>(oD3);
    126126
    127127        Identifier* idD4 = Class(Model);
    128128        BaseObject* oD4 = idD4->fabricate(this);
    129         this->debris4_ = dynamic_cast<Model*>(oD4);
     129        this->debris4_ = orxonox_cast<Model>(oD4);
    130130
    131131        Identifier* id6 = Class(StaticEntity);
    132132        BaseObject* object4 = id6->fabricate(this);
    133         this->explosion_ = dynamic_cast<StaticEntity*>(object4);
     133        this->explosion_ = orxonox_cast<StaticEntity>(object4);
    134134
    135135        this->debrisSmoke1_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
     
    202202            Identifier* idf1 = Class(Model);
    203203            BaseObject* obj1 = idf1->fabricate(this);
    204             Model* part1 = dynamic_cast<Model*>(obj1);
     204            Model* part1 = orxonox_cast<Model>(obj1);
    205205
    206206
    207207            Identifier* idf2 = Class(Model);
    208208            BaseObject* obj2 = idf2->fabricate(this);
    209             Model* part2 = dynamic_cast<Model*>(obj2);
     209            Model* part2 = orxonox_cast<Model>(obj2);
    210210
    211211            Identifier* idf3 = Class(MovableEntity);
    212212            BaseObject* obj3 = idf3->fabricate(this);
    213             MovableEntity* partEntity1 = dynamic_cast<MovableEntity*>(obj3);
     213            MovableEntity* partEntity1 = orxonox_cast<MovableEntity>(obj3);
    214214
    215215            Identifier* idf4 = Class(MovableEntity);
    216216            BaseObject* obj4 = idf4->fabricate(this);
    217             MovableEntity* partEntity2 = dynamic_cast<MovableEntity*>(obj4);
     217            MovableEntity* partEntity2 = orxonox_cast<MovableEntity>(obj4);
    218218
    219219            partEntity1->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10,100));
  • code/branches/core4/src/orxonox/objects/worldentities/ControllableEntity.cc

    r3196 r3223  
    267267        if (this->playerID_ != OBJECTID_UNKNOWN)
    268268        {
    269             this->player_ = dynamic_cast<PlayerInfo*>(Synchronisable::getSynchronisable(this->playerID_));
     269            this->player_ = orxonox_cast<PlayerInfo>(Synchronisable::getSynchronisable(this->playerID_));
    270270            if (this->player_ && (this->player_->getControllableEntity() != this))
    271271                this->player_->startControl(this);
  • code/branches/core4/src/orxonox/objects/worldentities/MovableEntity.cc

    r3196 r3223  
    7676        if (GameMode::isMaster() && enableCollisionDamage_)
    7777        {
    78             Pawn* victim = dynamic_cast<Pawn*>(otherObject);
     78            Pawn* victim = orxonox_cast<Pawn>(otherObject);
    7979            if (victim)
    8080            {
  • code/branches/core4/src/orxonox/objects/worldentities/PongBall.cc

    r3196 r3223  
    231231            this->bat_ = new PongBat*[2];
    232232        if (this->batID_[0] != OBJECTID_UNKNOWN)
    233             this->bat_[0] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[0]));
     233            this->bat_[0] = orxonox_cast<PongBat>(Synchronisable::getSynchronisable(this->batID_[0]));
    234234        if (this->batID_[1] != OBJECTID_UNKNOWN)
    235             this->bat_[1] = dynamic_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1]));
     235            this->bat_[1] = orxonox_cast<PongBat>(Synchronisable::getSynchronisable(this->batID_[1]));
    236236    }
    237237}
  • code/branches/core4/src/orxonox/objects/worldentities/PongCenterpoint.cc

    r3110 r3223  
    7373        if (this->getGametype() && this->getGametype()->isA(Class(Pong)))
    7474        {
    75             Pong* pong_gametype = dynamic_cast<Pong*>(this->getGametype());
     75            Pong* pong_gametype = orxonox_cast<Pong>(this->getGametype());
    7676            pong_gametype->setCenterpoint(this);
    7777        }
  • code/branches/core4/src/orxonox/objects/worldentities/WorldEntity.cc

    r3196 r3223  
    210210        if (this->parentID_ != OBJECTID_UNKNOWN)
    211211        {
    212             WorldEntity* parent = dynamic_cast<WorldEntity*>(Synchronisable::getSynchronisable(this->parentID_));
     212            WorldEntity* parent = orxonox_cast<WorldEntity>(Synchronisable::getSynchronisable(this->parentID_));
    213213            if (parent)
    214214                this->attachToParent(parent);
  • code/branches/core4/src/orxonox/objects/worldentities/pawns/Destroyer.cc

    r3110 r3223  
    4040        RegisterObject(Destroyer);
    4141
    42         UnderAttack* gametype = dynamic_cast<UnderAttack*>(this->getGametype());
     42        UnderAttack* gametype = orxonox_cast<UnderAttack>(this->getGametype());
    4343        if (gametype)
    4444        {
  • code/branches/core4/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r3196 r3223  
    198198                {
    199199                    BaseObject* object = identifier->fabricate(this);
    200                     this->engine_ = dynamic_cast<Engine*>(object);
     200                    this->engine_ = orxonox_cast<Engine>(object);
    201201
    202202                    if (this->engine_)
  • code/branches/core4/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc

    r3196 r3223  
    4545        this->state_ = BaseState::uncontrolled;
    4646
    47         TeamBaseMatch* gametype = dynamic_cast<TeamBaseMatch*>(this->getGametype());
     47        TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch>(this->getGametype());
    4848        if (gametype)
    4949        {
     
    5858        this->fireEvent();
    5959
    60         TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype());
     60        TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch>(this->getGametype());
    6161        if (!gametype)
    6262            return;
     
    8484            if ((*it)->isA(Class(TeamColourable)))
    8585            {
    86                 TeamColourable* tc = dynamic_cast<TeamColourable*>(*it);
     86                TeamColourable* tc = orxonox_cast<TeamColourable>(*it);
    8787                tc->setTeamColour(colour);
    8888            }
  • code/branches/core4/src/orxonox/objects/worldentities/triggers/CheckPoint.cc

    r3196 r3223  
    8585        DistanceTrigger::triggered(bIsTriggered);
    8686
    87         Asteroids* gametype = dynamic_cast<Asteroids*>(this->getGametype());
     87        Asteroids* gametype = orxonox_cast<Asteroids>(this->getGametype());
    8888        if (gametype)
    8989        {
  • code/branches/core4/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    r3196 r3223  
    120120    for (ClassTreeMaskObjectIterator it = this->targetMask_.begin(); it != this->targetMask_.end(); ++it)
    121121    {
    122       WorldEntity* entity = dynamic_cast<WorldEntity*>(*it);
     122      WorldEntity* entity = orxonox_cast<WorldEntity>(*it);
    123123      if (!entity)
    124124        continue;
     
    131131        if(this->isForPlayer())
    132132        {
    133           Pawn* player = dynamic_cast<Pawn*>(entity);
     133          Pawn* player = orxonox_cast<Pawn>(entity);
    134134          this->setTriggeringPlayer(player);
    135135        }
Note: See TracChangeset for help on using the changeset viewer.