diff --git a/OgreMain/include/OgreTextureUnitState.h b/OgreMain/include/OgreTextureUnitState.h index 8caf0af4935..90f147040eb 100644 --- a/OgreMain/include/OgreTextureUnitState.h +++ b/OgreMain/include/OgreTextureUnitState.h @@ -947,6 +947,10 @@ namespace Ogre { */ void setProjectiveTexturing(bool enabled, const Frustum* projectionSettings = 0); + /** Gets the Frustum which is being used to derive projective texturing parameters. + */ + const Frustum* getProjectiveTexturingFrustum(void) const; + /** Removes all effects applied to this texture layer. */ void removeAllEffects(void); diff --git a/OgreMain/src/OgreRenderSystem.cpp b/OgreMain/src/OgreRenderSystem.cpp index ad0349ff2c4..0dd3148d695 100644 --- a/OgreMain/src/OgreRenderSystem.cpp +++ b/OgreMain/src/OgreRenderSystem.cpp @@ -444,8 +444,7 @@ namespace Ogre { auto calcMode = tl._deriveTexCoordCalcMethod(); if(calcMode == TEXCALC_PROJECTIVE_TEXTURE) { - auto frustum = tl.getEffects().find(TextureUnitState::ET_PROJECTIVE_TEXTURE)->second.frustum; - _setTextureCoordCalculation(texUnit, calcMode, frustum); + _setTextureCoordCalculation(texUnit, calcMode, tl.getProjectiveTexturingFrustum()); } else { diff --git a/OgreMain/src/OgreSceneManager.cpp b/OgreMain/src/OgreSceneManager.cpp index 7b4c0ceb5fd..71fa31da977 100644 --- a/OgreMain/src/OgreSceneManager.cpp +++ b/OgreMain/src/OgreSceneManager.cpp @@ -812,10 +812,9 @@ const Pass* SceneManager::_setPass(const Pass* pass, bool shadowDerivation) { // Manually set texture projector for shaders if present // This won't get set any other way if using manual projection - auto effi = pTex->getEffects().find(TextureUnitState::ET_PROJECTIVE_TEXTURE); - if (effi != pTex->getEffects().end()) + if (auto frustum = pTex->getProjectiveTexturingFrustum()) { - mAutoParamDataSource->setTextureProjector(effi->second.frustum, unit); + mAutoParamDataSource->setTextureProjector(frustum, unit); } } if (pTex->getContentType() == TextureUnitState::CONTENT_COMPOSITOR) diff --git a/OgreMain/src/OgreTextureUnitState.cpp b/OgreMain/src/OgreTextureUnitState.cpp index 37bda7b4d07..c7981e552e7 100644 --- a/OgreMain/src/OgreTextureUnitState.cpp +++ b/OgreMain/src/OgreTextureUnitState.cpp @@ -1170,6 +1170,16 @@ namespace Ogre { } } + const Frustum* TextureUnitState::getProjectiveTexturingFrustum() const + { + EffectMap::const_iterator i = mEffects.find(ET_PROJECTIVE_TEXTURE); + if (i != mEffects.end()) + { + return i->second.frustum; + } + + return 0; + } //----------------------------------------------------------------------- void TextureUnitState::setName(const String& name) {