From 7c9c0830a9614c4b5f48c179228fa62761a65ed6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 31 May 2014 19:49:48 +0200 Subject: [PATCH] Fix errors due to BaseWhite material being removed --- components/terrain/chunk.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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;