From 643e7651e0980d93bdd2e6c63351461c405fe22e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 4 Aug 2013 18:31:12 -0700 Subject: [PATCH] Use a null material for non-SubEntities in the selection buffer --- libs/openengine/ogre/selectionbuffer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/openengine/ogre/selectionbuffer.cpp b/libs/openengine/ogre/selectionbuffer.cpp index 30e7b9e1e..69375b74d 100644 --- a/libs/openengine/ogre/selectionbuffer.cpp +++ b/libs/openengine/ogre/selectionbuffer.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -100,7 +101,16 @@ namespace Render return m->getTechnique(1); } else - throw std::runtime_error("selectionbuffer only works with entities"); + { + m = Ogre::MaterialManager::getSingleton().getByName("NullMaterial"); + if(m.isNull()) + { + m = Ogre::MaterialManager::getSingleton().create("NullMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + m->getTechnique(0)->getPass(0)->setDepthCheckEnabled(true); + m->getTechnique(0)->getPass(0)->setDepthFunction(Ogre::CMPF_ALWAYS_FAIL); + } + return m->getTechnique(0); + } } return NULL; }