Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3223


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
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/core/EventIncludes.h

    r3196 r3223  
    5454        this->addEventContainer(eventname, containername); \
    5555    } \
    56     event.castedOriginator_ = dynamic_cast<subclassname*>(event.originator_); \
     56    event.castedOriginator_ = orxonox::orxonox_cast<subclassname>(event.originator_); \
    5757    containername->process(this, event)
    5858
     
    6666        this->addEventContainer(eventname, containername); \
    6767    } \
    68     event.castedOriginator_ = dynamic_cast<subclassname*>(event.originator_); \
     68    event.castedOriginator_ = orxonox::orxonox_cast<subclassname>(event.originator_); \
    6969    containername->process(this, event)
    7070
  • code/branches/core4/src/core/Identifier.cc

    r3196 r3223  
    4747    // ###       Identifier        ###
    4848    // ###############################
    49     int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero (this static member variable is ok: it's used in main(), not before)
     49    int Identifier::hierarchyCreatingCounter_s = 0;
     50    unsigned int Identifier::classIDCounter_s = 0;
    5051
    5152    /**
     
    5354    */
    5455    Identifier::Identifier()
     56        : classID_(classIDCounter_s++)
    5557    {
    5658        this->objects_ = new ObjectListBase(this);
     
    6769        this->directChildren_ = new std::set<const Identifier*>();
    6870
    69         // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables
    70         static unsigned int classIDcounter_s = 0;
    71         this->classID_ = classIDcounter_s++;
     71        // Default network ID is the class ID
     72        this->networkID_ = this->classID_;
    7273    }
    7374
     
    244245    void Identifier::setNetworkID(uint32_t id)
    245246    {
    246         Factory::changeNetworkID(this, this->classID_, id);
    247         this->classID_ = id;
     247        Factory::changeNetworkID(this, this->networkID_, id);
     248        this->networkID_ = id;
    248249    }
    249250
  • code/branches/core4/src/core/Identifier.h

    r3196 r3223  
    224224
    225225            /** @brief Returns the network ID to identify a class through the network. @return the network ID */
    226             inline const uint32_t getNetworkID() const { return this->classID_; }
     226            inline const uint32_t getNetworkID() const { return this->networkID_; }
    227227
    228228            /** @brief Sets the network ID to a new value. @param id The new value */
    229229            void setNetworkID(uint32_t id);
     230
     231            /** @brief Returns the unique ID of the class */
     232            FORCEINLINE unsigned int getClassID() const { return this->classID_; }
    230233
    231234            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
     
    305308            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
    306309            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
    307             uint32_t classID_;                                             //!< The network ID to identify a class through the network
     310            uint32_t networkID_;                                           //!< The network ID to identify a class through the network
     311            const unsigned int classID_;                                   //!< Uniquely identifies a class (might not be the same as the networkID_)
     312            static unsigned int classIDCounter_s;                          //!< Static counter for the unique classIDs
    308313
    309314            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
     
    427432        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    428433        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
     434        // Add pointer of type T to the map in the OrxonoxClass instance that enables "dynamic_casts"
     435        object->objectPointers_.push_back(std::make_pair(this->getClassID(), reinterpret_cast<void*>(object)));
    429436    }
    430437
     
    444451            for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
    445452                (*it)->updateConfigValues(false);
     453    }
     454
     455
     456    // ###############################
     457    // ###      orxonox_cast       ###
     458    // ###############################
     459    /**
     460    @brief
     461        Casts on object of type OrxonoxClass to any derived type that is
     462        registered in the class hierarchy.
     463    @return
     464        Returns NULL if the cast is not possible
     465    @note
     466        In case of NULL return (and using MSVC), a dynamic_cast might still be possible if
     467        a class forgot to register its objects.
     468        Also note that the function is implemented differently for GCC/MSVC.
     469    */
     470    template <class T, class U>
     471    FORCEINLINE T* orxonox_cast(U* source)
     472    {
     473#ifdef ORXONOX_COMPILER_MSVC
     474        return source->template getDerivedPointer<T>(ClassIdentifier<T>::getIdentifier()->getClassID());
     475#else
     476        return dynamic_cast<T*>(source);
     477#endif
    446478    }
    447479
     
    539571                if (newObject)
    540572                {
    541                     return dynamic_cast<T*>(newObject);
     573                    return orxonox_cast<T>(newObject);
    542574                }
    543575                else
  • code/branches/core4/src/core/Iterator.h

    r3196 r3223  
    240240            {
    241241                if (this->element_)
    242                     return dynamic_cast<T*>(this->element_->objectBase_);
     242                    return orxonox_cast<T>(this->element_->objectBase_);
    243243                else
    244244                    return 0;
     
    252252            {
    253253                if (this->element_)
    254                     return dynamic_cast<T*>(this->element_->objectBase_);
     254                    return orxonox_cast<T>(this->element_->objectBase_);
    255255                else
    256256                    return 0;
  • code/branches/core4/src/core/OrxonoxClass.h

    r3196 r3223  
    5050    class _CoreExport OrxonoxClass
    5151    {
     52        template <class T>
     53        friend class ClassIdentifier;
     54
    5255        public:
    5356            OrxonoxClass();
     
    101104            bool isDirectParentOf(const OrxonoxClass* object);
    102105
     106            /**
     107            @brief
     108                Returns a valid pointer of any derived type that is
     109                registered in the class hierarchy.
     110            @return
     111                Returns NULL if the no pointer was found.
     112            */
     113            template <class T>
     114            FORCEINLINE T* getDerivedPointer(unsigned int classID) const
     115            {
     116                for (int i = this->objectPointers_.size() - 1; i >= 0; --i)
     117                {
     118                    if (this->objectPointers_[i].first == classID)
     119                        return reinterpret_cast<T*>(this->objectPointers_[i].second);
     120                }
     121                return NULL;
     122            }
     123
    103124        private:
    104125            Identifier* identifier_;                   //!< The Identifier of the object
    105126            std::set<const Identifier*>* parents_;     //!< List of all parents of the object
    106127            MetaObjectList* metaList_;                 //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
     128            //! 'Fast map' that holds this-pointers of all derived types
     129            std::vector<std::pair<unsigned int, void*> > objectPointers_;
    107130    };
    108131}
  • code/branches/core4/src/core/XMLPort.h

    r3196 r3223  
    565565                                                    newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
    566566
    567                                                     O* castedObject = dynamic_cast<O*>(newObject);
     567                                                    O* castedObject = orxonox_cast<O>(newObject);
    568568                                                    assert(castedObject);
    569569
  • code/branches/core4/src/network/NetworkFunction.h

    r3214 r3223  
    150150    {
    151151      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    152         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)));
     152        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)));
    153153    }
    154154    inline void call(uint32_t objectID, const MultiType& mt1)
    155155    {
    156156      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    157         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1);
     157        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1);
    158158    }
    159159    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
    160160    {
    161161      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    162         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
     162        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
    163163    }
    164164    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    165165    {
    166166      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    167         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
     167        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
    168168    }
    169169    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    170170    {
    171171      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    172         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
     172        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
    173173    }
    174174    inline void call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    175175    {
    176176      if ( Synchronisable::getSynchronisable(objectID)!=0 )
    177         (*this->functor_)(dynamic_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
     177        (*this->functor_)(orxonox_cast<T>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
    178178    }
    179179   
  • code/branches/core4/src/network/synchronisable/Synchronisable.cc

    r3214 r3223  
    7373    if (creator)
    7474    {
    75         Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
     75        Synchronisable* synchronisable_creator = orxonox_cast<Synchronisable>(creator);
    7676        if (synchronisable_creator && synchronisable_creator->objectMode_)
    7777        {
     
    161161      }
    162162      else
    163         creator = dynamic_cast<BaseObject*>(synchronisable_creator);
     163        creator = orxonox_cast<BaseObject>(synchronisable_creator);
    164164    }
    165165    assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
    166166    BaseObject *bo = id->fabricate(creator);
    167167    assert(bo);
    168     Synchronisable *no = dynamic_cast<Synchronisable *>(bo);
     168    Synchronisable *no = orxonox_cast<Synchronisable>(bo);
    169169    assert(no);
    170170    no->objectID=header.getObjectID();
  • code/branches/core4/src/orxonox/objects/Level.cc

    r3196 r3223  
    121121std::cout << "Load Gametype: " << this->gametype_ << std::endl;
    122122
    123         Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
     123        Gametype* rootgametype = orxonox_cast<Gametype>(identifier->fabricate(this));
    124124        this->setGametype(rootgametype);
    125125
  • code/branches/core4/src/orxonox/objects/Scene.cc

    r3196 r3223  
    326326        // get the WorldEntity pointers
    327327        WorldEntity* object0 = (WorldEntity*)colObj0->getUserPointer();
    328         assert(dynamic_cast<WorldEntity*>(object0));
     328        assert(orxonox_cast<WorldEntity>(object0));
    329329        WorldEntity* object1 = (WorldEntity*)colObj1->getUserPointer();
    330         assert(dynamic_cast<WorldEntity*>(object1));
     330        assert(orxonox_cast<WorldEntity>(object1));
    331331
    332332        // false means that bullet will assume we didn't modify the contact
  • code/branches/core4/src/orxonox/objects/collisionshapes/CollisionShape.cc

    r3196 r3223  
    8585        // Parent can either be a WorldEntity or a CompoundCollisionShape. The reason is that the
    8686        // internal collision shape (which is compound) of a WE doesn't get synchronised.
    87         CompoundCollisionShape* parentCCS = dynamic_cast<CompoundCollisionShape*>(parent);
     87        CompoundCollisionShape* parentCCS = orxonox_cast<CompoundCollisionShape>(parent);
    8888        if (parentCCS)
    8989            parentCCS->attach(this);
    9090        else
    9191        {
    92             WorldEntity* parentWE = dynamic_cast<WorldEntity*>(parent);
     92            WorldEntity* parentWE = orxonox_cast<WorldEntity>(parent);
    9393            if (parentWE)
    9494                parentWE->attachCollisionShape(this);
     
    103103        this->parent_ = newParent;
    104104
    105         WorldEntityCollisionShape* parentWECCS = dynamic_cast<WorldEntityCollisionShape*>(newParent);
     105        WorldEntityCollisionShape* parentWECCS = orxonox_cast<WorldEntityCollisionShape>(newParent);
    106106        if (parentWECCS)
    107107            this->parentID_ = parentWECCS->getWorldEntityOwner()->getObjectID();
  • code/branches/core4/src/orxonox/objects/controllers/ArtificialController.cc

    r3196 r3223  
    181181        if (entity1->getXMLController())
    182182        {
    183             WaypointPatrolController* wpc = dynamic_cast<WaypointPatrolController*>(entity1->getXMLController());
     183            WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController>(entity1->getXMLController());
    184184            if (wpc)
    185185                team1 = wpc->getTeam();
     
    187187        if (entity2->getXMLController())
    188188        {
    189             WaypointPatrolController* wpc = dynamic_cast<WaypointPatrolController*>(entity2->getXMLController());
     189            WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController>(entity2->getXMLController());
    190190            if (wpc)
    191191                team2 = wpc->getTeam();
    192192        }
    193193
    194         TeamDeathmatch* tdm = dynamic_cast<TeamDeathmatch*>(gametype);
     194        TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch>(gametype);
    195195        if (tdm)
    196196        {
     
    203203
    204204        TeamBaseMatchBase* base = 0;
    205         base = dynamic_cast<TeamBaseMatchBase*>(entity1);
     205        base = orxonox_cast<TeamBaseMatchBase>(entity1);
    206206        if (base)
    207207        {
     
    219219            }
    220220        }
    221         base = dynamic_cast<TeamBaseMatchBase*>(entity2);
     221        base = orxonox_cast<TeamBaseMatchBase>(entity2);
    222222        if (base)
    223223        {
  • code/branches/core4/src/orxonox/objects/controllers/HumanController.cc

    r3196 r3223  
    161161        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    162162        {
    163             Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
     163            Pawn* pawn = orxonox_cast<Pawn>(HumanController::localController_s->controllableEntity_);
    164164            if (pawn)
    165165                pawn->kill();
     
    196196    {
    197197        if (HumanController::localController_s)
    198             return dynamic_cast<Pawn*>(HumanController::localController_s->getControllableEntity());
     198            return orxonox_cast<Pawn>(HumanController::localController_s->getControllableEntity());
    199199        else
    200200            return NULL;
  • code/branches/core4/src/orxonox/objects/gametypes/Pong.cc

    r3196 r3223  
    144144        if (player && player->getController() && player->getController()->isA(Class(PongAI)))
    145145        {
    146             PongAI* ai = dynamic_cast<PongAI*>(player->getController());
     146            PongAI* ai = orxonox_cast<PongAI>(player->getController());
    147147            ai->setPongBall(this->ball_);
    148148        }
  • code/branches/core4/src/orxonox/objects/gametypes/TeamBaseMatch.cc

    r3196 r3223  
    5454    bool TeamBaseMatch::allowPawnDeath(Pawn* victim, Pawn* originator)
    5555    {
    56         TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim);
     56        TeamBaseMatchBase* base = orxonox_cast<TeamBaseMatchBase>(victim);
    5757        if (base)
    5858        {
     
    8787    bool TeamBaseMatch::allowPawnDamage(Pawn* victim, Pawn* originator)
    8888    {
    89         TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim);
     89        TeamBaseMatchBase* base = orxonox_cast<TeamBaseMatchBase>(victim);
    9090        if (base)
    9191        {
  • code/branches/core4/src/orxonox/objects/gametypes/TeamDeathmatch.cc

    r3196 r3223  
    126126            if ((*it)->isA(Class(TeamSpawnPoint)))
    127127            {
    128                 TeamSpawnPoint* tsp = dynamic_cast<TeamSpawnPoint*>(*it);
     128                TeamSpawnPoint* tsp = orxonox_cast<TeamSpawnPoint>(*it);
    129129                if (tsp && (int)tsp->getTeamNumber() != desiredTeamNr)
    130130                {
     
    171171                    if ((*it)->isA(Class(TeamColourable)))
    172172                    {
    173                         TeamColourable* tc = dynamic_cast<TeamColourable*>(*it);
     173                        TeamColourable* tc = orxonox_cast<TeamColourable>(*it);
    174174                        tc->setTeamColour(this->teamcolours_[it_player->second]);
    175175                    }
  • code/branches/core4/src/orxonox/objects/infos/PlayerInfo.cc

    r3196 r3223  
    186186        {
    187187            Synchronisable* temp = Synchronisable::getSynchronisable(this->controllableEntityID_);
    188             ControllableEntity* entity = dynamic_cast<ControllableEntity*>(temp);
     188            ControllableEntity* entity = orxonox_cast<ControllableEntity>(temp);
    189189            this->startControl(entity);
    190190        }
     
    199199        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
    200200        {
    201             this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
     201            this->gtinfo_ = orxonox_cast<GametypeInfo>(Synchronisable::getSynchronisable(this->gtinfoID_));
    202202
    203203            if (!this->gtinfo_)
  • code/branches/core4/src/orxonox/objects/items/Engine.cc

    r3196 r3223  
    138138            Synchronisable* object = Synchronisable::getSynchronisable(this->shipID_);
    139139            if (object)
    140                 this->addToSpaceShip(dynamic_cast<SpaceShip*>(object));
     140                this->addToSpaceShip(orxonox_cast<SpaceShip>(object));
    141141        }
    142142    }
  • 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            {
  • code/branches/core4/src/orxonox/objects/quest/QuestManager.cc

    r3196 r3223  
    239239            return NULL;
    240240        }
    241         player = dynamic_cast<PlayerInfo*>(obj);
     241        player = orxonox_cast<PlayerInfo>(obj);
    242242   
    243243        QuestContainer* root = NULL;
  • code/branches/core4/src/orxonox/objects/weaponsystem/projectiles/Projectile.cc

    r3196 r3223  
    126126                dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
    127127
    128             Pawn* victim = dynamic_cast<Pawn*>(otherObject);
     128            Pawn* victim = orxonox_cast<Pawn>(otherObject);
    129129            if (victim)
    130130                victim->damage(dmg, this->owner_);
  • 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        }
  • code/branches/core4/src/orxonox/overlays/hud/AnnounceMessage.cc

    r3110 r3223  
    5656        SUPER(AnnounceMessage, changedOwner);
    5757
    58         this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
     58        this->owner_ = orxonox_cast<PlayerInfo>(this->getOwner());
    5959    }
    6060}
  • code/branches/core4/src/orxonox/overlays/hud/DeathMessage.cc

    r3110 r3223  
    5656        SUPER(DeathMessage, changedOwner);
    5757
    58         this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
     58        this->owner_ = orxonox_cast<PlayerInfo>(this->getOwner());
    5959    }
    6060}
  • code/branches/core4/src/orxonox/overlays/hud/GametypeStatus.cc

    r3196 r3223  
    8686        SUPER(GametypeStatus, changedOwner);
    8787
    88         this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
     88        this->owner_ = orxonox_cast<PlayerInfo>(this->getOwner());
    8989    }
    9090}
  • code/branches/core4/src/orxonox/overlays/hud/HUDHealthBar.cc

    r3196 r3223  
    9494        SUPER(HUDHealthBar, changedOwner);
    9595
    96         this->owner_ = dynamic_cast<Pawn*>(this->getOwner());
     96        this->owner_ = orxonox_cast<Pawn>(this->getOwner());
    9797    }
    9898
  • code/branches/core4/src/orxonox/overlays/hud/HUDRadar.cc

    r3196 r3223  
    164164        SUPER(HUDRadar, changedOwner);
    165165
    166         this->owner_ = dynamic_cast<Pawn*>(this->getOwner());
     166        this->owner_ = orxonox_cast<Pawn>(this->getOwner());
    167167    }
    168168}
  • code/branches/core4/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r3196 r3223  
    6565        SUPER(HUDSpeedBar, changedOwner);
    6666
    67         this->owner_ = dynamic_cast<SpaceShip*>(this->getOwner());
     67        this->owner_ = orxonox_cast<SpaceShip>(this->getOwner());
    6868    }
    6969}
  • code/branches/core4/src/orxonox/overlays/hud/HUDTimer.cc

    r3196 r3223  
    6868        SUPER(HUDTimer, changedOwner);
    6969
    70         this->owner_ = dynamic_cast<ControllableEntity*>(this->getOwner());
     70        this->owner_ = orxonox_cast<ControllableEntity>(this->getOwner());
    7171    }
    7272}
  • code/branches/core4/src/orxonox/overlays/hud/KillMessage.cc

    r3110 r3223  
    5656        SUPER(KillMessage, changedOwner);
    5757
    58         this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
     58        this->owner_ = orxonox_cast<PlayerInfo>(this->getOwner());
    5959    }
    6060}
  • code/branches/core4/src/orxonox/overlays/hud/PongScore.cc

    r3196 r3223  
    133133
    134134        if (this->getOwner() && this->getOwner()->getGametype())
    135             this->owner_ = dynamic_cast<Pong*>(this->getOwner()->getGametype());
     135            this->owner_ = orxonox_cast<Pong>(this->getOwner()->getGametype());
    136136        else
    137137            this->owner_ = 0;
  • code/branches/core4/src/orxonox/overlays/hud/TeamBaseMatchScore.cc

    r3196 r3223  
    118118
    119119        if (this->getOwner() && this->getOwner()->getGametype())
    120             this->owner_ = dynamic_cast<TeamBaseMatch*>(this->getOwner()->getGametype());
     120            this->owner_ = orxonox_cast<TeamBaseMatch>(this->getOwner()->getGametype());
    121121        else
    122122            this->owner_ = 0;
  • code/branches/core4/src/orxonox/overlays/hud/UnderAttackHealthBar.cc

    r3196 r3223  
    7373        SUPER(UnderAttackHealthBar, changedOwner);
    7474
    75         PlayerInfo* player = dynamic_cast<PlayerInfo*>(this->getOwner());
     75        PlayerInfo* player = orxonox_cast<PlayerInfo>(this->getOwner());
    7676        if (player)
    7777        {
    7878            this->owner_ = player;
    7979
    80             UnderAttack* ua = dynamic_cast<UnderAttack*>(player->getGametype());
     80            UnderAttack* ua = orxonox_cast<UnderAttack>(player->getGametype());
    8181            if (ua)
    8282            {
  • code/branches/core4/src/orxonox/overlays/map/Map.cc

    r3196 r3223  
    359359        //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
    360360
    361         ControllableEntity* entity = dynamic_cast<ControllableEntity*>(this->getOwner());
     361        ControllableEntity* entity = orxonox_cast<ControllableEntity>(this->getOwner());
    362362        if(entity && entity->getReverseCamera())
    363363        {
Note: See TracChangeset for help on using the changeset viewer.