Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • 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.
Note: See TracChangeset for help on using the changeset viewer.