diff --git a/Src/ModelLoadCMO.cpp b/Src/ModelLoadCMO.cpp index 19249b168..6b904e1a0 100644 --- a/Src/ModelLoadCMO.cpp +++ b/Src/ModelLoadCMO.cpp @@ -767,7 +767,7 @@ std::unique_ptr DirectX::Model::CreateFromCMO( auto& mat = materials[sm.MaterialIndex]; - auto part = new ModelMeshPart(); + auto part = std::make_unique(); if (mat.pMaterial->Diffuse.w < 1) part->isAlpha = true; @@ -781,7 +781,7 @@ std::unique_ptr DirectX::Model::CreateFromCMO( part->effect = mat.effect; part->vbDecl = enableSkinning ? g_vbdeclSkinning : g_vbdecl; - mesh->meshParts.emplace_back(part); + mesh->meshParts.emplace_back(std::move(part)); } model->meshes.emplace_back(mesh); diff --git a/Src/ModelLoadSDKMESH.cpp b/Src/ModelLoadSDKMESH.cpp index 204538a8a..a2f2dabf7 100644 --- a/Src/ModelLoadSDKMESH.cpp +++ b/Src/ModelLoadSDKMESH.cpp @@ -704,7 +704,7 @@ std::unique_ptr DirectX::Model::CreateFromSDKMESH( SetDebugObjectName(il.Get(), "ModelSDKMESH"); - auto part = new ModelMeshPart(); + auto part = std::make_unique(); part->isAlpha = mat.alpha; part->indexCount = static_cast(subset.IndexCount); @@ -719,7 +719,7 @@ std::unique_ptr DirectX::Model::CreateFromSDKMESH( part->effect = mat.effect; part->vbDecl = vbDecls[mh.VertexBuffers[0]]; - mesh->meshParts.emplace_back(part); + mesh->meshParts.emplace_back(std::move(part)); } model->meshes.emplace_back(mesh); diff --git a/Src/ModelLoadVBO.cpp b/Src/ModelLoadVBO.cpp index 1d136d9d9..67a96a6bb 100644 --- a/Src/ModelLoadVBO.cpp +++ b/Src/ModelLoadVBO.cpp @@ -152,7 +152,7 @@ std::unique_ptr DirectX::Model::CreateFromVBO( SetDebugObjectName(il.Get(), "ModelVBO"); - auto part = new ModelMeshPart(); + auto part = std::make_unique(); part->indexCount = header->numIndices; part->startIndex = 0; part->vertexStride = static_cast(sizeof(VertexPositionNormalTexture)); @@ -167,9 +167,11 @@ std::unique_ptr DirectX::Model::CreateFromVBO( mesh->pmalpha = (flags & ModelLoader_PremultipledAlpha) != 0; BoundingSphere::CreateFromPoints(mesh->boundingSphere, header->numVertices, &verts->position, sizeof(VertexPositionNormalTexture)); BoundingBox::CreateFromPoints(mesh->boundingBox, header->numVertices, &verts->position, sizeof(VertexPositionNormalTexture)); - mesh->meshParts.emplace_back(part); + mesh->meshParts.reserve(1); + mesh->meshParts.emplace_back(std::move(part)); auto model = std::make_unique(); + model->meshes.reserve(1); model->meshes.emplace_back(mesh); return model;