Made use of smart pointers :)

Former-commit-id: 5380752e0da3f4b958a944e41fcde38722e3c4c2
This commit is contained in:
Lynix
2013-05-23 02:13:45 +02:00
parent c934d8ed6b
commit 738788b4c3
6 changed files with 63 additions and 95 deletions

View File

@@ -11,6 +11,7 @@
#include <Nazara/Utility/Mesh.hpp>
#include <Nazara/Utility/Skeleton.hpp>
#include <Nazara/Utility/VertexStruct.hpp>
#include <memory>
#include <vector>
#include <Nazara/Utility/Debug.hpp>
@@ -132,10 +133,10 @@ namespace
struct NzSkeletalMeshImpl
{
std::unique_ptr<nzUInt8[]> bindPoseBuffer;
std::vector<NzVertexWeight> vertexWeights;
std::vector<NzWeight> weights;
NzCubef aabb;
nzUInt8* bindPoseBuffer;
NzIndexBufferConstRef indexBuffer;
unsigned int vertexCount;
};
@@ -169,7 +170,7 @@ bool NzSkeletalMesh::Create(unsigned int vertexCount, unsigned int weightCount)
#endif
m_impl = new NzSkeletalMeshImpl;
m_impl->bindPoseBuffer = new nzUInt8[vertexCount*sizeof(NzMeshVertex)];
m_impl->bindPoseBuffer.reset(new nzUInt8[vertexCount*sizeof(NzMeshVertex)]);
m_impl->vertexCount = vertexCount;
m_impl->vertexWeights.resize(vertexCount);
m_impl->weights.resize(weightCount);
@@ -181,7 +182,6 @@ void NzSkeletalMesh::Destroy()
{
if (m_impl)
{
delete[] m_impl->bindPoseBuffer;
delete m_impl;
m_impl = nullptr;
}
@@ -217,7 +217,7 @@ void* NzSkeletalMesh::GetBindPoseBuffer()
}
#endif
return m_impl->bindPoseBuffer;
return m_impl->bindPoseBuffer.get();
}
const void* NzSkeletalMesh::GetBindPoseBuffer() const
@@ -230,7 +230,7 @@ const void* NzSkeletalMesh::GetBindPoseBuffer() const
}
#endif
return m_impl->bindPoseBuffer;
return m_impl->bindPoseBuffer.get();
}
const NzIndexBuffer* NzSkeletalMesh::GetIndexBuffer() const
@@ -358,7 +358,7 @@ void NzSkeletalMesh::Skin(NzMeshVertex* outputBuffer, const NzSkeleton* skeleton
#endif
SkinningInfos skinningInfos;
skinningInfos.inputVertex = reinterpret_cast<const NzMeshVertex*>(m_impl->bindPoseBuffer);
skinningInfos.inputVertex = reinterpret_cast<const NzMeshVertex*>(m_impl->bindPoseBuffer.get());
skinningInfos.outputVertex = outputBuffer;
skinningInfos.joints = skeleton->GetJoints();
skinningInfos.vertexWeights = &m_impl->vertexWeights[0];