diff --git a/components/terrain/chunk.cpp b/components/terrain/chunk.cpp index 7ecafda5e..57db15124 100644 --- a/components/terrain/chunk.cpp +++ b/components/terrain/chunk.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -56,7 +57,11 @@ namespace Terrain mVertexData->vertexBufferBinding->setBinding(3, colourBuffer); // Assign a default material in case terrain material fails to be created - mMaterial = Ogre::MaterialManager::getSingleton().getByName("BaseWhite"); + // Since we are removing this material in the destructor, it must be cloned from BaseWhite + // so the original always stays available. + static int materialCount=0; + mMaterial = Ogre::MaterialManager::getSingleton().getByName("BaseWhite") + ->clone("BaseWhite"+Ogre::StringConverter::toString(++materialCount)); mIndexData = OGRE_NEW Ogre::IndexData(); mIndexData->indexStart = 0;