Merge branch 'MiscImportFixes20211105' of https://github.com/Areloch/Torque3D into Preview4_0

This commit is contained in:
Areloch 2021-11-06 19:09:55 -05:00
commit bd0a070d03
6 changed files with 64 additions and 99 deletions

View file

@ -1617,6 +1617,7 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
} }
} }
bool foundExistingMaterial = false;
if (activeImportConfig->UseExistingMaterials) if (activeImportConfig->UseExistingMaterials)
{ {
//So if the material already exists, we should just use that. So first, let's find out if it already exists //So if the material already exists, we should just use that. So first, let's find out if it already exists
@ -1651,9 +1652,11 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
{ {
//We found a match, so just modify our asset item's info to point against it. This will create the asset definition, but otherwise leave the material definition as-is. //We found a match, so just modify our asset item's info to point against it. This will create the asset definition, but otherwise leave the material definition as-is.
assetItem->filePath = (Torque::Path)(mat->getFilename()); assetItem->filePath = (Torque::Path)(mat->getFilename());
foundExistingMaterial = true;
} }
} }
else
if(!foundExistingMaterial)
{ {
if (activeImportConfig->AlwaysAddMaterialSuffix) //we only opt to force on the suffix if we're not obligating using the original material defs if (activeImportConfig->AlwaysAddMaterialSuffix) //we only opt to force on the suffix if we're not obligating using the original material defs
{ {
@ -1811,19 +1814,6 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
} }
} }
} }
/*for (U32 i = 0; i < assetItem->childAssetItems.size(); i++)
{
AssetImportObject* childAssetItem = assetItem->childAssetItems[i];
if (childAssetItem->skip || childAssetItem->processed || childAssetItem->assetType != String("ImageAsset"))
continue;
if (childAssetItem->imageSuffixType == String("Albedo"))
{
assetItem->diffuseImageAsset = % childAssetItem;
}
}*/
} }
} }
@ -1963,7 +1953,7 @@ void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 m
else else
{ {
Torque::Path filePath = materialItemValue; Torque::Path filePath = materialItemValue;
String fullFilePath = filePath.getFullFileName().c_str(); String fullFilePath = filePath.getFullPath().c_str();
String shapePathBase = assetItem->filePath.getRootAndPath(); String shapePathBase = assetItem->filePath.getRootAndPath();
if (fullFilePath.isNotEmpty()) if (fullFilePath.isNotEmpty())
@ -1977,24 +1967,26 @@ void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 m
fullFilePath = fullFilePath.replace(" (Not Found)", ""); fullFilePath = fullFilePath.replace(" (Not Found)", "");
fullFilePath = fullFilePath.replace(" (not found)", ""); fullFilePath = fullFilePath.replace(" (not found)", "");
String testFileName = shapePathBase + "/" + fullFilePath; if(filePath.getPath().isEmpty())
if (Platform::isFile(testFileName.c_str())) fullFilePath = shapePathBase + "/" + fullFilePath;
if (Platform::isFile(fullFilePath.c_str()))
{ {
filePath = testFileName; filePath = Torque::Path(fullFilePath);
} }
else else
{ {
//Hmm, didn't find it. It could be that the in-model filename could be different by virtue of //Hmm, didn't find it. It could be that the in-model filename could be different by virtue of
//image extension. Some files have source content files like psd's, but the mesh was exported to use //image extension. Some files have source content files like psd's, but the mesh was exported to use
//a dds or png, etc //a dds or png, etc
Torque::Path testFilePath = testFileName; Torque::Path testFilePath = fullFilePath;
String imgFileName = AssetImporter::findImagePath(testFilePath.getPath() + "/" + testFilePath.getFileName()); String imgFileName = AssetImporter::findImagePath(testFilePath.getPath() + "/" + testFilePath.getFileName());
if (imgFileName.isNotEmpty()) if (imgFileName.isNotEmpty())
filePath = imgFileName; filePath = imgFileName;
} }
} }
matAssetItem = addImportingAsset("MaterialAsset", shapePathBase + "/", assetItem, matName); matAssetItem = addImportingAsset("MaterialAsset", shapePathBase + "/" + matName, assetItem, matName);
AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, ""); AssetImportObject* imageAssetItem = addImportingAsset("ImageAsset", filePath, matAssetItem, "");
String suffixType; String suffixType;
@ -2831,7 +2823,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
} }
assetFieldName = mapFieldName + "Asset"; assetFieldName = mapFieldName + "Asset";
mapFieldName += "[0]"; assetFieldName += "[0]";
//String path = childItem->filePath.getFullFileName(); //String path = childItem->filePath.getFullFileName();
//dSprintf(lineBuffer, 1024, " %s = \"%s\";", mapFieldName.c_str(), path.c_str()); //dSprintf(lineBuffer, 1024, " %s = \"%s\";", mapFieldName.c_str(), path.c_str());

View file

@ -6,113 +6,114 @@
//Console Functions //Console Functions
DefineEngineMethod(AssetImportConfig, loadImportConfig, void, (Settings* configSettings, String configName), (nullAsType<Settings*>(), ""), DefineEngineMethod(AssetImportConfig, loadImportConfig, void, (Settings* configSettings, String configName), (nullAsType<Settings*>(), ""),
"Creates a new script asset using the targetFilePath.\n" "Loads the provided import config to the importer.\n"
"@return The bool result of calling exec") "@param configSettings A Settings object containing the import configs.\n"
"@param configName The specific name of the config to be used.")
{ {
return object->loadImportConfig(configSettings, configName); return object->loadImportConfig(configSettings, configName);
} }
DefineEngineMethod(AssetImporter, setTargetPath, void, (String path), (""), DefineEngineMethod(AssetImporter, setTargetPath, void, (String path), (""),
"Creates a new script asset using the targetFilePath.\n" "Sets the target path the importing assets will be put into.\n"
"@return The bool result of calling exec") "@param A string of the target path.")
{ {
return object->setTargetPath(path); return object->setTargetPath(path);
} }
DefineEngineMethod(AssetImporter, resetImportSession, void, (bool forceResetSession), (false), DefineEngineMethod(AssetImporter, resetImportSession, void, (bool forceResetSession), (false),
"Creates a new script asset using the targetFilePath.\n" "Resets the importer's import session. All existing import items, logs, etc will be cleared.")
"@return The bool result of calling exec")
{ {
return object->resetImportSession(forceResetSession); return object->resetImportSession(forceResetSession);
} }
DefineEngineMethod(AssetImporter, dumpActivityLog, void, (), , DefineEngineMethod(AssetImporter, dumpActivityLog, void, (), ,
"Creates a new script asset using the targetFilePath.\n" "Dumps the import activity log. If the importer is set to, it will save to file, otherwise dump to console.")
"@return The bool result of calling exec")
{ {
return object->dumpActivityLog(); return object->dumpActivityLog();
} }
DefineEngineMethod(AssetImporter, getActivityLogLineCount, S32, (),, DefineEngineMethod(AssetImporter, getActivityLogLineCount, S32, (),,
"Creates a new script asset using the targetFilePath.\n" "Gets the number of lines in the import activity log.\n"
"@return The bool result of calling exec") "@return The number of lines in the import activity log.")
{ {
return object->getActivityLogLineCount(); return object->getActivityLogLineCount();
} }
DefineEngineMethod(AssetImporter, getActivityLogLine, String, (S32 i), (0), DefineEngineMethod(AssetImporter, getActivityLogLine, String, (S32 index), (0),
"Creates a new script asset using the targetFilePath.\n" "Gets a specific line in the import activity log.\n"
"@return The bool result of calling exec") "@param index The index of the line to be returned.\n"
"@return The string of the requested line of the activity log")
{ {
return object->getActivityLogLine(i); return object->getActivityLogLine(index);
} }
DefineEngineMethod(AssetImporter, autoImportFile, String, (String path, String typeHint), ("", ""), DefineEngineMethod(AssetImporter, autoImportFile, String, (String path, String typeHint), ("", ""),
"Creates a new script asset using the targetFilePath.\n" "Run the full import process on a specific file.\n"
"@return The bool result of calling exec") "@return If import is successful, the assetId of the new asset. If it failed, an empty string.")
{ {
return object->autoImportFile(path, typeHint); return object->autoImportFile(path, typeHint);
} }
DefineEngineMethod(AssetImporter, addImportingFile, AssetImportObject*, (String path), (""), DefineEngineMethod(AssetImporter, addImportingFile, AssetImportObject*, (String path), (""),
"Creates a new script asset using the targetFilePath.\n" "Adds a filepath to the current importing session.\n"
"@return The bool result of calling exec") "@param path The path to the file to be imported.\n"
"@return The AssetImportObject from the import session.")
{ {
return object->addImportingFile(path); return object->addImportingFile(path);
} }
DefineEngineMethod(AssetImporter, addImportingAssetItem, void, (AssetImportObject* assetItem, AssetImportObject* parentItem), (nullAsType< AssetImportObject*>(), nullAsType< AssetImportObject*>()), DefineEngineMethod(AssetImporter, addImportingAssetItem, void, (AssetImportObject* assetItem, AssetImportObject* parentItem), (nullAsType< AssetImportObject*>(), nullAsType< AssetImportObject*>()),
"Creates a new script asset using the targetFilePath.\n" "Adds an existing AssetImportObject to the current improting session.\n"
"@return The bool result of calling exec") "@param assetItem The AssetImportObject to be added to the import session.\n"
"@param parentItem An AssetImportObject that to act as the parent of the item being added.")
{ {
return object->addImportingAssetItem(assetItem, parentItem); return object->addImportingAssetItem(assetItem, parentItem);
} }
DefineEngineMethod(AssetImporter, processImportingAssets, void, (), , DefineEngineMethod(AssetImporter, processImportingAssets, void, (), ,
"Creates a new script asset using the targetFilePath.\n" "Processes the importing assets.")
"@return The bool result of calling exec")
{ {
return object->processImportAssets(); return object->processImportAssets();
} }
DefineEngineMethod(AssetImporter, validateImportingAssets, bool, (), , DefineEngineMethod(AssetImporter, hasImportIssues, bool, (), ,
"Creates a new script asset using the targetFilePath.\n" "Validates the status of the importing items.\n"
"@return The bool result of calling exec") "@return False if there are no issues, true if there are importing issues")
{ {
return object->validateAssets(); return object->validateAssets();
} }
DefineEngineMethod(AssetImporter, resolveAssetItemIssues, void, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()), DefineEngineMethod(AssetImporter, resolveAssetItemIssues, void, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()),
"Creates a new script asset using the targetFilePath.\n" "Runs the issue resolver to attempt to correct any simple issues, such as utilizing the config's settings to resolve collisions.")
"@return The bool result of calling exec")
{ {
object->resolveAssetItemIssues(assetItem); object->resolveAssetItemIssues(assetItem);
} }
DefineEngineMethod(AssetImporter, importAssets, void, (),, DefineEngineMethod(AssetImporter, importAssets, void, (),,
"Creates a new script asset using the targetFilePath.\n" "Runs the actual import action on the items.")
"@return The bool result of calling exec")
{ {
return object->importAssets(); return object->importAssets();
} }
DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),, DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),,
"Creates a new script asset using the targetFilePath.\n" "Gets the number of importing asset items.\n"
"@return The bool result of calling exec") "@return The number of importing asset items")
{ {
return object->getAssetItemCount(); return object->getAssetItemCount();
} }
DefineEngineMethod(AssetImporter, getAssetItem, AssetImportObject*, (S32 index), (0), DefineEngineMethod(AssetImporter, getAssetItem, AssetImportObject*, (S32 index), (0),
"Creates a new script asset using the targetFilePath.\n" "Gets a specific import asset item.\n"
"@return The bool result of calling exec") "@param index The index of the AssetImportObject to be returned.\n"
"@return AssetImportObject")
{ {
return object->getAssetItem(index); return object->getAssetItem(index);
} }
DefineEngineMethod(AssetImporter, getAssetItemChildCount, S32, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()), DefineEngineMethod(AssetImporter, getAssetItemChildCount, S32, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()),
"Creates a new script asset using the targetFilePath.\n" "Gets number of child items for a given importing asset item.\n"
"@return The bool result of calling exec") "@param assetItem The AssetImportObject to get the number of children of.\n"
"@return The number of child items")
{ {
if (assetItem == nullptr) if (assetItem == nullptr)
return 0; return 0;
@ -121,8 +122,10 @@ DefineEngineMethod(AssetImporter, getAssetItemChildCount, S32, (AssetImportObjec
} }
DefineEngineMethod(AssetImporter, getAssetItemChild, AssetImportObject*, (AssetImportObject* assetItem, S32 index), (nullAsType< AssetImportObject*>(), 0), DefineEngineMethod(AssetImporter, getAssetItemChild, AssetImportObject*, (AssetImportObject* assetItem, S32 index), (nullAsType< AssetImportObject*>(), 0),
"Creates a new script asset using the targetFilePath.\n" "Gets a specific child item of a given importing asset item.\n"
"@return The bool result of calling exec") "@param assetItem The AssetImportObject to get the child from.\n"
"@param index The index of the child to get.\n"
"@return The child AssetImportObect")
{ {
if (assetItem == nullptr) if (assetItem == nullptr)
return nullptr; return nullptr;
@ -131,31 +134,15 @@ DefineEngineMethod(AssetImporter, getAssetItemChild, AssetImportObject*, (AssetI
} }
DefineEngineMethod(AssetImporter, deleteImportingAsset, void, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()), DefineEngineMethod(AssetImporter, deleteImportingAsset, void, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()),
"Creates a new script asset using the targetFilePath.\n" "Deletes an importing AssetImportObject from the import session.\n"
"@return The bool result of calling exec") "@param assetItem The AssetImportObject to delete.")
{ {
return object->deleteImportingAsset(assetItem); return object->deleteImportingAsset(assetItem);
} }
DefineEngineMethod(AssetImporter, setImportConfig, void, (AssetImportConfig* importConfig), (nullAsType< AssetImportConfig*>()), DefineEngineMethod(AssetImporter, setImportConfig, void, (AssetImportConfig* importConfig), (nullAsType< AssetImportConfig*>()),
"Creates a new script asset using the targetFilePath.\n" "Sets the import config to be used via a AssetImportConfig object.\n"
"@return The bool result of calling exec") "@param importConfig The AssetImportConfig object to use.")
{ {
return object->setImportConfig(importConfig); return object->setImportConfig(importConfig);
} }
/*DefineEngineFunction(enumColladaForImport, bool, (const char* shapePath, const char* ctrl, bool loadCachedDts), ("", "", true),
"(string shapePath, GuiTreeViewCtrl ctrl) Collect scene information from "
"a COLLADA file and store it in a GuiTreeView control. This function is "
"used by the COLLADA import gui to show a preview of the scene contents "
"prior to import, and is probably not much use for anything else.\n"
"@param shapePath COLLADA filename\n"
"@param ctrl GuiTreeView control to add elements to\n"
"@param loadCachedDts dictates if it should try and load the cached dts file if it exists"
"@return true if successful, false otherwise\n"
"@ingroup Editors\n"
"@internal")
{
return enumColladaForImport(shapePath, ctrl, loadCachedDts);
}*/

View file

@ -425,6 +425,7 @@ bool AssimpShapeLoader::fillGuiTreeView(const char* sourceShapePath, GuiTreeView
void AssimpShapeLoader::updateMaterialsScript(const Torque::Path &path) void AssimpShapeLoader::updateMaterialsScript(const Torque::Path &path)
{ {
return;
Torque::Path scriptPath(path); Torque::Path scriptPath(path);
scriptPath.setFileName("materials"); scriptPath.setFileName("materials");
scriptPath.setExtension(TORQUE_SCRIPT_EXTENSION); scriptPath.setExtension(TORQUE_SCRIPT_EXTENSION);

View file

@ -461,6 +461,8 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
return; return;
#endif #endif
return;
Torque::Path scriptPath(path); Torque::Path scriptPath(path);
scriptPath.setFileName("materials"); scriptPath.setFileName("materials");
scriptPath.setExtension(TORQUE_SCRIPT_EXTENSION); scriptPath.setExtension(TORQUE_SCRIPT_EXTENSION);

View file

@ -85,8 +85,6 @@ function ImportAssetWindow::onWake(%this)
%this.importer.targetPath = AssetImportTargetAddress.getText(); %this.importer.targetPath = AssetImportTargetAddress.getText();
%this.importer.targetModuleId = AssetImportTargetModule.getText(); %this.importer.targetModuleId = AssetImportTargetModule.getText();
ImportActivityLog.empty();
%this.refresh(); %this.refresh();
} }
@ -519,7 +517,8 @@ function ImportAssetWindow::doRefresh(%this)
if(ImportAssetWindow.importConfigsList.count() != 0 if(ImportAssetWindow.importConfigsList.count() != 0
&& EditorSettings.value("Assets/AssetImporDefaultConfig") !$= "" && EditorSettings.value("Assets/AssetImporDefaultConfig") !$= ""
&& EditorSettings.value("Assets/AutoImport", false) == true && EditorSettings.value("Assets/AutoImport", false) == true
&& ImportAssetWindow.hasImportIssues == false && ImportAssetWindow.hasImportIssues() == false
&& AssetBrowser.isAssetReImport == false
&& ImportAssetWindow.allowAutoImport) && ImportAssetWindow.allowAutoImport)
{ {
AssetImportCtrl.setHidden(true); AssetImportCtrl.setHidden(true);
@ -722,11 +721,7 @@ function NewAssetsPanelInputs::onRightMouseDown(%this)
// //
function ImportAssetWindow::removeImportingAsset(%this) function ImportAssetWindow::removeImportingAsset(%this)
{ {
ImportActivityLog.add("Removing Asset from Import");
%this.importer.deleteImportingAsset(ImportAssetActions.assetItem); %this.importer.deleteImportingAsset(ImportAssetActions.assetItem);
//ImportAssetWindow.refresh();
} }
function ImportAssetWindow::addNewImportingAsset(%this, %filterType) function ImportAssetWindow::addNewImportingAsset(%this, %filterType)
@ -924,9 +919,9 @@ function ImportAssetWindow::toggleLogWindow()
} }
ImportLogTextList.clear(); ImportLogTextList.clear();
for(%i=0; %i < ImportActivityLog.count(); %i++) for(%i=0; %i < ImportAssetWindow.importer.getActivityLogLineCount(); %i++)
{ {
ImportLogTextList.addRow(%i, ImportActivityLog.getKey(%i)); ImportLogTextList.addRow(%i,ImportAssetWindow.importer.getActivityLogLine(%i));
} }
} }
// //

View file

@ -3,12 +3,6 @@ function ImportAssetConfigList::onSelect( %this, %id, %text )
//Apply our settings to the assets //Apply our settings to the assets
echo("Changed our import config!"); echo("Changed our import config!");
if(ImportActivityLog.count() != 0)
ImportActivityLog.add("");
ImportActivityLog.add("Asset Import Configs set to " @ %text);
ImportActivityLog.add("");
ImportAssetWindow.activeImportConfigIndex = %id; ImportAssetWindow.activeImportConfigIndex = %id;
//ImportAssetWindow.activeImportConfig = ImportAssetWindow.importConfigsList.getKey(%id); //ImportAssetWindow.activeImportConfig = ImportAssetWindow.importConfigsList.getKey(%id);
@ -236,12 +230,6 @@ function ImportAssetOptionsWindow::saveAssetOptions(%this)
{ {
%success = AssetImportSettings.write(); %success = AssetImportSettings.write();
if(ImportActivityLog.count() != 0)
ImportActivityLog.add("");
ImportActivityLog.add("Asset Import Configs saved, refreshing Import session");
ImportActivityLog.add("");
ImportAssetWindow.refresh(); ImportAssetWindow.refresh();
ImportAssetOptionsWindow.setVisible(0); ImportAssetOptionsWindow.setVisible(0);
} }