mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +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
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ public:
|
|||
};
|
||||
|
||||
static StringTableEntry smNoImageAssetFallback;
|
||||
static StringTableEntry smNamedTargetAssetFallback;
|
||||
|
||||
enum ImageAssetErrCode
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ function Core_Rendering::onCreate(%this)
|
|||
$Core::WetnessTexture = "core/rendering/images/wetMap.png";
|
||||
|
||||
$Core::NoImageAssetFallback = "Core_Rendering:missingTexture_image";
|
||||
$Core::NamedTargetFallback = "Core_Rendering:namedTarget_image";
|
||||
$Core::NoMaterialAssetFallback = "Core_Rendering:noMaterial";
|
||||
$Core::NoShapeAssetFallback = "Core_Rendering:noShape";
|
||||
|
||||
|
|
|
|||
BIN
Templates/BaseGame/game/core/rendering/images/namedTarget.png
Normal file
BIN
Templates/BaseGame/game/core/rendering/images/namedTarget.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="namedTarget_image"
|
||||
imageFile="@assetFile=namedTarget.png"/>
|
||||
Loading…
Reference in a new issue