diff --git a/src/Core/Resource/Factory/CCollisionLoader.cpp b/src/Core/Resource/Factory/CCollisionLoader.cpp index 80039eb9..357c7601 100644 --- a/src/Core/Resource/Factory/CCollisionLoader.cpp +++ b/src/Core/Resource/Factory/CCollisionLoader.cpp @@ -23,31 +23,31 @@ CCollisionMesh::CCollisionOctree::SLeaf* CCollisionLoader::ParseOctreeLeaf(IInpu } #endif -SOBBTreeNode* CCollisionLoader::ParseOBBNode(IInputStream& DCLN) +std::unique_ptr CCollisionLoader::ParseOBBNode(IInputStream& DCLN) const { - SOBBTreeNode* pOut = nullptr; + std::unique_ptr pOut; - CTransform4f Transform(DCLN); - CVector3f Radius(DCLN); - bool IsLeaf = DCLN.ReadBool(); + const CTransform4f Transform(DCLN); + const CVector3f Radius(DCLN); + const bool IsLeaf = DCLN.ReadBool(); if (IsLeaf) { - SOBBTreeLeaf* pLeaf = new SOBBTreeLeaf; - uint NumTris = DCLN.ReadLong(); + auto pLeaf = std::make_unique(); + const uint NumTris = DCLN.ReadLong(); pLeaf->TriangleIndices.resize(NumTris); - for (uint i=0; iTriangleIndices[i] = DCLN.ReadShort(); - pOut = pLeaf; + pOut = std::move(pLeaf); } else { - SOBBTreeBranch* pBranch = new SOBBTreeBranch; - pBranch->pLeft = std::unique_ptr( ParseOBBNode(DCLN) ); - pBranch->pRight = std::unique_ptr( ParseOBBNode(DCLN) ); - pOut = pBranch; + auto pBranch = std::make_unique(); + pBranch->pLeft = ParseOBBNode(DCLN); + pBranch->pRight = ParseOBBNode(DCLN); + pOut = std::move(pBranch); } pOut->Transform = Transform; @@ -271,7 +271,7 @@ std::unique_ptr CCollisionLoader::LoadDCLN(IInputStream& rD // Parse OBB tree CCollidableOBBTree* pOBBTree = static_cast(Loader.mpMesh); - pOBBTree->mpOBBTree = std::unique_ptr( Loader.ParseOBBNode(rDCLN) ); + pOBBTree->mpOBBTree = Loader.ParseOBBNode(rDCLN); } return ptr; diff --git a/src/Core/Resource/Factory/CCollisionLoader.h b/src/Core/Resource/Factory/CCollisionLoader.h index 200e2475..36141982 100644 --- a/src/Core/Resource/Factory/CCollisionLoader.h +++ b/src/Core/Resource/Factory/CCollisionLoader.h @@ -6,6 +6,8 @@ #include "Core/Resource/Collision/CCollidableOBBTree.h" #include +#include + class CCollisionLoader { TResPtr mpGroup; @@ -20,9 +22,9 @@ class CCollisionLoader CCollisionMesh::CCollisionOctree::SLeaf* ParseOctreeLeaf(IInputStream& rSrc); #endif - SOBBTreeNode* ParseOBBNode(IInputStream& DCLN); - void LoadCollisionMaterial(IInputStream& Src, CCollisionMaterial& OutMaterial); - void LoadCollisionIndices(IInputStream& File, SCollisionIndexData& OutData); + std::unique_ptr ParseOBBNode(IInputStream& DCLN) const; + void LoadCollisionMaterial(IInputStream& Src, CCollisionMaterial& OutMaterial); + void LoadCollisionIndices(IInputStream& File, SCollisionIndexData& OutData); public: static std::unique_ptr LoadAreaCollision(IInputStream& rMREA);