Using unique ptr for indices
This commit is contained in:
@@ -27,8 +27,8 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
#if __has_include("assimp/Exporter.hpp")
|
#if __has_include("assimp/Exporter.hpp")
|
||||||
void SetupAssimpScene(OpenVulkano::Scene::Geometry* geometry, aiScene& scene, aiNode& rootNode, aiMesh& mesh, unsigned int*& indices,
|
void SetupAssimpScene(OpenVulkano::Scene::Geometry* geometry, aiScene& scene, aiNode& rootNode, aiMesh& mesh,
|
||||||
bool withTexCoords, float scaling)
|
std::unique_ptr<unsigned int[]>& indices, bool withTexCoords, float scaling)
|
||||||
{
|
{
|
||||||
mesh.mVertices = nullptr;
|
mesh.mVertices = nullptr;
|
||||||
mesh.mNormals = nullptr;
|
mesh.mNormals = nullptr;
|
||||||
@@ -75,7 +75,7 @@ namespace
|
|||||||
|
|
||||||
mesh.mNumFaces = geometry->indexCount / 3;
|
mesh.mNumFaces = geometry->indexCount / 3;
|
||||||
mesh.mFaces = new aiFace[mesh.mNumFaces];
|
mesh.mFaces = new aiFace[mesh.mNumFaces];
|
||||||
indices = new unsigned int[geometry->indexCount];
|
indices = std::make_unique<unsigned int[]>(geometry->indexCount);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < geometry->indexCount; ++i)
|
for (unsigned int i = 0; i < geometry->indexCount; ++i)
|
||||||
{
|
{
|
||||||
@@ -172,7 +172,7 @@ namespace OpenVulkano::Scene
|
|||||||
std::unique_ptr<aiScene> scene(new aiScene());
|
std::unique_ptr<aiScene> scene(new aiScene());
|
||||||
std::unique_ptr<aiNode> rootNode(new aiNode());
|
std::unique_ptr<aiNode> rootNode(new aiNode());
|
||||||
std::unique_ptr<aiMesh> mesh(new aiMesh());
|
std::unique_ptr<aiMesh> mesh(new aiMesh());
|
||||||
unsigned int* indices = nullptr;
|
std::unique_ptr<unsigned int[]> indices;
|
||||||
|
|
||||||
SetupAssimpScene(geometry, *scene, *rootNode, *mesh, indices, false, 1.0f);
|
SetupAssimpScene(geometry, *scene, *rootNode, *mesh, indices, false, 1.0f);
|
||||||
|
|
||||||
@@ -187,7 +187,6 @@ namespace OpenVulkano::Scene
|
|||||||
aiFace& face = mesh->mFaces[i];
|
aiFace& face = mesh->mFaces[i];
|
||||||
face.mIndices = nullptr;
|
face.mIndices = nullptr;
|
||||||
}
|
}
|
||||||
delete[] indices;
|
|
||||||
|
|
||||||
if (result != aiReturn_SUCCESS)
|
if (result != aiReturn_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -204,7 +203,7 @@ namespace OpenVulkano::Scene
|
|||||||
std::unique_ptr<aiScene> scene(new aiScene());
|
std::unique_ptr<aiScene> scene(new aiScene());
|
||||||
std::unique_ptr<aiNode> rootNode(new aiNode());
|
std::unique_ptr<aiNode> rootNode(new aiNode());
|
||||||
std::unique_ptr<aiMesh> mesh(new aiMesh());
|
std::unique_ptr<aiMesh> mesh(new aiMesh());
|
||||||
unsigned int* indices = nullptr;
|
std::unique_ptr<unsigned int[]> indices;
|
||||||
|
|
||||||
SetupAssimpScene(geometry, *scene, *rootNode, *mesh, indices, true, 100.0f);
|
SetupAssimpScene(geometry, *scene, *rootNode, *mesh, indices, true, 100.0f);
|
||||||
|
|
||||||
@@ -224,7 +223,6 @@ namespace OpenVulkano::Scene
|
|||||||
aiFace& face = mesh->mFaces[i];
|
aiFace& face = mesh->mFaces[i];
|
||||||
face.mIndices = nullptr;
|
face.mIndices = nullptr;
|
||||||
}
|
}
|
||||||
delete[] indices;
|
|
||||||
|
|
||||||
if (result != aiReturn_SUCCESS)
|
if (result != aiReturn_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user