Skip to content

Commit 07c3ec4

Browse files
committed
Main: TUS - split camera based from controller based effects
1 parent 612de95 commit 07c3ec4

File tree

2 files changed

+29
-42
lines changed

2 files changed

+29
-42
lines changed

OgreMain/include/OgreTextureUnitState.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,14 @@ namespace Ogre {
314314
*/
315315
struct TextureEffect {
316316
TextureEffectType type;
317-
float arg1, arg2;
317+
float arg1;
318318
int subtype;
319319
WaveformType waveType;
320320
float base;
321321
float frequency;
322322
float phase;
323323
float amplitude;
324324
ControllerFloat* controller;
325-
const Frustum* frustum;
326325
};
327326

328327
/** Texture effects in a multimap paired array.
@@ -1098,6 +1097,9 @@ namespace Ogre {
10981097
/// The index of the referenced texture if referencing an MRT in a compositor.
10991098
uint32 mCompositorRefMrtIndex;
11001099

1100+
const Frustum* mProjectiveTexturingFrustum;
1101+
TexCoordCalcMethod mTexCoordCalcMethod;
1102+
11011103
//-----------------------------------------------------------------------------
11021104
// Complex members (those that can't be copied using memcpy) are at the end to
11031105
// allow for fast copying of the basic members.

OgreMain/src/OgreTextureUnitState.cpp

+25-40
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ namespace Ogre {
132132
, mTextureLoadFailed(false)
133133
, mRecalcTexMatrix(false)
134134
, mTextureCoordSetIndex(0)
135+
, mProjectiveTexturingFrustum(0)
136+
, mTexCoordCalcMethod(TEXCALC_NONE)
135137
, mFramePtrs(1)
136138
, mSampler(TextureManager::getSingletonPtr() ? TextureManager::getSingleton().getDefaultSampler() : DUMMY_SAMPLER)
137139
, mParent(parent)
@@ -673,13 +675,25 @@ namespace Ogre {
673675
{
674676
if (enable)
675677
{
676-
TextureEffect eff = {ET_ENVIRONMENT_MAP};
677-
eff.subtype = envMapType;
678-
addEffect(eff);
678+
switch (envMapType)
679+
{
680+
case ENV_CURVED:
681+
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP;
682+
break;
683+
case ENV_PLANAR:
684+
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_PLANAR;
685+
break;
686+
case ENV_REFLECTION:
687+
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_REFLECTION;
688+
break;
689+
case ENV_NORMAL:
690+
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_NORMAL;
691+
break;
692+
}
679693
}
680694
else
681695
{
682-
removeEffect(ET_ENVIRONMENT_MAP);
696+
mTexCoordCalcMethod = TEXCALC_NONE;
683697
}
684698
}
685699
//-----------------------------------------------------------------------
@@ -1160,25 +1174,19 @@ namespace Ogre {
11601174
{
11611175
if (enable)
11621176
{
1163-
TextureEffect eff = {ET_PROJECTIVE_TEXTURE};
1164-
eff.frustum = projectionSettings;
1165-
addEffect(eff);
1177+
mProjectiveTexturingFrustum = projectionSettings;
1178+
mTexCoordCalcMethod = TEXCALC_PROJECTIVE_TEXTURE;
11661179
}
11671180
else
11681181
{
1169-
removeEffect(ET_PROJECTIVE_TEXTURE);
1182+
mProjectiveTexturingFrustum = 0;
1183+
mTexCoordCalcMethod = TEXCALC_NONE;
11701184
}
11711185

11721186
}
11731187
const Frustum* TextureUnitState::getProjectiveTexturingFrustum() const
11741188
{
1175-
EffectMap::const_iterator i = mEffects.find(ET_PROJECTIVE_TEXTURE);
1176-
if (i != mEffects.end())
1177-
{
1178-
return i->second.frustum;
1179-
}
1180-
1181-
return 0;
1189+
return mProjectiveTexturingFrustum;
11821190
}
11831191
//-----------------------------------------------------------------------
11841192
void TextureUnitState::setName(const String& name)
@@ -1218,28 +1226,5 @@ namespace Ogre {
12181226
return mSampler;
12191227
}
12201228

1221-
TexCoordCalcMethod TextureUnitState::_deriveTexCoordCalcMethod() const
1222-
{
1223-
TexCoordCalcMethod texCoordCalcMethod = TEXCALC_NONE;
1224-
for (const auto& effi : mEffects)
1225-
{
1226-
switch (effi.second.type)
1227-
{
1228-
case ET_ENVIRONMENT_MAP:
1229-
texCoordCalcMethod = (TexCoordCalcMethod)effi.second.subtype;
1230-
break;
1231-
case ET_UVSCROLL:
1232-
case ET_USCROLL:
1233-
case ET_VSCROLL:
1234-
case ET_ROTATE:
1235-
case ET_TRANSFORM:
1236-
break;
1237-
case ET_PROJECTIVE_TEXTURE:
1238-
texCoordCalcMethod = TEXCALC_PROJECTIVE_TEXTURE;
1239-
break;
1240-
}
1241-
}
1242-
1243-
return texCoordCalcMethod;
1244-
}
1245-
}
1229+
TexCoordCalcMethod TextureUnitState::_deriveTexCoordCalcMethod() const { return mTexCoordCalcMethod; }
1230+
} // namespace Ogre

0 commit comments

Comments
 (0)