diff --git a/components/terrain/chunk.cpp b/components/terrain/chunk.cpp index cf6c99cf4..624809229 100644 --- a/components/terrain/chunk.cpp +++ b/components/terrain/chunk.cpp @@ -3,6 +3,10 @@ #include #include #include +#include + +#include + #include "world.hpp" // FIXME: for LoadResponseData, move to backgroundloader.hpp @@ -63,6 +67,11 @@ namespace Terrain Chunk::~Chunk() { +#if TERRAIN_USE_SHADER + sh::Factory::getInstance().destroyMaterialInstance(mMaterial->getName()); +#endif + Ogre::MaterialManager::getSingleton().remove(mMaterial->getName()); + OGRE_DELETE mVertexData; OGRE_DELETE mIndexData; } diff --git a/components/terrain/chunk.hpp b/components/terrain/chunk.hpp index d198de264..9a7d20fb8 100644 --- a/components/terrain/chunk.hpp +++ b/components/terrain/chunk.hpp @@ -20,6 +20,7 @@ namespace Terrain virtual ~Chunk(); + /// @note Takes ownership of \a material void setMaterial (const Ogre::MaterialPtr& material); void setIndexBuffer(Ogre::HardwareIndexBufferSharedPtr buffer);