Implements shape preview caching for shape assets

Also standardizes the loading gui overlay so it can be used to inform that the asset preview generation is happening
This commit is contained in:
Areloch 2021-01-27 01:54:26 -06:00
parent 762a84550f
commit 85a9a9b608
7 changed files with 112 additions and 23 deletions

View file

@ -983,8 +983,7 @@ function ImportAssetWindow::ImportAssets(%this)
return;
}
Canvas.pushDialog( EditorLoadingGui );
Canvas.repaint();
displayEditorLoadingGui("Importing Assets...");
%this.importer.targetModuleId = %moduleName;
}
@ -1000,7 +999,7 @@ function ImportAssetWindow::ImportAssets(%this)
%this.importer.resetImportSession(true);
Canvas.popDialog( EditorLoadingGui );
hideEditorLoadingGui();
//do the actual importing, now!
/*%assetCount = ImportAssetItems.count();

View file

@ -244,10 +244,48 @@ function AssetBrowser::importShapeAsset(%this, %assetItem)
function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData)
{
%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getShapeFile())));
%previewPath = "tools/resources/shapePreviewCache/" @ %module.moduleId @ "/";
if(!IsDirectory(%previewPath))
{
%this.dirHandler.createFolder(%previewPath);
}
%previewPath = %previewPath @ %assetDef.assetName @ "_Preview.png";
if(!isFile(%previewPath))
{
displayEditorLoadingGui("Generating Shape Asset Preview...");
//This is slightly hacky, but we're going to utilize the imposter/last detail system
//to generate our previews for us and then clean up the unneeded bits
%oldImposterSetting = $TSLastDetail::dumpImposters;
$TSLastDetail::dumpImposters = true;
%filePath = %assetDef.generateCachedPreviewImage();
%imposterPath = %filePath @ ".imposter.png";
pathCopy(%imposterPath, %previewPath);
//cleanup
fileDelete(%imposterPath);
fileDelete(%filePath @ ".imposter.dds");
fileDelete(%filePath @ ".imposter_normals.png");
fileDelete(%filePath @ ".imposter_normals.dds");
$TSLastDetail::dumpImposters = %oldImposterSetting;
hideEditorLoadingGui();
}
//Revalidate. If it didn't work, just use the default placeholder one
if(!isFile(%previewPath))
%previewPath = "tools/assetBrowser/art/genericAssetIcon";
%previewData.assetName = %assetDef.assetName;
%previewData.assetPath = %assetDef.fileName;
%previewData.previewImage = "tools/assetBrowser/art/genericAssetIcon";//%assetDef.fileName;
%previewData.previewImage = %previewPath;//%assetDef.fileName;
%previewData.assetFriendlyName = %assetDef.assetName;
%previewData.assetDesc = %assetDef.description;