diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp index 8cfa55cc4..68aa7d4d4 100644 --- a/code/AssetLib/B3D/B3DImporter.cpp +++ b/code/AssetLib/B3D/B3DImporter.cpp @@ -671,7 +671,7 @@ void B3DImporter::ReadBB3D(aiScene *scene) { int bone = v.bones[k]; float weight = v.weights[k]; - vweights[bone].push_back(aiVertexWeight(vertIdx + faceIndex, weight)); + vweights[bone].emplace_back(vertIdx + faceIndex, weight); } } ++face; diff --git a/code/AssetLib/COB/COBLoader.cpp b/code/AssetLib/COB/COBLoader.cpp index 3e4c63b63..a540ffaf1 100644 --- a/code/AssetLib/COB/COBLoader.cpp +++ b/code/AssetLib/COB/COBLoader.cpp @@ -518,7 +518,7 @@ void COBImporter::ReadMat1_Ascii(Scene &out, LineSplitter &splitter, const Chunk return; } - out.materials.push_back(Material()); + out.materials.emplace_back(); Material &mat = out.materials.back(); mat = nfo; @@ -1004,7 +1004,7 @@ void COBImporter::ReadMat1_Binary(COB::Scene &out, StreamReaderLE &reader, const const chunk_guard cn(nfo, reader); - out.materials.push_back(Material()); + out.materials.emplace_back(); Material &mat = out.materials.back(); mat = nfo; diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index d8dbb6244..ffe961a4e 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -3319,7 +3319,7 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList(const std::vector& a, ClipperLib::Polygon clip; for(const IfcVector2& pip : a) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -410,7 +410,7 @@ void MergeWindowContours (const std::vector& a, clip.clear(); for(const IfcVector2& pip : b) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -433,7 +433,7 @@ void MakeDisjunctWindowContours (const std::vector& a, ClipperLib::Polygon clip; for(const IfcVector2& pip : a) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -444,7 +444,7 @@ void MakeDisjunctWindowContours (const std::vector& a, clip.clear(); for(const IfcVector2& pip : b) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(clip)) { @@ -466,7 +466,7 @@ void CleanupWindowContour(ProjectedWindowContour& window) ClipperLib::ExPolygons clipped; for(const IfcVector2& pip : contour) { - subject.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + subject.emplace_back(to_int64(pip.x), to_int64(pip.y)); } clipper.AddPolygon(subject,ClipperLib::ptSubject); @@ -524,7 +524,7 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh& ClipperLib::Polygon clip; clip.reserve(contour_flat.size()); for(const IfcVector2& pip : contour_flat) { - clip.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + clip.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (!ClipperLib::Orientation(clip)) { @@ -544,7 +544,7 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh& continue; } } - subject.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + subject.emplace_back(to_int64(pip.x), to_int64(pip.y)); if (--countdown == 0) { if (!ClipperLib::Orientation(subject)) { std::reverse(subject.begin(), subject.end()); @@ -1378,12 +1378,12 @@ bool GenerateOpenings(std::vector& openings, if(!temp_contour.empty()) { if (generate_connection_geometry) { - contours_to_openings.push_back(std::vector( - joined_openings.begin(), - joined_openings.end())); + contours_to_openings.emplace_back( + joined_openings.begin(), + joined_openings.end()); } - contours.push_back(ProjectedWindowContour(temp_contour, bb, is_rectangle)); + contours.emplace_back(temp_contour, bb, is_rectangle); } } @@ -1791,7 +1791,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings, pip.x = (pip.x - vmin.x) / vmax.x; pip.y = (pip.y - vmin.y) / vmax.y; - hole.push_back(ClipperLib::IntPoint(to_int64(pip.x),to_int64(pip.y))); + hole.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if(!ClipperLib::Orientation(hole)) { @@ -1833,7 +1833,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings, pip.x = (pip.x - vmin.x) / vmax.x; pip.y = (pip.y - vmin.y) / vmax.y; - poly.push_back(ClipperLib::IntPoint( to_int64(pip.x), to_int64(pip.y) )); + poly.emplace_back(to_int64(pip.x), to_int64(pip.y)); } if (ClipperLib::Orientation(poly)) { diff --git a/code/AssetLib/IQM/IQMImporter.h b/code/AssetLib/IQM/IQMImporter.h index cc549186f..ea4729988 100644 --- a/code/AssetLib/IQM/IQMImporter.h +++ b/code/AssetLib/IQM/IQMImporter.h @@ -58,7 +58,7 @@ public: IQMImporter(); ~IQMImporter() override = default; - /// \brief Returns whether the class can handle the format of the given file. + /// \brief Returns whether the class can handle the format of the given file. /// \remark See BaseImporter::CanRead() for details. bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const override; diff --git a/code/AssetLib/LWO/LWOBLoader.cpp b/code/AssetLib/LWO/LWOBLoader.cpp index 1fbd9b9df..a61e49a7f 100644 --- a/code/AssetLib/LWO/LWOBLoader.cpp +++ b/code/AssetLib/LWO/LWOBLoader.cpp @@ -218,7 +218,7 @@ void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it, // ------------------------------------------------------------------------------------------------ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned int size) { - list.push_back(LWO::Texture()); + list.emplace_back(); LWO::Texture* tex = &list.back(); std::string type; diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index be7d54700..df0ba2238 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -1095,7 +1095,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) { void LWOImporter::LoadLWO2Clip(unsigned int length) { AI_LWO_VALIDATE_CHUNK_LENGTH(length, CLIP, 10); - mClips.push_back(LWO::Clip()); + mClips.emplace_back(); LWO::Clip &clip = mClips.back(); // first - get the index of the clip @@ -1165,7 +1165,7 @@ void LWOImporter::LoadLWO2Clip(unsigned int length) { void LWOImporter::LoadLWO3Clip(unsigned int length) { AI_LWO_VALIDATE_CHUNK_LENGTH(length, CLIP, 12); - mClips.push_back(LWO::Clip()); + mClips.emplace_back(); LWO::Clip &clip = mClips.back(); // first - get the index of the clip @@ -1238,7 +1238,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length) { LE_NCONST uint8_t *const end = mFileBuffer + length; AI_LWO_VALIDATE_CHUNK_LENGTH(length, ENVL, 4); - mEnvelopes.push_back(LWO::Envelope()); + mEnvelopes.emplace_back(); LWO::Envelope &envelope = mEnvelopes.back(); // Get the index of the envelope @@ -1346,7 +1346,7 @@ void LWOImporter::LoadLWO3Envelope(unsigned int length) { LE_NCONST uint8_t *const end = mFileBuffer + length; AI_LWO_VALIDATE_CHUNK_LENGTH(length, ENVL, 4); - mEnvelopes.push_back(LWO::Envelope()); + mEnvelopes.emplace_back(); LWO::Envelope &envelope = mEnvelopes.back(); // Get the index of the envelope diff --git a/code/AssetLib/MD5/MD5Parser.cpp b/code/AssetLib/MD5/MD5Parser.cpp index 7ed23cb82..606660080 100644 --- a/code/AssetLib/MD5/MD5Parser.cpp +++ b/code/AssetLib/MD5/MD5Parser.cpp @@ -76,7 +76,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) { // and read all sections until we're finished bool running = true; while (running) { - mSections.push_back(Section()); + mSections.emplace_back(); Section &sec = mSections.back(); if (!ParseSection(sec)) { break; @@ -158,7 +158,7 @@ bool MD5Parser::ParseSection(Section &out) { break; } - out.mElements.push_back(Element()); + out.mElements.emplace_back(); Element &elem = out.mElements.back(); elem.iLineNumber = lineNumber; @@ -253,7 +253,7 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) { } else if ((*iter).mName == "joints") { // "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 ) for (const auto &elem : (*iter).mElements) { - mJoints.push_back(BoneDesc()); + mJoints.emplace_back(); BoneDesc &desc = mJoints.back(); const char *sz = elem.szStart; @@ -267,7 +267,7 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) { AI_MD5_READ_TRIPLE(desc.mRotationQuat); // normalized quaternion, so w is not there } } else if ((*iter).mName == "mesh") { - mMeshes.push_back(MeshDesc()); + mMeshes.emplace_back(); MeshDesc &desc = mMeshes.back(); for (const auto &elem : (*iter).mElements) { @@ -364,7 +364,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) { if ((*iter).mName == "hierarchy") { // "sheath" 0 63 6 for (const auto &elem : (*iter).mElements) { - mAnimatedBones.push_back(AnimBoneDesc()); + mAnimatedBones.emplace_back(); AnimBoneDesc &desc = mAnimatedBones.back(); const char *sz = elem.szStart; @@ -389,7 +389,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) { for (const auto &elem : (*iter).mElements) { const char *sz = elem.szStart; - mBaseFrames.push_back(BaseFrameDesc()); + mBaseFrames.emplace_back(); BaseFrameDesc &desc = mBaseFrames.back(); AI_MD5_READ_TRIPLE(desc.vPositionXYZ); @@ -401,7 +401,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) { continue; } - mFrames.push_back(FrameDesc()); + mFrames.emplace_back(); FrameDesc &desc = mFrames.back(); desc.iIndex = strtoul10((*iter).mGlobalValue.c_str()); @@ -459,7 +459,7 @@ MD5CameraParser::MD5CameraParser(SectionList &mSections) { for (const auto &elem : (*iter).mElements) { const char *sz = elem.szStart; - frames.push_back(CameraAnimFrameDesc()); + frames.emplace_back(); CameraAnimFrameDesc &cur = frames.back(); AI_MD5_READ_TRIPLE(cur.vPositionXYZ); AI_MD5_READ_TRIPLE(cur.vRotationQuat); diff --git a/code/AssetLib/MMD/MMDImporter.cpp b/code/AssetLib/MMD/MMDImporter.cpp index 7a9030b64..97b04f4eb 100644 --- a/code/AssetLib/MMD/MMDImporter.cpp +++ b/code/AssetLib/MMD/MMDImporter.cpp @@ -269,43 +269,30 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel, dynamic_cast(v->skinning.get()); switch (v->skinning_type) { case pmx::PmxVertexSkinningType::BDEF1: - bone_vertex_map[vsBDEF1_ptr->bone_index].push_back( - aiVertexWeight(index, 1.0)); + bone_vertex_map[vsBDEF1_ptr->bone_index].emplace_back(index, 1.0); break; case pmx::PmxVertexSkinningType::BDEF2: - bone_vertex_map[vsBDEF2_ptr->bone_index1].push_back( - aiVertexWeight(index, vsBDEF2_ptr->bone_weight)); - bone_vertex_map[vsBDEF2_ptr->bone_index2].push_back( - aiVertexWeight(index, 1.0f - vsBDEF2_ptr->bone_weight)); + bone_vertex_map[vsBDEF2_ptr->bone_index1].emplace_back(index, vsBDEF2_ptr->bone_weight); + bone_vertex_map[vsBDEF2_ptr->bone_index2].emplace_back(index, 1.0f - vsBDEF2_ptr->bone_weight); break; case pmx::PmxVertexSkinningType::BDEF4: - bone_vertex_map[vsBDEF4_ptr->bone_index1].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight1)); - bone_vertex_map[vsBDEF4_ptr->bone_index2].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight2)); - bone_vertex_map[vsBDEF4_ptr->bone_index3].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight3)); - bone_vertex_map[vsBDEF4_ptr->bone_index4].push_back( - aiVertexWeight(index, vsBDEF4_ptr->bone_weight4)); + bone_vertex_map[vsBDEF4_ptr->bone_index1].emplace_back(index, vsBDEF4_ptr->bone_weight1); + bone_vertex_map[vsBDEF4_ptr->bone_index2].emplace_back(index, vsBDEF4_ptr->bone_weight2); + bone_vertex_map[vsBDEF4_ptr->bone_index3].emplace_back(index, vsBDEF4_ptr->bone_weight3); + bone_vertex_map[vsBDEF4_ptr->bone_index4].emplace_back(index, vsBDEF4_ptr->bone_weight4); break; case pmx::PmxVertexSkinningType::SDEF: // TODO: how to use sdef_c, sdef_r0, // sdef_r1? - bone_vertex_map[vsSDEF_ptr->bone_index1].push_back( - aiVertexWeight(index, vsSDEF_ptr->bone_weight)); - bone_vertex_map[vsSDEF_ptr->bone_index2].push_back( - aiVertexWeight(index, 1.0f - vsSDEF_ptr->bone_weight)); + bone_vertex_map[vsSDEF_ptr->bone_index1].emplace_back(index, vsSDEF_ptr->bone_weight); + bone_vertex_map[vsSDEF_ptr->bone_index2].emplace_back(index, 1.0f - vsSDEF_ptr->bone_weight); break; case pmx::PmxVertexSkinningType::QDEF: const auto vsQDEF_ptr = dynamic_cast(v->skinning.get()); - bone_vertex_map[vsQDEF_ptr->bone_index1].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight1)); - bone_vertex_map[vsQDEF_ptr->bone_index2].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight2)); - bone_vertex_map[vsQDEF_ptr->bone_index3].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight3)); - bone_vertex_map[vsQDEF_ptr->bone_index4].push_back( - aiVertexWeight(index, vsQDEF_ptr->bone_weight4)); + bone_vertex_map[vsQDEF_ptr->bone_index1].emplace_back(index, vsQDEF_ptr->bone_weight1); + bone_vertex_map[vsQDEF_ptr->bone_index2].emplace_back(index, vsQDEF_ptr->bone_weight2); + bone_vertex_map[vsQDEF_ptr->bone_index3].emplace_back(index, vsQDEF_ptr->bone_weight3); + bone_vertex_map[vsQDEF_ptr->bone_index4].emplace_back(index, vsQDEF_ptr->bone_weight4); break; } } diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index 5ea4f00e1..a91788c78 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -418,7 +418,7 @@ outer: (*fit).mat = 0; } if (fidx[(*fit).mat].empty()) ++pScene->mNumMeshes; - fidx[(*fit).mat].push_back(FaceIdx(p, q)); + fidx[(*fit).mat].emplace_back(p, q); } } pScene->mNumMaterials = pScene->mNumMeshes; diff --git a/code/PostProcessing/DeboneProcess.cpp b/code/PostProcessing/DeboneProcess.cpp index 2412eb9d8..bbf3264a5 100644 --- a/code/PostProcessing/DeboneProcess.cpp +++ b/code/PostProcessing/DeboneProcess.cpp @@ -153,7 +153,7 @@ void DeboneProcess::Execute( aiScene* pScene) } else { // Mesh is kept unchanged - store it's new place in the mesh array - mSubMeshIndices[a].push_back(std::pair(static_cast(meshes.size()),(aiNode*)0)); + mSubMeshIndices[a].emplace_back(static_cast(meshes.size()), (aiNode *)0); meshes.push_back(srcMesh); } } diff --git a/code/PostProcessing/ProcessHelper.cpp b/code/PostProcessing/ProcessHelper.cpp index d819012d9..15f01676c 100644 --- a/code/PostProcessing/ProcessHelper.cpp +++ b/code/PostProcessing/ProcessHelper.cpp @@ -208,7 +208,7 @@ VertexWeightTable *ComputeVertexBoneWeightTable(const aiMesh *pMesh) { aiBone *bone = pMesh->mBones[i]; for (unsigned int a = 0; a < bone->mNumWeights; ++a) { const aiVertexWeight &weight = bone->mWeights[a]; - avPerVertexWeights[weight.mVertexId].push_back(std::pair(i, weight.mWeight)); + avPerVertexWeights[weight.mVertexId].emplace_back(i, weight.mWeight); } } return avPerVertexWeights; diff --git a/code/PostProcessing/SortByPTypeProcess.cpp b/code/PostProcessing/SortByPTypeProcess.cpp index 0c5d78350..6312fa173 100644 --- a/code/PostProcessing/SortByPTypeProcess.cpp +++ b/code/PostProcessing/SortByPTypeProcess.cpp @@ -309,7 +309,7 @@ void SortByPTypeProcess::Execute(aiScene *pScene) { VertexWeightTable &tbl = avw[idx]; for (VertexWeightTable::const_iterator it = tbl.begin(), end = tbl.end(); it != end; ++it) { - tempBones[(*it).first].push_back(aiVertexWeight(outIdx, (*it).second)); + tempBones[(*it).first].emplace_back(outIdx, (*it).second); } } diff --git a/code/PostProcessing/SplitByBoneCountProcess.cpp b/code/PostProcessing/SplitByBoneCountProcess.cpp index 5e052b76a..a501d3bd6 100644 --- a/code/PostProcessing/SplitByBoneCountProcess.cpp +++ b/code/PostProcessing/SplitByBoneCountProcess.cpp @@ -173,7 +173,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vectormWeights[b].mWeight > 0.0f) { int vertexId = bone->mWeights[b].mVertexId; - vertexBones[vertexId].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); + vertexBones[vertexId].emplace_back(a, bone->mWeights[b].mWeight); if (vertexBones[vertexId].size() > mMaxBoneCount) { throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!"); diff --git a/code/PostProcessing/TextureTransform.cpp b/code/PostProcessing/TextureTransform.cpp index 2699863d1..efbf4d2c6 100644 --- a/code/PostProcessing/TextureTransform.cpp +++ b/code/PostProcessing/TextureTransform.cpp @@ -434,7 +434,7 @@ void TextureTransformStep::Execute( aiScene* pScene) for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) { if (ref[n]) continue; - trafo.push_back(STransformVecInfo()); + trafo.emplace_back(); trafo.back().uvIndex = n; } diff --git a/test/unit/utLimitBoneWeights.cpp b/test/unit/utLimitBoneWeights.cpp index 0c24b56c4..bf3ea93f5 100644 --- a/test/unit/utLimitBoneWeights.cpp +++ b/test/unit/utLimitBoneWeights.cpp @@ -114,7 +114,7 @@ TEST_F(LimitBoneWeightsTest, testProcess) { aiBone &pcBone = **(mMesh->mBones + i); for (unsigned int q = 0; q < pcBone.mNumWeights; ++q) { aiVertexWeight weight = pcBone.mWeights[q]; - asWeights[weight.mVertexId].push_back(LimitBoneWeightsProcess::Weight(i, weight.mWeight)); + asWeights[weight.mVertexId].emplace_back(i, weight.mWeight); } } diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp index 4c2df2d9e..f5766a47d 100644 --- a/tools/assimp_cmd/CompareDump.cpp +++ b/tools/assimp_cmd/CompareDump.cpp @@ -125,10 +125,10 @@ public: ai_assert(expect); fseek(actual,0,SEEK_END); - lengths.push(std::make_pair(static_cast(ftell(actual)),0)); + lengths.emplace(static_cast(ftell(actual)),0); fseek(actual,0,SEEK_SET); - history.push_back(HistoryEntry("---",PerChunkCounter())); + history.emplace_back("---",PerChunkCounter()); } public: @@ -144,7 +144,7 @@ public: } else history.back().second[s] = 0; - history.push_back(HistoryEntry(s,PerChunkCounter())); + history.emplace_back(s,PerChunkCounter()); debug_trace.push_back("PUSH " + s); } @@ -158,7 +158,7 @@ public: /* push current chunk length and start offset on top of stack */ void push_length(uint32_t nl, uint32_t start) { - lengths.push(std::make_pair(nl,start)); + lengths.emplace(nl,start); ++cnt_chunks; }