mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 08:37:12 +00:00
Replace new with make_unique in components
This commit is contained in:
parent
f84be8c3f9
commit
a95b6e050a
@ -21,8 +21,7 @@ void DataManager::setResourcePath(const std::string &path)
|
|||||||
MyGUI::IDataStream *DataManager::getData(const std::string &name) const
|
MyGUI::IDataStream *DataManager::getData(const std::string &name) const
|
||||||
{
|
{
|
||||||
std::string fullpath = getDataPath(name);
|
std::string fullpath = getDataPath(name);
|
||||||
std::unique_ptr<std::ifstream> stream;
|
auto stream = std::make_unique<std::ifstream>();
|
||||||
stream.reset(new std::ifstream);
|
|
||||||
stream->open(fullpath, std::ios::binary);
|
stream->open(fullpath, std::ios::binary);
|
||||||
if (stream->fail())
|
if (stream->fail())
|
||||||
{
|
{
|
||||||
|
@ -140,7 +140,7 @@ std::monostate fillTriangleMesh(std::unique_ptr<btTriangleMesh>& mesh, const Nif
|
|||||||
return handleNiGeometry(geometry, [&] (const auto& data)
|
return handleNiGeometry(geometry, [&] (const auto& data)
|
||||||
{
|
{
|
||||||
if (mesh == nullptr)
|
if (mesh == nullptr)
|
||||||
mesh.reset(new btTriangleMesh(false));
|
mesh = std::make_unique<btTriangleMesh>(false);
|
||||||
fillTriangleMesh(*mesh, data, transform);
|
fillTriangleMesh(*mesh, data, transform);
|
||||||
return std::monostate {};
|
return std::monostate {};
|
||||||
});
|
});
|
||||||
@ -150,7 +150,7 @@ std::unique_ptr<btTriangleMesh> makeChildMesh(const Nif::NiGeometry& geometry)
|
|||||||
{
|
{
|
||||||
return handleNiGeometry(geometry, [&] (const auto& data)
|
return handleNiGeometry(geometry, [&] (const auto& data)
|
||||||
{
|
{
|
||||||
std::unique_ptr<btTriangleMesh> mesh(new btTriangleMesh);
|
auto mesh = std::make_unique<btTriangleMesh>();
|
||||||
fillTriangleMesh(*mesh, data, osg::Matrixf());
|
fillTriangleMesh(*mesh, data, osg::Matrixf());
|
||||||
return mesh;
|
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 extents = Misc::Convert::toBullet(mShape->mCollisionBox.mExtents);
|
||||||
const btVector3 center = Misc::Convert::toBullet(mShape->mCollisionBox.mCenter);
|
const btVector3 center = Misc::Convert::toBullet(mShape->mCollisionBox.mCenter);
|
||||||
std::unique_ptr<btCompoundShape> compound (new btCompoundShape);
|
auto compound = std::make_unique<btCompoundShape>();
|
||||||
std::unique_ptr<btBoxShape> boxShape(new btBoxShape(extents));
|
auto boxShape = std::make_unique<btBoxShape>(extents);
|
||||||
btTransform transform = btTransform::getIdentity();
|
btTransform transform = btTransform::getIdentity();
|
||||||
transform.setOrigin(center);
|
transform.setOrigin(center);
|
||||||
compound->addChildShape(transform, boxShape.get());
|
compound->addChildShape(transform, boxShape.get());
|
||||||
@ -226,7 +226,7 @@ osg::ref_ptr<Resource::BulletShape> BulletNifLoader::load(const Nif::File& nif)
|
|||||||
{
|
{
|
||||||
btTransform trans;
|
btTransform trans;
|
||||||
trans.setIdentity();
|
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());
|
mCompoundShape->addChildShape(trans, child.get());
|
||||||
child.release();
|
child.release();
|
||||||
mStaticMesh.release();
|
mStaticMesh.release();
|
||||||
@ -407,7 +407,7 @@ void BulletNifLoader::handleNiTriShape(const Nif::NiGeometry& niGeometry, const
|
|||||||
if (!mCompoundShape)
|
if (!mCompoundShape)
|
||||||
mCompoundShape.reset(new btCompoundShape);
|
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();
|
childMesh.release();
|
||||||
|
|
||||||
float scale = niGeometry.trafo.scale;
|
float scale = niGeometry.trafo.scale;
|
||||||
|
@ -13,10 +13,10 @@ namespace Resource
|
|||||||
ResourceSystem::ResourceSystem(const VFS::Manager *vfs)
|
ResourceSystem::ResourceSystem(const VFS::Manager *vfs)
|
||||||
: mVFS(vfs)
|
: mVFS(vfs)
|
||||||
{
|
{
|
||||||
mNifFileManager.reset(new NifFileManager(vfs));
|
mNifFileManager = std::make_unique<NifFileManager>(vfs);
|
||||||
mImageManager.reset(new ImageManager(vfs));
|
mImageManager = std::make_unique<ImageManager>(vfs);
|
||||||
mSceneManager.reset(new SceneManager(vfs, mImageManager.get(), mNifFileManager.get()));
|
mSceneManager = std::make_unique<SceneManager>(vfs, mImageManager.get(), mNifFileManager.get());
|
||||||
mKeyframeManager.reset(new KeyframeManager(vfs, mSceneManager.get()));
|
mKeyframeManager = std::make_unique<KeyframeManager>(vfs, mSceneManager.get());
|
||||||
|
|
||||||
addResourceManager(mNifFileManager.get());
|
addResourceManager(mNifFileManager.get());
|
||||||
addResourceManager(mKeyframeManager.get());
|
addResourceManager(mKeyframeManager.get());
|
||||||
|
@ -69,7 +69,7 @@ Bone* Skeleton::getBone(const std::string &name)
|
|||||||
|
|
||||||
if (!mRootBone.get())
|
if (!mRootBone.get())
|
||||||
{
|
{
|
||||||
mRootBone.reset(new Bone);
|
mRootBone = std::make_unique<Bone>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bone* bone = mRootBone.get();
|
Bone* bone = mRootBone.get();
|
||||||
|
@ -287,7 +287,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour
|
|||||||
|
|
||||||
if (mDebugTerrainChunks)
|
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());
|
addChunkManager(mDebugChunkManager.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
|||||||
|
|
||||||
mParent->addChild(mTerrainRoot);
|
mParent->addChild(mTerrainRoot);
|
||||||
|
|
||||||
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager()));
|
mTextureManager = std::make_unique<TextureManager>(mResourceSystem->getSceneManager());
|
||||||
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer));
|
mChunkManager = std::make_unique<ChunkManager>(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer);
|
||||||
mChunkManager->setNodeMask(nodeMask);
|
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(mChunkManager.get());
|
||||||
mResourceSystem->addResourceManager(mTextureManager.get());
|
mResourceSystem->addResourceManager(mTextureManager.get());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user