diff --git a/code/OgreBinarySerializer.cpp b/code/OgreBinarySerializer.cpp index dd0b57c00..d823d37fa 100644 --- a/code/OgreBinarySerializer.cpp +++ b/code/OgreBinarySerializer.cpp @@ -501,10 +501,8 @@ void OgreBinarySerializer::NormalizeBoneWeights(VertexData *vertexData) const Some exporters wont care if the sum of all bone weights for a single vertex equals 1 or not, so validate here. */ const float epsilon = 0.05f; - for(std::set::const_iterator iter=influencedVertices.begin(), end=influencedVertices.end(); iter != end; ++iter) + for (const uint32_t vertexIndex : influencedVertices) { - const uint32_t vertexIndex = (*iter); - float sum = 0.0f; for (VertexBoneAssignmentList::const_iterator baIter=vertexData->boneAssignments.begin(), baEnd=vertexData->boneAssignments.end(); baIter != baEnd; ++baIter) { @@ -513,10 +511,10 @@ void OgreBinarySerializer::NormalizeBoneWeights(VertexData *vertexData) const } if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon))) { - for (VertexBoneAssignmentList::iterator baIter=vertexData->boneAssignments.begin(), baEnd=vertexData->boneAssignments.end(); baIter != baEnd; ++baIter) + for (auto &boneAssign : vertexData->boneAssignments) { - if (baIter->vertexIndex == vertexIndex) - baIter->weight /= sum; + if (boneAssign.vertexIndex == vertexIndex) + boneAssign.weight /= sum; } } } diff --git a/code/OgreStructs.cpp b/code/OgreStructs.cpp index 566c51e0f..593f0b90e 100644 --- a/code/OgreStructs.cpp +++ b/code/OgreStructs.cpp @@ -258,12 +258,11 @@ void IVertexData::AddVertexMapping(uint32_t oldIndex, uint32_t newIndex) void IVertexData::BoneAssignmentsForVertex(uint32_t currentIndex, uint32_t newIndex, VertexBoneAssignmentList &dest) const { - for (VertexBoneAssignmentList::const_iterator iter=boneAssignments.begin(), end=boneAssignments.end(); - iter!=end; ++iter) + for (const auto &boneAssign : boneAssignments) { - if (iter->vertexIndex == currentIndex) + if (boneAssign.vertexIndex == currentIndex) { - VertexBoneAssignment a = (*iter); + VertexBoneAssignment a = boneAssign; a.vertexIndex = newIndex; dest.push_back(a); } @@ -289,10 +288,9 @@ AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices) std::set IVertexData::ReferencedBonesByWeights() const { std::set referenced; - for (VertexBoneAssignmentList::const_iterator iter=boneAssignments.begin(), end=boneAssignments.end(); - iter!=end; ++iter) + for (const auto &boneAssign : boneAssignments) { - referenced.insert(iter->boneIndex); + referenced.insert(boneAssign.boneIndex); } return referenced; } @@ -318,10 +316,10 @@ void VertexData::Reset() uint32_t VertexData::VertexSize(uint16_t source) const { uint32_t size = 0; - for(VertexElementList::const_iterator iter=vertexElements.begin(), end=vertexElements.end(); iter != end; ++iter) + for(const auto &element : vertexElements) { - if (iter->source == source) - size += iter->Size(); + if (element.source == source) + size += element.Size(); } return size; } @@ -335,9 +333,8 @@ MemoryStream *VertexData::VertexBuffer(uint16_t source) VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, uint16_t index) { - for(VertexElementList::iterator iter=vertexElements.begin(), end=vertexElements.end(); iter != end; ++iter) + for(auto & element : vertexElements) { - VertexElement &element = (*iter); if (element.semantic == semantic && element.index == index) return &element; } @@ -427,16 +424,16 @@ void Mesh::Reset() OGRE_SAFE_DELETE(skeleton) OGRE_SAFE_DELETE(sharedVertexData) - for(size_t i=0, len=subMeshes.size(); iBoneById(children[i]); + Bone *child = skeleton->BoneById(boneId); if (!child) { - throw DeadlyImportError(Formatter::format() << "CalculateWorldMatrixAndDefaultPose: Failed to find child bone " << children[i] << " for parent " << id << " " << name); + throw DeadlyImportError(Formatter::format() << "CalculateWorldMatrixAndDefaultPose: Failed to find child bone " << boneId << " for parent " << id << " " << name); } child->CalculateWorldMatrixAndDefaultPose(skeleton); } diff --git a/code/OgreXmlSerializer.cpp b/code/OgreXmlSerializer.cpp index 030d61d57..b011b842f 100644 --- a/code/OgreXmlSerializer.cpp +++ b/code/OgreXmlSerializer.cpp @@ -453,7 +453,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest) } else if (uvs > 0 && m_currentNodeName == nnTexCoord) { - for(size_t i=0, len=dest->uvs.size(); iuvs) { if (m_currentNodeName != nnTexCoord) { throw DeadlyImportError("Vertex buffer declared more UVs than can be found in a vertex"); @@ -462,7 +462,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest) aiVector3D uv; uv.x = ReadAttribute("u"); uv.y = (ReadAttribute("v") * -1) + 1; // Flip UV from Ogre to Assimp form - dest->uvs[i].push_back(uv); + uvs.push_back(uv); NextNode(); } @@ -657,10 +657,8 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest) Some exporters wont care if the sum of all bone weights for a single vertex equals 1 or not, so validate here. */ const float epsilon = 0.05f; - for(std::set::const_iterator iter=influencedVertices.begin(), end=influencedVertices.end(); iter != end; ++iter) + for (const uint32_t vertexIndex : influencedVertices) { - const uint32_t vertexIndex = (*iter); - float sum = 0.0f; for (VertexBoneAssignmentList::const_iterator baIter=dest->boneAssignments.begin(), baEnd=dest->boneAssignments.end(); baIter != baEnd; ++baIter) { @@ -669,10 +667,10 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest) } if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon))) { - for (VertexBoneAssignmentList::iterator baIter=dest->boneAssignments.begin(), baEnd=dest->boneAssignments.end(); baIter != baEnd; ++baIter) + for (auto &boneAssign : dest->boneAssignments) { - if (baIter->vertexIndex == vertexIndex) - baIter->weight /= sum; + if (boneAssign.vertexIndex == vertexIndex) + boneAssign.weight /= sum; } } }