From a95b6e050ac1eb91071dce232a80e74f69f76255 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 29 May 2022 13:24:32 +0200 Subject: [PATCH] Replace new with make_unique in components --- components/myguiplatform/myguidatamanager.cpp | 3 +-- components/nifbullet/bulletnifloader.cpp | 12 ++++++------ components/resource/resourcesystem.cpp | 8 ++++---- components/sceneutil/skeleton.cpp | 2 +- components/terrain/quadtreeworld.cpp | 2 +- components/terrain/world.cpp | 6 +++--- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index 62023c8366..b01c5bbcf6 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -21,8 +21,7 @@ void DataManager::setResourcePath(const std::string &path) MyGUI::IDataStream *DataManager::getData(const std::string &name) const { std::string fullpath = getDataPath(name); - std::unique_ptr stream; - stream.reset(new std::ifstream); + auto stream = std::make_unique(); stream->open(fullpath, std::ios::binary); if (stream->fail()) { diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 52be8d4a07..364f79e98e 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -140,7 +140,7 @@ std::monostate fillTriangleMesh(std::unique_ptr& mesh, const Nif return handleNiGeometry(geometry, [&] (const auto& data) { if (mesh == nullptr) - mesh.reset(new btTriangleMesh(false)); + mesh = std::make_unique(false); fillTriangleMesh(*mesh, data, transform); return std::monostate {}; }); @@ -150,7 +150,7 @@ std::unique_ptr makeChildMesh(const Nif::NiGeometry& geometry) { return handleNiGeometry(geometry, [&] (const auto& data) { - std::unique_ptr mesh(new btTriangleMesh); + auto mesh = std::make_unique(); fillTriangleMesh(*mesh, data, osg::Matrixf()); return mesh; }); @@ -197,8 +197,8 @@ osg::ref_ptr BulletNifLoader::load(const Nif::File& nif) { const btVector3 extents = Misc::Convert::toBullet(mShape->mCollisionBox.mExtents); const btVector3 center = Misc::Convert::toBullet(mShape->mCollisionBox.mCenter); - std::unique_ptr compound (new btCompoundShape); - std::unique_ptr boxShape(new btBoxShape(extents)); + auto compound = std::make_unique(); + auto boxShape = std::make_unique(extents); btTransform transform = btTransform::getIdentity(); transform.setOrigin(center); compound->addChildShape(transform, boxShape.get()); @@ -226,7 +226,7 @@ osg::ref_ptr BulletNifLoader::load(const Nif::File& nif) { btTransform trans; trans.setIdentity(); - std::unique_ptr child(new Resource::TriangleMeshShape(mStaticMesh.get(), true)); + std::unique_ptr child = std::make_unique(mStaticMesh.get(), true); mCompoundShape->addChildShape(trans, child.get()); child.release(); mStaticMesh.release(); @@ -407,7 +407,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const if (!mCompoundShape) mCompoundShape.reset(new btCompoundShape); - std::unique_ptr childShape(new Resource::TriangleMeshShape(childMesh.get(), true)); + auto childShape = std::make_unique(childMesh.get(), true); childMesh.release(); float scale = niGeometry.trafo.scale; diff --git a/components/resource/resourcesystem.cpp b/components/resource/resourcesystem.cpp index ab9d0aba2c..a62dd0016a 100644 --- a/components/resource/resourcesystem.cpp +++ b/components/resource/resourcesystem.cpp @@ -13,10 +13,10 @@ namespace Resource ResourceSystem::ResourceSystem(const VFS::Manager *vfs) : mVFS(vfs) { - mNifFileManager.reset(new NifFileManager(vfs)); - mImageManager.reset(new ImageManager(vfs)); - mSceneManager.reset(new SceneManager(vfs, mImageManager.get(), mNifFileManager.get())); - mKeyframeManager.reset(new KeyframeManager(vfs, mSceneManager.get())); + mNifFileManager = std::make_unique(vfs); + mImageManager = std::make_unique(vfs); + mSceneManager = std::make_unique(vfs, mImageManager.get(), mNifFileManager.get()); + mKeyframeManager = std::make_unique(vfs, mSceneManager.get()); addResourceManager(mNifFileManager.get()); addResourceManager(mKeyframeManager.get()); diff --git a/components/sceneutil/skeleton.cpp b/components/sceneutil/skeleton.cpp index c465333fb4..9f646ade5c 100644 --- a/components/sceneutil/skeleton.cpp +++ b/components/sceneutil/skeleton.cpp @@ -69,7 +69,7 @@ Bone* Skeleton::getBone(const std::string &name) if (!mRootBone.get()) { - mRootBone.reset(new Bone); + mRootBone = std::make_unique(); } Bone* bone = mRootBone.get(); diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index eba69ad42d..1266e440a3 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -287,7 +287,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour if (mDebugTerrainChunks) { - mDebugChunkManager = std::unique_ptr(new DebugChunkManager(mResourceSystem->getSceneManager(), mStorage, borderMask)); + mDebugChunkManager = std::make_unique(mResourceSystem->getSceneManager(), mStorage, borderMask); addChunkManager(mDebugChunkManager.get()); } } diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index 582cc68b1b..186687b37d 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -41,10 +41,10 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst mParent->addChild(mTerrainRoot); - mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager())); - mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer)); + mTextureManager = std::make_unique(mResourceSystem->getSceneManager()); + mChunkManager = std::make_unique(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer); mChunkManager->setNodeMask(nodeMask); - mCellBorder.reset(new CellBorder(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager())); + mCellBorder = std::make_unique(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager()); mResourceSystem->addResourceManager(mChunkManager.get()); mResourceSystem->addResourceManager(mTextureManager.get());