mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
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:
parent
762a84550f
commit
85a9a9b608
7 changed files with 112 additions and 23 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
isContainer = "0";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
internalName = "loadingText";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -73,3 +74,19 @@ function EditorLoadingGui::onWake(%this)
|
|||
%posY = (%resY / 2) - (%dialogHeight / 2);
|
||||
%dialog.setPosition(%posX, %posY);
|
||||
}
|
||||
|
||||
function displayEditorLoadingGui(%displayText)
|
||||
{
|
||||
if(%displayText $= "")
|
||||
%displayText = "Loading the Editor...";
|
||||
|
||||
EditorLoadingGui-->loadingText.setText(%displayText);
|
||||
|
||||
Canvas.pushDialog( EditorLoadingGui );
|
||||
Canvas.repaint();
|
||||
}
|
||||
|
||||
function hideEditorLoadingGui()
|
||||
{
|
||||
Canvas.popDialog( EditorLoadingGui );
|
||||
}
|
||||
|
|
@ -261,12 +261,11 @@ function fastLoadWorldEdit(%val)
|
|||
{
|
||||
if(!$Tools::loaded)
|
||||
{
|
||||
canvas.pushDialog( EditorLoadingGui );
|
||||
canvas.repaint();
|
||||
displayEditorLoadingGui();
|
||||
|
||||
onStart();
|
||||
|
||||
canvas.popDialog(EditorLoadingGui);
|
||||
hideEditorLoadingGui();
|
||||
}
|
||||
|
||||
%timerId = startPrecisionTimer();
|
||||
|
|
@ -304,8 +303,7 @@ function fastLoadWorldEdit(%val)
|
|||
}
|
||||
else
|
||||
{
|
||||
canvas.pushDialog( EditorLoadingGui );
|
||||
canvas.repaint();
|
||||
displayEditorLoadingGui();
|
||||
|
||||
Editor.open();
|
||||
|
||||
|
|
@ -317,7 +315,7 @@ function fastLoadWorldEdit(%val)
|
|||
if (theLevelInfo.type $= "DemoScene")
|
||||
commandToServer('dropCameraAtPlayer', true);
|
||||
|
||||
canvas.popDialog(EditorLoadingGui);
|
||||
hideEditorLoadingGui();
|
||||
}
|
||||
|
||||
popInstantGroup();
|
||||
|
|
@ -334,12 +332,11 @@ function fastLoadGUIEdit(%val)
|
|||
{
|
||||
if(!$Tools::loaded)
|
||||
{
|
||||
canvas.pushDialog( EditorLoadingGui );
|
||||
canvas.repaint();
|
||||
displayEditorLoadingGui();
|
||||
|
||||
onStart();
|
||||
|
||||
canvas.popDialog(EditorLoadingGui);
|
||||
hideEditorLoadingGui();
|
||||
}
|
||||
|
||||
toggleGuiEditor(true);
|
||||
|
|
|
|||
|
|
@ -138,8 +138,7 @@ function toggleEditor(%make)
|
|||
}
|
||||
else
|
||||
{
|
||||
canvas.pushDialog( EditorLoadingGui );
|
||||
canvas.repaint();
|
||||
displayEditorLoadingGui();
|
||||
|
||||
Editor.open();
|
||||
|
||||
|
|
@ -151,7 +150,7 @@ function toggleEditor(%make)
|
|||
if (theLevelInfo.type $= "DemoScene")
|
||||
commandToServer('dropCameraAtPlayer', true);
|
||||
|
||||
canvas.popDialog(EditorLoadingGui);
|
||||
hideEditorLoadingGui();
|
||||
}
|
||||
|
||||
popInstantGroup();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue