mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-23 00:23:46 +00:00
give named target a fallback
we need to give named target a fallback image so references are kept when a named target is not ready.
This commit is contained in:
parent
9f2ab5a64e
commit
bab7878ca6
5 changed files with 25 additions and 3 deletions
|
|
@ -53,6 +53,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
StringTableEntry ImageAsset::smNoImageAssetFallback = NULL;
|
||||
StringTableEntry ImageAsset::smNamedTargetAssetFallback = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -139,7 +140,6 @@ ConsoleSetType(TypeImageAssetPtrRefactor)
|
|||
// Is the asset pointer the correct type?
|
||||
if (pAssetPtr == NULL)
|
||||
{
|
||||
// No, so fail.
|
||||
Con::warnf("(TypeImageAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
|
||||
return;
|
||||
}
|
||||
|
|
@ -207,7 +207,12 @@ void ImageAsset::consoleInit()
|
|||
"The assetId of the texture to display when the requested image asset is missing.\n"
|
||||
"@ingroup GFX\n");
|
||||
|
||||
Con::addVariable("$Core::NamedTargetFallback", TypeString, &smNamedTargetAssetFallback,
|
||||
"The assetId of the texture to display when the requested image asset is named target.\n"
|
||||
"@ingroup GFX\n");
|
||||
|
||||
smNoImageAssetFallback = StringTable->insert(Con::getVariable("$Core::NoImageAssetFallback"));
|
||||
smNamedTargetAssetFallback = StringTable->insert(Con::getVariable("$Core::NamedTargetFallback"));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -447,7 +452,19 @@ GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
|
|||
load();
|
||||
|
||||
if (isNamedTarget())
|
||||
return getNamedTarget()->getTexture();
|
||||
{
|
||||
GFXTexHandle tex = getNamedTarget()->getTexture();
|
||||
if(tex.isNull())
|
||||
{
|
||||
AssetPtr<ImageAsset> fallbackAsset;
|
||||
ImageAsset::getAssetById(smNamedTargetAssetFallback, &fallbackAsset);
|
||||
return fallbackAsset->getTexture();
|
||||
}
|
||||
else
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
}
|
||||
|
||||
if (mLoadedState == Ok)
|
||||
{
|
||||
|
|
@ -460,7 +477,7 @@ GFXTexHandle ImageAsset::getTexture(GFXTextureProfile* requestedProfile)
|
|||
|
||||
//If we don't have an existing map case to the requested format, we'll just create it and insert it in
|
||||
GFXTexHandle newTex;
|
||||
newTex.set(mImageFile, requestedProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__));
|
||||
newTex.set(mImageFile, requestedProfile, avar("%s %s() - mTextureObject (line %d)", mImageFile, __FUNCTION__, __LINE__));
|
||||
if (newTex)
|
||||
{
|
||||
mLoadedState = AssetErrCode::Ok;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue