diff --git a/ogre/src/OgreRTShaderSystem.cc b/ogre/src/OgreRTShaderSystem.cc index 4bf49bea1..a3094683d 100644 --- a/ogre/src/OgreRTShaderSystem.cc +++ b/ogre/src/OgreRTShaderSystem.cc @@ -70,6 +70,9 @@ class ignition::rendering::OgreRTShaderSystemPrivate /// \brief Flag to indicate shadows need to be reapplied public: bool resetShadows = false; + + /// \brief thread that shader system is created in + public: std::thread::id threadId; }; using namespace ignition; @@ -86,12 +89,17 @@ OgreRTShaderSystem::OgreRTShaderSystem() #else this->dataPtr->pssmSetup.reset(); #endif + + this->dataPtr->threadId = std::this_thread::get_id(); } ////////////////////////////////////////////////// OgreRTShaderSystem::~OgreRTShaderSystem() { - this->Fini(); + if (std::this_thread::get_id() == this->dataPtr->threadId) + { + this->Fini(); + } } //////////////////////////////////////////////////