mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
move population of image metadata to onAssetRefresh
This commit is contained in:
parent
3d77b59b71
commit
48b512ef73
2 changed files with 48 additions and 41 deletions
|
|
@ -345,6 +345,8 @@ void ImageAsset::initializeAsset(void)
|
|||
return;
|
||||
|
||||
mImageFile = expandAssetFilePath(mImageFile);
|
||||
|
||||
populateImage();
|
||||
}
|
||||
|
||||
void ImageAsset::onAssetRefresh(void)
|
||||
|
|
@ -356,6 +358,8 @@ void ImageAsset::onAssetRefresh(void)
|
|||
// Call parent.
|
||||
Parent::onAssetRefresh();
|
||||
|
||||
populateImage();
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -395,46 +399,6 @@ void ImageAsset::setImageFile(StringTableEntry pImageFile)
|
|||
|
||||
mImageFile = getOwned() ? expandAssetFilePath(pImageFile) : StringTable->insert(pImageFile);
|
||||
|
||||
if (Torque::FS::IsFile(mImageFile))
|
||||
{
|
||||
if (dStrEndsWith(mImageFile, ".dds"))
|
||||
{
|
||||
DDSFile* tempFile = new DDSFile();
|
||||
FileStream* ddsFs;
|
||||
if ((ddsFs = FileStream::createAndOpen(mImageFile, Torque::FS::File::Read)) == NULL)
|
||||
{
|
||||
Con::errorf("ImageAsset::setImageFile Failed to open ddsfile: %s", mImageFile);
|
||||
}
|
||||
|
||||
if (!tempFile->readHeader(*ddsFs))
|
||||
{
|
||||
Con::errorf("ImageAsset::setImageFile Failed to read header of ddsfile: %s", mImageFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
mImageWidth = tempFile->mWidth;
|
||||
mImageHeight = tempFile->mHeight;
|
||||
}
|
||||
|
||||
ddsFs->close();
|
||||
delete tempFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!stbi_info(mImageFile, &mImageWidth, &mImageHeight, &mImageChannels))
|
||||
{
|
||||
StringTableEntry stbErr = stbi_failure_reason();
|
||||
if (stbErr == StringTable->EmptyString())
|
||||
stbErr = "ImageAsset::Unkown Error!";
|
||||
|
||||
Con::errorf("ImageAsset::setImageFile STB Get file info failed: %s", stbErr);
|
||||
}
|
||||
}
|
||||
|
||||
// we only support 2d textures..... for no ;)
|
||||
mImageDepth = 1;
|
||||
}
|
||||
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
|
|
@ -675,6 +639,49 @@ void ImageAsset::onTamlCustomRead(const TamlCustomNodes& customNodes)
|
|||
}
|
||||
}
|
||||
|
||||
void ImageAsset::populateImage(void)
|
||||
{
|
||||
if (Torque::FS::IsFile(mImageFile))
|
||||
{
|
||||
if (dStrEndsWith(mImageFile, ".dds"))
|
||||
{
|
||||
DDSFile* tempFile = new DDSFile();
|
||||
FileStream* ddsFs;
|
||||
if ((ddsFs = FileStream::createAndOpen(mImageFile, Torque::FS::File::Read)) == NULL)
|
||||
{
|
||||
Con::errorf("ImageAsset::setImageFile Failed to open ddsfile: %s", mImageFile);
|
||||
}
|
||||
|
||||
if (!tempFile->readHeader(*ddsFs))
|
||||
{
|
||||
Con::errorf("ImageAsset::setImageFile Failed to read header of ddsfile: %s", mImageFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
mImageWidth = tempFile->mWidth;
|
||||
mImageHeight = tempFile->mHeight;
|
||||
}
|
||||
|
||||
ddsFs->close();
|
||||
delete tempFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!stbi_info(mImageFile, &mImageWidth, &mImageHeight, &mImageChannels))
|
||||
{
|
||||
StringTableEntry stbErr = stbi_failure_reason();
|
||||
if (stbErr == StringTable->EmptyString())
|
||||
stbErr = "ImageAsset::Unkown Error!";
|
||||
|
||||
Con::errorf("ImageAsset::setImageFile STB Get file info failed: %s", stbErr);
|
||||
}
|
||||
}
|
||||
|
||||
// we only support 2d textures..... for now ;)
|
||||
mImageDepth = 1;
|
||||
}
|
||||
}
|
||||
|
||||
const char* ImageAsset::getImageInfo()
|
||||
{
|
||||
if (isAssetValid())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue