Fixed OnResourceDestroy callback not called by the destructor

Former-commit-id: 8b961101f88343ddd3bb382d2c333052efb03164
This commit is contained in:
Lynix 2013-09-03 13:57:32 +02:00
parent 76abb5bf16
commit bed20692a6
10 changed files with 34 additions and 10 deletions

View File

@ -46,7 +46,7 @@ class NAZARA_API NzMaterial : public NzResource
NzMaterial();
NzMaterial(const NzMaterial& material);
NzMaterial(NzMaterial&& material);
~NzMaterial() = default;
~NzMaterial();
void Apply(const NzShaderProgram* program) const;

View File

@ -25,7 +25,7 @@ class NAZARA_API NzIndexBuffer : public NzResource
NzIndexBuffer(bool largeIndices, unsigned int length, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
NzIndexBuffer(const NzIndexBuffer& indexBuffer);
NzIndexBuffer(NzIndexBuffer&& indexBuffer) noexcept;
~NzIndexBuffer() = default;
~NzIndexBuffer();
unsigned int ComputeCacheMissCount() const;

View File

@ -26,7 +26,7 @@ class NAZARA_API NzVertexBuffer : public NzResource
NzVertexBuffer(const NzVertexDeclaration* vertexDeclaration, unsigned int length, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
NzVertexBuffer(NzVertexBuffer&& vertexBuffer) noexcept;
~NzVertexBuffer() = default;
~NzVertexBuffer();
bool Fill(const void* data, unsigned int startVertex, unsigned int length, bool forceDiscard = false);
bool FillRaw(const void* data, unsigned int offset, unsigned int size, bool forceDiscard = false);

View File

@ -26,7 +26,7 @@ class NAZARA_API NzVertexDeclaration : public NzResource
public:
NzVertexDeclaration();
NzVertexDeclaration(NzVertexDeclaration& declaration);
~NzVertexDeclaration() = default;
~NzVertexDeclaration();
void DisableAttribute(nzAttributeUsage usage);
void EnableAttribute(nzAttributeUsage usage, nzAttributeType type, unsigned int offset);

View File

@ -43,6 +43,11 @@ NzMaterial::NzMaterial(NzMaterial&& material)
unit.program.Reset();
}
NzMaterial::~NzMaterial()
{
NotifyDestroy();
}
void NzMaterial::Apply(const NzShaderProgram* program) const
{
int alphaThresholdLocation = program->GetUniformLocation(nzShaderUniform_MaterialAlphaThreshold);

View File

@ -41,6 +41,11 @@ m_startOffset(indexBuffer.m_startOffset)
{
}
NzIndexBuffer::~NzIndexBuffer()
{
NotifyDestroy();
}
unsigned int NzIndexBuffer::ComputeCacheMissCount() const
{
NzIndexMapper mapper(this);

View File

@ -182,6 +182,8 @@ void NzSkeletalMesh::Destroy()
{
if (m_impl)
{
NotifyDestroy();
delete m_impl;
m_impl = nullptr;
}

View File

@ -40,14 +40,16 @@ bool NzStaticMesh::Create(NzVertexBuffer* vertexBuffer)
void NzStaticMesh::Destroy()
{
if (m_indexBuffer)
{
m_indexBuffer->RemoveResourceListener(this);
m_indexBuffer = nullptr;
}
if (m_vertexBuffer)
{
NotifyDestroy();
if (m_indexBuffer)
{
m_indexBuffer->RemoveResourceListener(this);
m_indexBuffer = nullptr;
}
m_vertexBuffer->RemoveResourceListener(this);
m_vertexBuffer = nullptr;
}

View File

@ -36,6 +36,11 @@ m_vertexCount(vertexBuffer.m_vertexCount)
{
}
NzVertexBuffer::~NzVertexBuffer()
{
NotifyDestroy();
}
bool NzVertexBuffer::Fill(const void* data, unsigned int startVertex, unsigned int length, bool forceDiscard)
{
unsigned int stride = m_vertexDeclaration->GetStride();

View File

@ -53,6 +53,11 @@ m_stride(declaration.m_stride)
std::memcpy(m_attributes, declaration.m_attributes, sizeof(Attribute)*(nzAttributeUsage_Max+1));
}
NzVertexDeclaration::~NzVertexDeclaration()
{
NotifyDestroy();
}
void NzVertexDeclaration::DisableAttribute(nzAttributeUsage usage)
{
#ifdef NAZARA_DEBUG