Skip to content

Commit

Permalink
Main: TextureUnitState - add getProjectiveTexturingFrustum
Browse files Browse the repository at this point in the history
to reduce getEffects() usage
  • Loading branch information
paroj committed Aug 20, 2024
1 parent 584766d commit d89e833
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions OgreMain/include/OgreTextureUnitState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions OgreMain/src/OgreRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
5 changes: 2 additions & 3 deletions OgreMain/src/OgreSceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions OgreMain/src/OgreTextureUnitState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit d89e833

Please sign in to comment.