|
@@ -125,13 +125,18 @@ ImplementEnumType(ImageAssetType,
|
|
|
|
|
|
EndImplementEnumType;
|
|
EndImplementEnumType;
|
|
|
|
|
|
-
|
|
|
|
|
|
+const String ImageAsset::mErrCodeStrings[] =
|
|
|
|
+{
|
|
|
|
+ "TooManyMips",
|
|
|
|
+ "UnKnown"
|
|
|
|
+};
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
ImageAsset::ImageAsset() : AssetBase(), mUseMips(true), mIsHDRImage(false), mIsValidImage(false), mImageType(Albedo)
|
|
ImageAsset::ImageAsset() : AssetBase(), mUseMips(true), mIsHDRImage(false), mIsValidImage(false), mImageType(Albedo)
|
|
{
|
|
{
|
|
mImageFileName = StringTable->EmptyString();
|
|
mImageFileName = StringTable->EmptyString();
|
|
mImagePath = StringTable->EmptyString();
|
|
mImagePath = StringTable->EmptyString();
|
|
mLoadedState = AssetErrCode::NotLoaded;
|
|
mLoadedState = AssetErrCode::NotLoaded;
|
|
|
|
+ mChangeSignal.notify(this, &ImageAsset::onAssetRefresh);
|
|
}
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
@@ -202,6 +207,7 @@ U32 ImageAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ImageAsse
|
|
{
|
|
{
|
|
//acquire and bind the asset, and return it out
|
|
//acquire and bind the asset, and return it out
|
|
imageAsset->setAssetId(query.mAssetList[0]);
|
|
imageAsset->setAssetId(query.mAssetList[0]);
|
|
|
|
+ (*imageAsset)->loadImage();
|
|
return (*imageAsset)->mLoadedState;
|
|
return (*imageAsset)->mLoadedState;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -234,12 +240,14 @@ U32 ImageAsset::getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* ima
|
|
|
|
|
|
if (imageAsset->notNull())
|
|
if (imageAsset->notNull())
|
|
{
|
|
{
|
|
|
|
+ (*imageAsset)->loadImage();
|
|
return (*imageAsset)->mLoadedState;
|
|
return (*imageAsset)->mLoadedState;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
if (imageAsset->isNull())
|
|
if (imageAsset->isNull())
|
|
{
|
|
{
|
|
|
|
+ (*imageAsset)->loadImage();
|
|
//Well that's bad, loading the fallback failed.
|
|
//Well that's bad, loading the fallback failed.
|
|
Con::warnf("ImageAsset::getAssetById - Finding of asset with id %s failed with no fallback asset", assetId);
|
|
Con::warnf("ImageAsset::getAssetById - Finding of asset with id %s failed with no fallback asset", assetId);
|
|
return AssetErrCode::Failed;
|
|
return AssetErrCode::Failed;
|
|
@@ -248,6 +256,7 @@ U32 ImageAsset::getAssetById(StringTableEntry assetId, AssetPtr<ImageAsset>* ima
|
|
//handle noshape not being loaded itself
|
|
//handle noshape not being loaded itself
|
|
if ((*imageAsset)->mLoadedState == BadFileReference)
|
|
if ((*imageAsset)->mLoadedState == BadFileReference)
|
|
{
|
|
{
|
|
|
|
+ (*imageAsset)->loadImage();
|
|
Con::warnf("ImageAsset::getAssetById - Finding of asset with id %s failed, and fallback asset reported error of Bad File Reference.", assetId);
|
|
Con::warnf("ImageAsset::getAssetById - Finding of asset with id %s failed, and fallback asset reported error of Bad File Reference.", assetId);
|
|
return AssetErrCode::BadFileReference;
|
|
return AssetErrCode::BadFileReference;
|
|
}
|
|
}
|
|
@@ -268,6 +277,7 @@ void ImageAsset::copyTo(SimObject* object)
|
|
|
|
|
|
void ImageAsset::loadImage()
|
|
void ImageAsset::loadImage()
|
|
{
|
|
{
|
|
|
|
+ if (mLoadedState == AssetErrCode::Ok) return;
|
|
if (mImagePath)
|
|
if (mImagePath)
|
|
{
|
|
{
|
|
if (!Torque::FS::IsFile(mImagePath))
|
|
if (!Torque::FS::IsFile(mImagePath))
|
|
@@ -279,7 +289,6 @@ void ImageAsset::loadImage()
|
|
|
|
|
|
mLoadedState = Ok;
|
|
mLoadedState = Ok;
|
|
mIsValidImage = true;
|
|
mIsValidImage = true;
|
|
- mChangeSignal.trigger();
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
mLoadedState = BadFileReference;
|
|
mLoadedState = BadFileReference;
|
|
@@ -292,13 +301,11 @@ void ImageAsset::initializeAsset()
|
|
ResourceManager::get().getChangedSignal().notify(this, &ImageAsset::_onResourceChanged);
|
|
ResourceManager::get().getChangedSignal().notify(this, &ImageAsset::_onResourceChanged);
|
|
|
|
|
|
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
|
|
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
|
|
- loadImage();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void ImageAsset::onAssetRefresh()
|
|
void ImageAsset::onAssetRefresh()
|
|
{
|
|
{
|
|
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
|
|
mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
|
|
- loadImage();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void ImageAsset::_onResourceChanged(const Torque::Path& path)
|
|
void ImageAsset::_onResourceChanged(const Torque::Path& path)
|
|
@@ -308,7 +315,7 @@ void ImageAsset::_onResourceChanged(const Torque::Path& path)
|
|
|
|
|
|
refreshAsset();
|
|
refreshAsset();
|
|
|
|
|
|
- //loadImage();
|
|
|
|
|
|
+ onAssetRefresh();
|
|
}
|
|
}
|
|
|
|
|
|
void ImageAsset::setImageFileName(const char* pScriptFile)
|
|
void ImageAsset::setImageFileName(const char* pScriptFile)
|