Apply some more modernize-use-emplace

pull/4703/head
Aaron Gokaslan 2022-09-02 11:20:02 -04:00
parent e3b01e10db
commit 411171fa45
17 changed files with 56 additions and 69 deletions

View File

@ -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;

View File

@ -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;

View File

@ -3319,7 +3319,7 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList(const std::vector<c
}
}
inputs.push_back(std::make_tuple(Keys, Values, mapto));
inputs.emplace_back(Keys, Values, mapto);
}
}
return inputs; // pray for NRVO :-)
@ -3396,7 +3396,7 @@ FBXConverter::KeyFrameListList FBXConverter::GetRotationKeyframeList(const std::
}
}
}
inputs.push_back(std::make_tuple(Keys, Values, mapto));
inputs.emplace_back(Keys, Values, mapto);
}
}
return inputs;

View File

@ -399,7 +399,7 @@ void MergeWindowContours (const std::vector<IfcVector2>& 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<IfcVector2>& 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<IfcVector2>& 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<IfcVector2>& 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<IfcVector2>& 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<IfcVector2>& 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<TempOpening>& openings,
if(!temp_contour.empty()) {
if (generate_connection_geometry) {
contours_to_openings.push_back(std::vector<TempOpening*>(
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<TempOpening>& 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<TempOpening>& 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)) {

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -269,43 +269,30 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
dynamic_cast<pmx::PmxVertexSkinningSDEF *>(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<pmx::PmxVertexSkinningQDEF *>(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;
}
}

View File

@ -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;

View File

@ -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<unsigned int,aiNode*>(static_cast<unsigned int>(meshes.size()),(aiNode*)0));
mSubMeshIndices[a].emplace_back(static_cast<unsigned int>(meshes.size()), (aiNode *)0);
meshes.push_back(srcMesh);
}
}

View File

@ -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<unsigned int, float>(i, weight.mWeight));
avPerVertexWeights[weight.mVertexId].emplace_back(i, weight.mWeight);
}
}
return avPerVertexWeights;

View File

@ -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);
}
}

View File

@ -173,7 +173,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
if (bone->mWeights[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!");

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -125,10 +125,10 @@ public:
ai_assert(expect);
fseek(actual,0,SEEK_END);
lengths.push(std::make_pair(static_cast<uint32_t>(ftell(actual)),0));
lengths.emplace(static_cast<uint32_t>(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;
}