Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/collisionshapes/CollisionShape.cc

    r10624 r11071  
    5757        RegisterObject(CollisionShape);
    5858
    59         this->parent_ = 0;
     59        this->parent_ = nullptr;
    6060        this->parentID_ = OBJECTID_UNKNOWN;
    61         this->collisionShape_ = 0;
     61        this->collisionShape_ = nullptr;
    6262        this->position_ = Vector3::ZERO;
    6363        this->orientation_ = Quaternion::IDENTITY;
     
    154154    void CollisionShape::notifyDetached()
    155155    {
    156         this->parent_ = 0;
     156        this->parent_ = nullptr;
    157157        this->parentID_ = OBJECTID_UNKNOWN;
    158158    }
  • code/trunk/src/orxonox/collisionshapes/CollisionShape.h

    r9667 r11071  
    6161            virtual ~CollisionShape();
    6262
    63             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     63            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    6464
    6565            /**
     
    181181
    182182            btCollisionShape*       collisionShape_; //!< The bullet collision shape of this CollisionShape.
    183             CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, NULL if it doesn't belong to one.
     183            CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, nullptr if it doesn't belong to one.
    184184            unsigned int            parentID_; //!< The objectID of the parent of this CollisionShape, which can either be a CompoundCollisionShape or a WorldEntity.
    185185
  • code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc

    r10624 r11071  
    6565        {
    6666            // Delete all children
    67             for (std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin();
    68                 it != this->attachedShapes_.end(); ++it)
     67            for (const auto& mapEntry : this->attachedShapes_)
    6968            {
    7069                // make sure that the child doesn't want to detach itself --> speedup because of the missing update
    71                 it->first->notifyDetached();
    72                 it->first->destroy();
    73                 if (this->collisionShape_ == it->second)
    74                     this->collisionShape_ = NULL; // don't destroy it twice
     70                mapEntry.first->notifyDetached();
     71                mapEntry.first->destroy();
     72                if (this->collisionShape_ == mapEntry.second)
     73                    this->collisionShape_ = nullptr; // don't destroy it twice
    7574            }
    7675
    7776            delete this->compoundShape_;
    7877            if (this->collisionShape_ == this->compoundShape_)
    79                 this->collisionShape_ = NULL; // don't destroy it twice
     78                this->collisionShape_ = nullptr; // don't destroy it twice
    8079        }
    8180    }
     
    9695    void CompoundCollisionShape::attach(CollisionShape* shape)
    9796    {
    98         // If either the input shape is NULL or we try to attach the CollisionShape to itself.
     97        // If either the input shape is nullptr or we try to attach the CollisionShape to itself.
    9998        if (!shape || static_cast<CollisionShape*>(this) == shape)
    10099            return;
     
    197196    void CompoundCollisionShape::updatePublicShape()
    198197    {
    199         btCollisionShape* primitive = 0; // The primitive shape, if there is one.
     198        btCollisionShape* primitive = nullptr; // The primitive shape, if there is one.
    200199        bool bPrimitive = true; // Whether the CompoundCollisionShape has just one non-empty CollisionShape. And that shape also has no transformation.
    201200        bool bEmpty = true; // Whether the CompoundCollisionShape is empty.
    202201        // Iterate over all CollisionShapes that belong to this CompoundCollisionShape.
    203         for (std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)
     202        for (const auto& mapEntry : this->attachedShapes_)
    204203        {
    205204            // TODO: Make sure this is correct.
    206             if (it->second)
     205            if (mapEntry.second)
    207206            {
    208207                bEmpty = false;
    209                 if (!it->first->hasTransform() && bPrimitive)
    210                     primitive = it->second;
     208                if (!mapEntry.first->hasTransform() && bPrimitive)
     209                    primitive = mapEntry.second;
    211210                else
    212211                {
     
    221220        {
    222221            // If there was none all along, nothing needs to be changed.
    223             if (this->collisionShape_ == 0)
     222            if (this->collisionShape_ == nullptr)
    224223                return;
    225             this->collisionShape_ = 0;
     224            this->collisionShape_ = nullptr;
    226225        }
    227226        // If the CompoundCollisionShape is just a primitive.
     
    247246    {
    248247        unsigned int i = 0;
    249         for (std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)
     248        for (const auto& mapEntry : this->attachedShapes_)
    250249        {
    251250            if (i == index)
    252                 return it->first;
     251                return mapEntry.first;
    253252            ++i;
    254253        }
    255         return 0;
     254        return nullptr;
    256255    }
    257256
     
    267266        std::vector<CollisionShape*> shapes;
    268267        // Iterate through all attached CollisionShapes and add them to the list of shapes.
    269         for(std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
    270             shapes.push_back(it->first);
     268        for(const auto& mapEntry : this->attachedShapes_)
     269            shapes.push_back(mapEntry.first);
    271270
    272271        // Delete the compound shape and create a new one.
     
    275274
    276275        // Re-attach all CollisionShapes.
    277         for(std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++)
    278         {
    279             CollisionShape* shape = *it;
     276        for(CollisionShape* shape : shapes)
     277        {
    280278            shape->setScale3D(this->getScale3D());
    281279            // Only actually attach if we didn't pick a CompoundCollisionShape with no content.
  • code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.h

    r9667 r11071  
    6161            virtual ~CompoundCollisionShape();
    6262
    63             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     63            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    6464
    6565            void attach(CollisionShape* shape);
     
    7070            void updateAttachedShape(CollisionShape* shape);
    7171
    72             virtual void changedScale();
     72            virtual void changedScale() override;
    7373
    7474        private:
    7575            void updatePublicShape();
    76             inline virtual btCollisionShape* createNewShape() const
    77                 { assert(false); return 0; }
     76            virtual inline btCollisionShape* createNewShape() const override
     77                { assert(false); return nullptr; }
    7878
    7979            btCompoundShape* compoundShape_;
  • code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc

    r10624 r11071  
    4343        RegisterObject(WorldEntityCollisionShape);
    4444
    45         this->worldEntityOwner_ = NULL;
     45        this->worldEntityOwner_ = nullptr;
    4646        // suppress synchronisation
    4747        this->setSyncMode(ObjectDirection::None);
     
    5454        CollisionShape::updateParent();
    5555
    56         assert(this->worldEntityOwner_ != 0);
     56        assert(this->worldEntityOwner_ != nullptr);
    5757        this->worldEntityOwner_->notifyCollisionShapeChanged();
    5858    }
  • code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h

    r10624 r11071  
    4646
    4747        protected:
    48             virtual void updateParent();
     48            virtual void updateParent() override;
    4949
    5050        private:
    51             void parentChanged();
     51            virtual void parentChanged() override;
    5252
    5353            WorldEntity* worldEntityOwner_;
Note: See TracChangeset for help on using the changeset viewer.