mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 07:39:41 +00:00
Replace new with make_unique in components
This commit is contained in:
parent
f84be8c3f9
commit
a95b6e050a
6 changed files with 16 additions and 17 deletions
|
@ -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<std::ifstream> stream;
|
||||
stream.reset(new std::ifstream);
|
||||
auto stream = std::make_unique<std::ifstream>();
|
||||
stream->open(fullpath, std::ios::binary);
|
||||
if (stream->fail())
|
||||
{
|
||||
|
|
|
@ -140,7 +140,7 @@ std::monostate fillTriangleMesh(std::unique_ptr<btTriangleMesh>& mesh, const Nif
|
|||
return handleNiGeometry(geometry, [&] (const auto& data)
|
||||
{
|
||||
if (mesh == nullptr)
|
||||
mesh.reset(new btTriangleMesh(false));
|
||||
mesh = std::make_unique<btTriangleMesh>(false);
|
||||
fillTriangleMesh(*mesh, data, transform);
|
||||
return std::monostate {};
|
||||
});
|
||||
|
@ -150,7 +150,7 @@ std::unique_ptr<btTriangleMesh> makeChildMesh(const Nif::NiGeometry& geometry)
|
|||
{
|
||||
return handleNiGeometry(geometry, [&] (const auto& data)
|
||||
{
|
||||
std::unique_ptr<btTriangleMesh> mesh(new btTriangleMesh);
|
||||
auto mesh = std::make_unique<btTriangleMesh>();
|
||||
fillTriangleMesh(*mesh, data, osg::Matrixf());
|
||||
return mesh;
|
||||
});
|
||||
|
@ -197,8 +197,8 @@ osg::ref_ptr<Resource::BulletShape> 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<btCompoundShape> compound (new btCompoundShape);
|
||||
std::unique_ptr<btBoxShape> boxShape(new btBoxShape(extents));
|
||||
auto compound = std::make_unique<btCompoundShape>();
|
||||
auto boxShape = std::make_unique<btBoxShape>(extents);
|
||||
btTransform transform = btTransform::getIdentity();
|
||||
transform.setOrigin(center);
|
||||
compound->addChildShape(transform, boxShape.get());
|
||||
|
@ -226,7 +226,7 @@ osg::ref_ptr<Resource::BulletShape> BulletNifLoader::load(const Nif::File& nif)
|
|||
{
|
||||
btTransform trans;
|
||||
trans.setIdentity();
|
||||
std::unique_ptr<btCollisionShape> child(new Resource::TriangleMeshShape(mStaticMesh.get(), true));
|
||||
std::unique_ptr<btCollisionShape> child = std::make_unique<Resource::TriangleMeshShape>(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<Resource::TriangleMeshShape> childShape(new Resource::TriangleMeshShape(childMesh.get(), true));
|
||||
auto childShape = std::make_unique<Resource::TriangleMeshShape>(childMesh.get(), true);
|
||||
childMesh.release();
|
||||
|
||||
float scale = niGeometry.trafo.scale;
|
||||
|
|
|
@ -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<NifFileManager>(vfs);
|
||||
mImageManager = std::make_unique<ImageManager>(vfs);
|
||||
mSceneManager = std::make_unique<SceneManager>(vfs, mImageManager.get(), mNifFileManager.get());
|
||||
mKeyframeManager = std::make_unique<KeyframeManager>(vfs, mSceneManager.get());
|
||||
|
||||
addResourceManager(mNifFileManager.get());
|
||||
addResourceManager(mKeyframeManager.get());
|
||||
|
|
|
@ -69,7 +69,7 @@ Bone* Skeleton::getBone(const std::string &name)
|
|||
|
||||
if (!mRootBone.get())
|
||||
{
|
||||
mRootBone.reset(new Bone);
|
||||
mRootBone = std::make_unique<Bone>();
|
||||
}
|
||||
|
||||
Bone* bone = mRootBone.get();
|
||||
|
|
|
@ -287,7 +287,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour
|
|||
|
||||
if (mDebugTerrainChunks)
|
||||
{
|
||||
mDebugChunkManager = std::unique_ptr<DebugChunkManager>(new DebugChunkManager(mResourceSystem->getSceneManager(), mStorage, borderMask));
|
||||
mDebugChunkManager = std::make_unique<DebugChunkManager>(mResourceSystem->getSceneManager(), mStorage, borderMask);
|
||||
addChunkManager(mDebugChunkManager.get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<TextureManager>(mResourceSystem->getSceneManager());
|
||||
mChunkManager = std::make_unique<ChunkManager>(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer);
|
||||
mChunkManager->setNodeMask(nodeMask);
|
||||
mCellBorder.reset(new CellBorder(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager()));
|
||||
mCellBorder = std::make_unique<CellBorder>(this,mTerrainRoot.get(),borderMask,mResourceSystem->getSceneManager());
|
||||
|
||||
mResourceSystem->addResourceManager(mChunkManager.get());
|
||||
mResourceSystem->addResourceManager(mTextureManager.get());
|
||||
|
|
Loading…
Reference in a new issue