named target material reload clean

clean up the previous requirements for namedTarget to display on a material
This commit is contained in:
marauder2k7 2025-03-27 08:31:28 +00:00
parent 3b70689abc
commit a8d7664fc2
2 changed files with 2 additions and 48 deletions

View file

@ -61,8 +61,6 @@ MaterialManager::MaterialManager()
mLastTime = 0; mLastTime = 0;
mDampness = 0.0f; mDampness = 0.0f;
mWarningInst = NULL; mWarningInst = NULL;
mMatDefToFlush = NULL;
mMatDefToReload = NULL;
GFXDevice::getDeviceEventSignal().notify( this, &MaterialManager::_handleGFXEvent ); GFXDevice::getDeviceEventSignal().notify( this, &MaterialManager::_handleGFXEvent );
@ -75,8 +73,6 @@ MaterialManager::MaterialManager()
mUsingDeferred = false; mUsingDeferred = false;
mFlushAndReInit = false; mFlushAndReInit = false;
mMatDefShouldFlush = false;
mMatDefShouldReload = false;
mDefaultAnisotropy = 1; mDefaultAnisotropy = 1;
Con::addVariable( "$pref::Video::defaultAnisotropy", TypeS32, &mDefaultAnisotropy, Con::addVariable( "$pref::Video::defaultAnisotropy", TypeS32, &mDefaultAnisotropy,
@ -328,12 +324,6 @@ String MaterialManager::getMapEntry(const String & textureName) const
} }
void MaterialManager::flushAndReInitInstances() void MaterialManager::flushAndReInitInstances()
{
// delay flushes and reinits until the start of the next frame.
mFlushAndReInit = true;
}
void MaterialManager::_flushAndReInitInstances()
{ {
// Clear the flag if its set. // Clear the flag if its set.
mFlushAndReInit = false; mFlushAndReInit = false;
@ -368,16 +358,8 @@ void MaterialManager::_flushAndReInitInstances()
(*iter)->reInit(); (*iter)->reInit();
} }
// Used in the materialEditor. This flushes the material preview object so it can be reloaded easily.
void MaterialManager::flushInstance(BaseMaterialDefinition* target)
{
mMatDefToFlush = target;
mMatDefShouldFlush = true;
}
void MaterialManager::_flushInstance( BaseMaterialDefinition *target ) void MaterialManager::_flushInstance( BaseMaterialDefinition *target )
{ {
mMatDefShouldFlush = false;
Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin(); Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin();
while ( iter != mMatInstanceList.end() ) while ( iter != mMatInstanceList.end() )
{ {
@ -388,26 +370,16 @@ void MaterialManager::_flushInstance( BaseMaterialDefinition *target )
} }
iter++; iter++;
} }
mMatDefToFlush = NULL;
}
void MaterialManager::reInitInstance(BaseMaterialDefinition* target)
{
mMatDefToReload = target;
mMatDefShouldReload = true;
} }
void MaterialManager::_reInitInstance( BaseMaterialDefinition *target ) void MaterialManager::_reInitInstance( BaseMaterialDefinition *target )
{ {
mMatDefShouldReload = false;
Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin(); Vector<BaseMatInstance*>::iterator iter = mMatInstanceList.begin();
for ( ; iter != mMatInstanceList.end(); iter++ ) for ( ; iter != mMatInstanceList.end(); iter++ )
{ {
if ( (*iter)->getMaterial() == target ) if ( (*iter)->getMaterial() == target )
(*iter)->reInit(); (*iter)->reInit();
} }
mMatDefToReload = NULL;
} }
void MaterialManager::updateTime() void MaterialManager::updateTime()
@ -527,14 +499,6 @@ bool MaterialManager::_handleGFXEvent( GFXDevice::GFXDeviceEventType event_ )
case GFXDevice::deStartOfFrame: case GFXDevice::deStartOfFrame:
if ( mFlushAndReInit ) if ( mFlushAndReInit )
_flushAndReInitInstances(); _flushAndReInitInstances();
if (mMatDefShouldFlush)
{
_flushInstance(mMatDefToFlush);
}
if (mMatDefShouldReload)
{
_reInitInstance(mMatDefToReload);
}
break; break;
default: default:

View file

@ -113,15 +113,9 @@ public:
/// procedural shaders have been flushed. /// procedural shaders have been flushed.
typedef Signal<void()> FlushSignal; typedef Signal<void()> FlushSignal;
/// Returns the signal used to notify systems that the /// Flushes all the procedural shaders and re-initializes all
/// procedural shaders have been flushed. /// the active materials instances immediately.
FlushSignal& getFlushSignal() { return mFlushSignal; }
void flushAndReInitInstances(); void flushAndReInitInstances();
// Flush the instance
void flushInstance( BaseMaterialDefinition *target );
/// Re-initializes the material instances for a specific target material.
void reInitInstance( BaseMaterialDefinition *target );
protected: protected:
@ -158,8 +152,6 @@ protected:
/// If set we flush and reinitialize all materials at the /// If set we flush and reinitialize all materials at the
/// start of the next rendered frame. /// start of the next rendered frame.
bool mFlushAndReInit; bool mFlushAndReInit;
bool mMatDefShouldReload;
bool mMatDefShouldFlush;
// material map // material map
typedef Map<String, String> MaterialMap; typedef Map<String, String> MaterialMap;
@ -174,8 +166,6 @@ protected:
F32 mDampness; F32 mDampness;
BaseMatInstance* mWarningInst; BaseMatInstance* mWarningInst;
BaseMaterialDefinition* mMatDefToFlush;
BaseMaterialDefinition* mMatDefToReload;
/// The default max anisotropy used in texture filtering. /// The default max anisotropy used in texture filtering.
S32 mDefaultAnisotropy; S32 mDefaultAnisotropy;