mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Separates out acquireAsset call for importing assets until after all assets have been imported, then runs it as a post step to ensure all assets are properly loaded before they're used
This commit is contained in:
parent
50973b7f6f
commit
1c7c32baa6
4 changed files with 41 additions and 11 deletions
|
|
@ -174,11 +174,6 @@ void MaterialAsset::initializeAsset()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMatDefinitionName == StringTable->insert("DetailBlue"))
|
|
||||||
{
|
|
||||||
bool asdfsd = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size() != 0 && mScriptPath == StringTable->EmptyString())
|
if (size() != 0 && mScriptPath == StringTable->EmptyString())
|
||||||
{
|
{
|
||||||
mLoadedState = EmbeddedDefinition;
|
mLoadedState = EmbeddedDefinition;
|
||||||
|
|
|
||||||
|
|
@ -1727,7 +1727,8 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
|
||||||
|
|
||||||
//If there was no existing assetId, then lets see if it already exists in a legacy file, like a materials.cs or materials.tscript
|
//If there was no existing assetId, then lets see if it already exists in a legacy file, like a materials.cs or materials.tscript
|
||||||
//If it does, we'll just make our asset point to that instead of a new file
|
//If it does, we'll just make our asset point to that instead of a new file
|
||||||
Material* mat = MATMGR->getMaterialDefinitionByName(assetName);
|
Material* mat;
|
||||||
|
Sim::findObject(assetName, mat);
|
||||||
|
|
||||||
if (!mat)
|
if (!mat)
|
||||||
mat = MATMGR->getMaterialDefinitionByMapTo(assetName);
|
mat = MATMGR->getMaterialDefinitionByMapTo(assetName);
|
||||||
|
|
@ -2618,6 +2619,8 @@ StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath, String typ
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
importAssets();
|
importAssets();
|
||||||
|
|
||||||
|
acquireAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
dumpActivityLog();
|
dumpActivityLog();
|
||||||
|
|
@ -2729,10 +2732,6 @@ void AssetImporter::importAssets(AssetImportObject* assetItem)
|
||||||
tss->setShapeAssetId(assetId);
|
tss->setShapeAssetId(assetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Go ahead and force the asset to load now just to kick it for immediate use
|
|
||||||
AssetBase* assetDef = AssetDatabase.acquireAsset<AssetBase>(assetId);
|
|
||||||
AssetDatabase.releaseAsset(assetId);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2757,6 +2756,34 @@ void AssetImporter::importAssets(AssetImportObject* assetItem)
|
||||||
dumpActivityLog();
|
dumpActivityLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetImporter::acquireAssets(AssetImportObject* assetItem)
|
||||||
|
{
|
||||||
|
Vector<AssetImportObject*> itemList = importingAssets;
|
||||||
|
if (assetItem != nullptr)
|
||||||
|
itemList = assetItem->childAssetItems;
|
||||||
|
|
||||||
|
for (U32 i = 0; i < itemList.size(); i++)
|
||||||
|
{
|
||||||
|
AssetImportObject* item = itemList[i];
|
||||||
|
if (item->importStatus == AssetImportObject::Skipped ||
|
||||||
|
item->importStatus == AssetImportObject::NotProcessed ||
|
||||||
|
item->importStatus == AssetImportObject::Error)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//recurse if needed, we want to process child items first for dependency reasons
|
||||||
|
acquireAssets(item);
|
||||||
|
|
||||||
|
//Go ahead and force the asset to load now just to kick it for immediate use
|
||||||
|
String assetId = item->moduleName + ":" + item->assetName;
|
||||||
|
|
||||||
|
if (AssetDatabase.isDeclaredAsset(assetId))
|
||||||
|
{
|
||||||
|
AssetBase* assetDef = AssetDatabase.acquireAsset<AssetBase>(assetId);
|
||||||
|
AssetDatabase.releaseAsset(assetId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Type-specific import logic
|
// Type-specific import logic
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -914,6 +914,12 @@ public:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Torque::Path importShapeAnimationAsset(AssetImportObject* assetItem);
|
Torque::Path importShapeAnimationAsset(AssetImportObject* assetItem);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Iterates over all the items in the current session and acquires them, which jumpstarts the loading/init'ng process on them, making the available for use immediately
|
||||||
|
/// <para>@param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children</para>
|
||||||
|
/// </summary>
|
||||||
|
void acquireAssets(AssetImportObject* assetItem = nullptr);
|
||||||
|
|
||||||
//
|
//
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the currently active import configuration
|
/// Gets the currently active import configuration
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,9 @@ DefineEngineMethod(AssetImporter, resolveAssetItemIssues, void, (AssetImportObje
|
||||||
DefineEngineMethod(AssetImporter, importAssets, void, (),,
|
DefineEngineMethod(AssetImporter, importAssets, void, (),,
|
||||||
"Runs the actual import action on the items.")
|
"Runs the actual import action on the items.")
|
||||||
{
|
{
|
||||||
return object->importAssets();
|
object->importAssets();
|
||||||
|
|
||||||
|
object->acquireAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),,
|
DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue