Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2015, 10:47:51 PM (9 years ago)
Author:
landauf
Message:

use range-based for-loop where it makes sense (e.g. ObjectList)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/overlays/hud/HUDRadar.cc

    r10917 r10919  
    165165    {
    166166        const std::set<RadarViewable*>& objectSet = this->getCreator()->getScene()->getRadar()->getRadarObjects();
    167         std::set<RadarViewable*>::const_iterator it;
    168         for( it=objectSet.begin(); it!=objectSet.end(); ++it )
    169             this->addObject(*it);
     167        for( RadarViewable* viewable : objectSet )
     168            this->addObject(viewable);
    170169        this->radarTick(0);
    171170    }
     
    183182
    184183        // update the distances for all objects
    185         std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it;
    186 
    187184
    188185        if(RadarMode_)
     
    201198        }
    202199
    203         for( it = this->radarObjects_.begin(); it != this->radarObjects_.end(); ++it )
     200        for( const auto& mapEntry : this->radarObjects_ )
    204201        {
    205202            // Make sure the object really is a WorldEntity
    206             const WorldEntity* wePointer = it->first->getWorldEntity();
     203            const WorldEntity* wePointer = mapEntry.first->getWorldEntity();
    207204            if( !wePointer )
    208205            {
     
    210207                assert(0);
    211208            }
    212             bool isFocus = (it->first == focusObject);
     209            bool isFocus = (mapEntry.first == focusObject);
    213210            // set size to fit distance...
    214211            float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
     
    217214            float size;
    218215            if(RadarMode_)
    219                 size = maximumDotSize3D_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
     216                size = maximumDotSize3D_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * mapEntry.first->getRadarObjectScale();
    220217            else
    221                 size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * it->first->getRadarObjectScale();
    222             it->second->setDimensions(size, size);
     218                size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance) * mapEntry.first->getRadarObjectScale();
     219            mapEntry.second->setDimensions(size, size);
    223220
    224221            // calc position on radar...
     
    234231                int zOrder = determineMap3DZOrder(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition(), detectionLimit_);
    235232                if(overXZPlain == false /*&& (it->second->getZOrder() >  100 * this->overlay_->getZOrder())*/) // it appears that zOrder of attached Overlayelements is 100 times the zOrder of the Overlay
    236                     it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 70 + zOrder);
     233                    mapEntry.second->_notifyZOrder(this->overlay_->getZOrder() * 100 - 70 + zOrder);
    237234                if(overXZPlain == true /*&& (it->second->getZOrder() <= 100 * this->overlay_->getZOrder())*/)
    238                     it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 70 + zOrder);
     235                    mapEntry.second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 70 + zOrder);
    239236            }
    240237            else
     
    242239
    243240            coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
    244             it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
     241            mapEntry.second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
    245242
    246243            if( distance < detectionLimit_ || detectionLimit_ < 0 )
    247                 it->second->show();
     244                mapEntry.second->show();
    248245            else
    249                 it->second->hide();
     246                mapEntry.second->hide();
    250247
    251248            // if this object is in focus, then set the focus marker
     
    255252                this->marker_->setPosition((1.0f + coord.x - size * 1.5f) * 0.5f, (1.0f - coord.y - size * 1.5f) * 0.5f);
    256253                if(RadarMode_)
    257                     this->marker_->_notifyZOrder(it->second->getZOrder() -1);
     254                    this->marker_->_notifyZOrder(mapEntry.second->getZOrder() -1);
    258255                this->marker_->show();
    259256            }
Note: See TracChangeset for help on using the changeset viewer.