diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index caaf21ecb..a8e97e7b1 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -246,8 +246,7 @@ void LWOImporter::InternReadFile( const std::string& pFile, apcMeshes.reserve(mLayers->size()*std::min(((unsigned int)mSurfaces->size()/2u), 1u)); unsigned int iDefaultSurface = UINT_MAX; // index of the default surface - for (LayerList::iterator lit = mLayers->begin(), lend = mLayers->end();lit != lend;++lit) { - LWO::Layer& layer = *lit; + for (LWO::Layer &layer : *mLayers) { if (layer.skip) continue; @@ -909,12 +908,12 @@ void LWOImporter::LoadLWO2PolygonTags(unsigned int length) template VMapEntry* FindEntry(std::vector< T >& list,const std::string& name, bool perPoly) { - for (typename std::vector< T >::iterator it = list.begin(), end = list.end();it != end; ++it) { - if ((*it).name == name) { + for (auto & elem : list) { + if (elem.name == name) { if (!perPoly) { DefaultLogger::get()->warn("LWO2: Found two VMAP sections with equal names"); } - return &(*it); + return &elem; } } list.push_back( T() ); @@ -941,8 +940,8 @@ inline void CreateNewEntry(T& chan, unsigned int srcIdx) template inline void CreateNewEntry(std::vector< T >& list, unsigned int srcIdx) { - for (typename std::vector< T >::iterator it = list.begin(), end = list.end();it != end;++it) { - CreateNewEntry( *it, srcIdx ); + for (auto &elem : list) { + CreateNewEntry( elem, srcIdx ); } } diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index b80dae1e8..24a2458cf 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -90,8 +90,8 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex aiString s; bool ret = false; - for (TextureList::const_iterator it = in.begin(), end = in.end();it != end;++it) { - if (!(*it).enabled || !(*it).bCanUse) + for (const auto &texture : in) { + if (!texture.enabled || !texture.bCanUse) continue; ret = true; @@ -100,7 +100,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex // channels if they're not there. aiTextureMapping mapping; - switch ((*it).mapMode) + switch (texture.mapMode) { case LWO::Texture::Planar: mapping = aiTextureMapping_PLANE; @@ -120,13 +120,13 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex break; case LWO::Texture::UV: { - if( UINT_MAX == (*it).mRealUVIndex ) { + if( UINT_MAX == texture.mRealUVIndex ) { // We have no UV index for this texture, so we can't display it continue; } // add the UV source index - temp = (*it).mRealUVIndex; + temp = texture.mRealUVIndex; pcMat->AddProperty((int*)&temp,1,AI_MATKEY_UVWSRC(type,cur)); mapping = aiTextureMapping_UV; @@ -139,7 +139,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex if (mapping != aiTextureMapping_UV) { // Setup the main axis aiVector3D v; - switch ((*it).majorAxis) { + switch (texture.majorAxis) { case Texture::AXIS_X: v = aiVector3D(1.f,0.f,0.f); break; @@ -156,8 +156,8 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex // Setup UV scalings for cylindric and spherical projections if (mapping == aiTextureMapping_CYLINDER || mapping == aiTextureMapping_SPHERE) { aiUVTransform trafo; - trafo.mScaling.x = (*it).wrapAmountW; - trafo.mScaling.y = (*it).wrapAmountH; + trafo.mScaling.x = texture.wrapAmountW; + trafo.mScaling.y = texture.wrapAmountH; static_assert(sizeof(aiUVTransform)/sizeof(float) == 5, "sizeof(aiUVTransform)/sizeof(float) == 5"); pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur)); @@ -171,7 +171,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex // find the corresponding clip (take the last one if multiple // share the same index) ClipList::iterator end = mClips.end(), candidate = end; - temp = (*it).mClipIdx; + temp = texture.mClipIdx; for (ClipList::iterator clip = mClips.begin(); clip != end; ++clip) { if ((*clip).idx == temp) { candidate = clip; @@ -208,7 +208,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex } else { - std::string ss = (*it).mFileName; + std::string ss = texture.mFileName; if (!ss.length()) { DefaultLogger::get()->error("LWOB: Empty file name"); continue; @@ -219,10 +219,10 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex pcMat->AddProperty(&s,AI_MATKEY_TEXTURE(type,cur)); // add the blend factor - pcMat->AddProperty(&(*it).mStrength,1,AI_MATKEY_TEXBLEND(type,cur)); + pcMat->AddProperty(&texture.mStrength,1,AI_MATKEY_TEXBLEND(type,cur)); // add the blend operation - switch ((*it).blendType) + switch (texture.blendType) { case LWO::Texture::Normal: case LWO::Texture::Multiply: @@ -254,11 +254,11 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex pcMat->AddProperty((int*)&mapping,1,AI_MATKEY_MAPPING(type,cur)); // add the u-wrapping - temp = (unsigned int)GetMapMode((*it).wrapModeWidth); + temp = (unsigned int)GetMapMode(texture.wrapModeWidth); pcMat->AddProperty((int*)&temp,1,AI_MATKEY_MAPPINGMODE_U(type,cur)); // add the v-wrapping - temp = (unsigned int)GetMapMode((*it).wrapModeHeight); + temp = (unsigned int)GetMapMode(texture.wrapModeHeight); pcMat->AddProperty((int*)&temp,1,AI_MATKEY_MAPPINGMODE_V(type,cur)); ++cur; @@ -343,16 +343,14 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat) // Now we need to know which shader to use .. iterate through the shader list of // the surface and search for a name which we know ... - for (ShaderList::const_iterator it = surf.mShaders.begin(), end = surf.mShaders.end();it != end;++it) { - //if (!(*it).enabled)continue; - - if ((*it).functionName == "LW_SuperCelShader" || (*it).functionName == "AH_CelShader") { + for (const auto &shader : surf.mShaders) { + if (shader.functionName == "LW_SuperCelShader" || shader.functionName == "AH_CelShader") { DefaultLogger::get()->info("LWO2: Mapping LW_SuperCelShader/AH_CelShader to aiShadingMode_Toon"); m = aiShadingMode_Toon; break; } - else if ((*it).functionName == "LW_RealFresnel" || (*it).functionName == "LW_FastFresnel") { + else if (shader.functionName == "LW_RealFresnel" || shader.functionName == "LW_FastFresnel") { DefaultLogger::get()->info("LWO2: Mapping LW_RealFresnel/LW_FastFresnel to aiShadingMode_Fresnel"); m = aiShadingMode_Fresnel; @@ -360,7 +358,7 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat) } else { - DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + (*it).functionName); + DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + shader.functionName); } } if (surf.mMaximumSmoothAngle <= 0.0f) @@ -381,20 +379,20 @@ char LWOImporter::FindUVChannels(LWO::TextureList& list, LWO::Layer& /*layer*/,LWO::UVChannel& uv, unsigned int next) { char ret = 0; - for (TextureList::iterator it = list.begin(), end = list.end();it != end;++it) { + for (auto &texture : list) { // Ignore textures with non-UV mappings for the moment. - if (!(*it).enabled || !(*it).bCanUse || (*it).mapMode != LWO::Texture::UV) { + if (!texture.enabled || !texture.bCanUse || texture.mapMode != LWO::Texture::UV) { continue; } - if ((*it).mUVChannelIndex == uv.name) { + if (texture.mUVChannelIndex == uv.name) { ret = 1; // got it. - if ((*it).mRealUVIndex == UINT_MAX || (*it).mRealUVIndex == next) + if (texture.mRealUVIndex == UINT_MAX || texture.mRealUVIndex == next) { - (*it).mRealUVIndex = next; + texture.mRealUVIndex = next; } else { // channel mismatch. need to duplicate the material.