mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Merge pull request #611 from Areloch/MatAssetLoadStabilization
Tweaks the MaterialAsset loading logic
This commit is contained in:
commit
ee824e0f17
2 changed files with 18 additions and 2 deletions
|
|
@ -167,6 +167,12 @@ void MaterialAsset::initializeAsset()
|
||||||
|
|
||||||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||||
|
|
||||||
|
if (mMatDefinitionName == StringTable->EmptyString())
|
||||||
|
{
|
||||||
|
mLoadedState = Failed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Torque::FS::IsScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
{
|
{
|
||||||
if (!Sim::findObject(mMatDefinitionName))
|
if (!Sim::findObject(mMatDefinitionName))
|
||||||
|
|
@ -180,6 +186,10 @@ void MaterialAsset::initializeAsset()
|
||||||
mLoadedState = Failed;
|
mLoadedState = Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLoadedState = DefinitionAlreadyExists;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMaterial();
|
loadMaterial();
|
||||||
|
|
@ -189,6 +199,12 @@ void MaterialAsset::onAssetRefresh()
|
||||||
{
|
{
|
||||||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||||
|
|
||||||
|
if (mMatDefinitionName == StringTable->EmptyString())
|
||||||
|
{
|
||||||
|
mLoadedState = Failed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Torque::FS::IsScriptFile(mScriptPath))
|
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||||
{
|
{
|
||||||
//Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
|
//Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
|
||||||
|
|
@ -204,7 +220,6 @@ void MaterialAsset::onAssetRefresh()
|
||||||
|
|
||||||
//And now that we've executed, switch back to the prior behavior
|
//And now that we've executed, switch back to the prior behavior
|
||||||
Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
|
Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMaterial();
|
loadMaterial();
|
||||||
|
|
@ -232,7 +247,7 @@ void MaterialAsset::loadMaterial()
|
||||||
if (mMaterialDefinition)
|
if (mMaterialDefinition)
|
||||||
SAFE_DELETE(mMaterialDefinition);
|
SAFE_DELETE(mMaterialDefinition);
|
||||||
|
|
||||||
if (mLoadedState == ScriptLoaded && mMatDefinitionName != StringTable->EmptyString())
|
if ((mLoadedState == ScriptLoaded || mLoadedState == DefinitionAlreadyExists) && mMatDefinitionName != StringTable->EmptyString())
|
||||||
{
|
{
|
||||||
Material* matDef;
|
Material* matDef;
|
||||||
if (!Sim::findObject(mMatDefinitionName, matDef))
|
if (!Sim::findObject(mMatDefinitionName, matDef))
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ public:
|
||||||
enum MaterialAssetErrCode
|
enum MaterialAssetErrCode
|
||||||
{
|
{
|
||||||
ScriptLoaded = AssetErrCode::Extended,
|
ScriptLoaded = AssetErrCode::Extended,
|
||||||
|
DefinitionAlreadyExists,
|
||||||
Extended
|
Extended
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue