فهرست منبع

Merge pull request #672 from Areloch/MiscFixes2021114

Misc fixes2021114
Brian Roberts 3 سال پیش
والد
کامیت
a05fe195e6

+ 74 - 7
Engine/source/T3D/assets/assetImporter.cpp

@@ -1158,12 +1158,76 @@ static bool enumColladaForImport(const char* shapePath, GuiTreeViewCtrl* tree, b
       {
          domImage* img = libraryImages->getImage_array()[j];
 
-         S32 materialID = tree->findItemByName(_GetNameOrId(img));
+         String imageName = _GetNameOrId(img);
+
+         S32 materialID = tree->findItemByName(imageName.c_str());
 
          if (materialID == 0)
-            continue;
+         {
+            bool materialFound = false;
+            String matName = "";
+
+            //If we don't have an immediate name match, we'll have to actually go look it up
+            for (S32 e = 0; e < root->getLibrary_effects_array().getCount(); e++)
+            {
+               const domLibrary_effects* libraryEffects = root->getLibrary_effects_array()[e];
+
+               for (S32 f = 0; f < libraryEffects->getEffect_array().getCount(); f++)
+               {
+                  domEffect* efct = libraryEffects->getEffect_array()[f];
+
+                  String effectName = efct->getID();
+
+                  for (S32 p = 0; p < efct->getFx_profile_abstract_array().getCount(); p++)
+                  {
+                     domProfile_COMMON* profile = daeSafeCast<domProfile_COMMON>(efct->getFx_profile_abstract_array()[p]);
+
+                     for (S32 n = 0; n < profile->getNewparam_array().getCount(); n++)
+                     {
+                        domCommon_newparam_typeRef param = profile->getNewparam_array()[n];
+                        String paramName = param->getSid();
+                        if (paramName.endsWith("-surface"))
+                        {
+                           //ok it's surface data, parse out the name
+                           String surfaceName = paramName.substr(0, paramName.length() - 8);
+                           if (surfaceName == imageName)
+                           {
+                              //got a match!
+                              matName = effectName;
+                              if (matName.endsWith("-effect"))
+                              {
+                                 matName = matName.substr(0, matName.length() - 7);
+                                 materialFound = true;
+                                 break;
+                              }
+                           }
+                        }
+                     }
 
-         tree->setItemValue(materialID, img->getInit_from()->getValue().str().c_str());
+                     if (materialFound)
+                        break;
+                  }
+
+                  if (materialFound)
+                  {
+                     materialID = tree->findItemByName(matName.c_str());
+                  }
+
+                  if (materialID != 0)
+                     break;
+               }
+            }
+
+            //if we STILL haven't found a match, then yes, we've failed
+            if (materialID == 0)
+               continue;
+         }
+
+         String imagePath = img->getInit_from()->getValue().str().c_str();
+         if (imagePath.startsWith("/"))
+            imagePath = imagePath.substr(1, imagePath.length() - 1);
+
+         tree->setItemValue(materialID, StringTable->insert(imagePath.c_str()));
       }
    }
 
@@ -2317,6 +2381,9 @@ void AssetImporter::resetImportConfig()
       Settings* importConfigs;
       if (Sim::findObject("AssetImportSettings", importConfigs))
       {
+         dSprintf(importLogBuffer, sizeof(importLogBuffer), "Loading import config: %s!", defaultImportConfig.c_str());
+         activityLog.push_back(importLogBuffer);
+
          //Now load the editor setting-deigned config!
          activeImportConfig->loadImportConfig(importConfigs, defaultImportConfig.c_str());
       }
@@ -2734,7 +2801,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
                }
                else if (imageType == ImageAsset::ImageTypes::Metalness)
                {
-                  mapFieldName = "MetalnessMap";
+                  mapFieldName = "MetalMap";
                }
                else if (imageType == ImageAsset::ImageTypes::AO)
                {
@@ -2742,7 +2809,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
                }
                else if (imageType == ImageAsset::ImageTypes::Roughness)
                {
-                  mapFieldName = "RoughnessMap";
+                  mapFieldName = "RoughMap";
                }
 
                assetFieldName = mapFieldName + "Asset[0]";
@@ -2810,7 +2877,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
          }
          else if (imageType == ImageAsset::ImageTypes::Metalness)
          {
-            mapFieldName = "MetalnessMap";
+            mapFieldName = "MetalMap";
          }
          else if (imageType == ImageAsset::ImageTypes::AO)
          {
@@ -2818,7 +2885,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
          }
          else if (imageType == ImageAsset::ImageTypes::Roughness)
          {
-            mapFieldName = "RoughnessMap";
+            mapFieldName = "RoughMap";
             hasRoughness = true;
          }
 

+ 8 - 2
Engine/source/T3D/assets/assetImporter.h

@@ -905,9 +905,15 @@ public:
    /// </summary>
    AssetImportConfig* getImportConfig() { return activeImportConfig; }
 
-   void setImportConfig(AssetImportConfig* importConfig) {
-      if(importConfig != nullptr)
+   void setImportConfig(AssetImportConfig* importConfig)
+   {
+      if (importConfig != nullptr)
+      {
+         dSprintf(importLogBuffer, sizeof(importLogBuffer), "Loading import config: %s!", importConfig->getName());
+         activityLog.push_back(importLogBuffer);
+
          activeImportConfig = importConfig;
+      }
    }
 
    /// <summary>

+ 1 - 1
Engine/source/ts/assimp/assimpShapeLoader.cpp

@@ -179,7 +179,7 @@ void AssimpShapeLoader::enumerateScene()
       String importFormat;
 
       const aiImporterDesc* importerDescription = aiGetImporterDesc(shapePath.getExtension().c_str());
-      if (importerDescription->mName == "Autodesk FBX Importer")
+      if (StringTable->insert(importerDescription->mName) == StringTable->insert("Autodesk FBX Importer"))
       {
          ColladaUtils::getOptions().formatScaleFactor = 0.01f;
       }

+ 10 - 0
Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript

@@ -642,4 +642,14 @@ function populateAllFonts(%font)
    populateFontCacheRange(%font,24,0,65535);
    populateFontCacheRange(%font,32,0,65535);
    populateFontCacheRange(%font,36,0,65535);
+}
+
+//------------------------------------------------------------------------------
+function playSoundAsset(%soundAssetId)
+{
+   %assetDef = AssetDatabase.acquireAsset(%soundAssetId);
+   if(isObject(%assetDef))
+      %assetDef.playSound();
+   
+   AssetDatabase.releaseAsset(%soundAssetId);
 }

+ 7 - 5
Templates/BaseGame/game/tools/assetBrowser/assetImportConfigs.xml

@@ -26,18 +26,18 @@
             <Setting name="AddedImageSuffix">_image</Setting>
             <Setting name="AlwaysAddImageSuffix">1</Setting>
             <Setting name="AOTypeSuffixes">_AO,_AMBIENT,_AMBIENTOCCLUSION</Setting>
-            <Setting name="CompositeTypeSuffixes">_COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM</Setting>
+            <Setting name="CompositeTypeSuffixes">_COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR,_ORM,-ORM,_C</Setting>
             <Setting name="Compressed">1</Setting>
             <Setting name="DiffuseTypeSuffixes">_ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL</Setting>
             <Setting name="GenerateMaterialOnImport">0</Setting>
             <Setting name="ImageType">N/A</Setting>
             <Setting name="ImportImages">1</Setting>
             <Setting name="IsHDR">0</Setting>
-            <Setting name="MetalnessTypeSuffixes">_METAL,_MET,_METALNESS,_METALLIC</Setting>
-            <Setting name="NormalTypeSuffixes">_NORMAL,_NORM</Setting>
-            <Setting name="RoughnessTypeSuffixes">_ROUGH,_ROUGHNESS</Setting>
+            <Setting name="MetalnessTypeSuffixes">_METAL,_MET,_METALNESS,_METALLIC,_M</Setting>
+            <Setting name="NormalTypeSuffixes">_NORMAL,_NORM,_N</Setting>
+            <Setting name="RoughnessTypeSuffixes">_ROUGH,_ROUGHNESS,_R</Setting>
             <Setting name="Scaling">1.0</Setting>
-            <Setting name="SmoothnessTypeSuffixes">_SMOOTH,_SMOOTHNESS</Setting>
+            <Setting name="SmoothnessTypeSuffixes">_SMOOTH,_SMOOTHNESS,_S</Setting>
             <Setting name="TextureFilteringMode">Bilinear</Setting>
             <Setting name="UseMips">1</Setting>
         </Group>
@@ -45,6 +45,8 @@
             <Setting name="AddedMaterialSuffix">_mat</Setting>
             <Setting name="AlwaysAddMaterialSuffix">0</Setting>
             <Setting name="CreateComposites">1</Setting>
+            <Setting name="CreateORMConfig">1</Setting>
+            <Setting name="IgnoreMaterials">DefaultMaterial</Setting>
             <Setting name="ImportMaterials">1</Setting>
             <Setting name="PopulateMaterialMaps">1</Setting>
             <Setting name="UseDiffuseSuffixOnOriginImage">1</Setting>

+ 12 - 3
Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.tscript

@@ -86,6 +86,8 @@ function ImportAssetWindow::onWake(%this)
    %this.importer.targetModuleId = AssetImportTargetModule.getText();
    
    %this.refresh();
+   
+   toggleImportWindowVizBtn.setStateOn(EditorSettings.value("Assets/AutoImport"));
 }
 
 //
@@ -469,9 +471,7 @@ function ImportAssetWindow::doRefresh(%this)
    ImportAssetWindow.importer.processImportingAssets();
    //%this.processImportAssets();
    
-   //ImportAssetWindow.hasImportIssues = %this.validateAssets();
-   
-   ImportAssetWindow.importer.validateImportingAssets();
+   ImportAssetWindow.hasImportIssues = ImportAssetWindow.importer.hasImportIssues();
    
    AssetImportCtrl-->NewAssetsTree.clear();
    AssetImportCtrl-->NewAssetsTree.insertItem(0, "Importing Assets");
@@ -947,3 +947,12 @@ function ImportAssetModuleList::refresh(%this)
    }
 }
 //
+
+//
+function toggleImportWindowViz()
+{
+   %value = EditorSettings.value("Assets/AutoImport");
+   EditorSettings.setValue("Assets/AutoImport", !%value);
+  
+}
+//

+ 2 - 2
Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.tscript

@@ -66,7 +66,7 @@ function setupImportConfigSettingsList()
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/ImportMaterials", "Import Materials", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/AlwaysAddMaterialSuffix", "Always Add Material Suffix", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/AddedMaterialSuffix", "Added Material Suffix", "string", "", "_mat", "");
-      ImportAssetConfigSettingsList.addNewConfigSetting("Materials/CreateComposites", "Create Composites", "bool", "", "1", "");
+      ImportAssetConfigSettingsList.addNewConfigSetting("Materials/CreateORMConfig", "Create ORM Map", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseDiffuseSuffixOnOriginImage", "Use Diffuse Suffix for Origin Image", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/UseExistingMaterials", "Use Existing Materials", "bool", "", "1", "");
       ImportAssetConfigSettingsList.addNewConfigSetting("Materials/IgnoreMaterials", "Ignore Materials", "command", "", "", "");
@@ -185,7 +185,7 @@ function ImportAssetOptionsWindow::editImportSettings(%this, %assetItem)
    else if(%assetType $= "MaterialAsset")
    {
       ImportOptionsList.startGroup("Material");
-      ImportOptionsList.addField("CreateComposites", "Create Composite Textures", "bool", "", "1", "", %assetConfigObj);
+      ImportOptionsList.addField("CreateORMConfig", "Create ORM Map", "bool", "", "1", "", %assetConfigObj);
       ImportOptionsList.endGroup();
    }
    else if(%assetType $= "ImageAsset")

+ 2 - 2
Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.tscript

@@ -25,7 +25,7 @@ function AssetBrowser::buildPopupMenus(%this)
 
          item[ 0 ] = "Edit Asset" TAB "" TAB "AssetBrowser.editAsset();";
          item[ 1 ] = "Rename Asset" TAB "" TAB "AssetBrowser.renameAsset();";
-         item[ 2 ] = "Refresh Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
+         item[ 2 ] = "Reload Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
          item[ 3 ] = "Asset Properties" TAB "" TAB "AssetBrowser.editAssetInfo();";
          item[ 4 ] = "-";
          Item[ 5 ] = "Duplicate Asset" TAB "" TAB "AssetBrowser.duplicateAsset();";
@@ -50,7 +50,7 @@ function AssetBrowser::buildPopupMenus(%this)
          item[ 0 ] = "Edit Level" TAB "" TAB "AssetBrowser.editAsset();";
          item[ 1 ] = "Append as Sublevel" TAB "" TAB "AssetBrowser.appendSublevel();";
          item[ 2 ] = "Rename Asset" TAB "" TAB "AssetBrowser.renameAsset();";
-         item[ 3 ] = "Refresh Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
+         item[ 3 ] = "Reload Asset" TAB "" TAB "AssetBrowser.refreshAsset();";
          item[ 4 ] = "Asset Properties" TAB "" TAB "AssetBrowser.editAssetInfo();";
          item[ 5 ] = "-";
          Item[ 6 ] = "Duplicate Asset" TAB "" TAB "AssetBrowser.duplicateAsset();";

+ 7 - 6
Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript

@@ -53,26 +53,27 @@ function ESettingsWindow::onWake( %this )
 
 function ESettingsWindow::hideDialog( %this )
 {
-   %this.setVisible(false);
+   Canvas.popDialog(EditorSettingsWindow);
 }
 
 function ESettingsWindow::ToggleVisibility()
 {
-   if ( ESettingsWindow.visible )
+   if(ESettingsWindow.isAwake())
    {
-      ESettingsWindow.setVisible(false);
+      Canvas.popDialog(EditorSettingsWindow);
    }
    else
    {
-      ESettingsWindow.setVisible(true);
+      Canvas.pushDialog(EditorSettingsWindow); 
+      
       ESettingsWindow.selectWindow();
       ESettingsWindow.setCollapseGroup(false);
       
       ESettingsWindowList.clear();
-   }
    
    ESettingsWindowList.setSelectedById( 1 );
 }
+}
 
 function ESettingsWindow::toggleProjectSettings(%this)
 {
@@ -528,7 +529,7 @@ function ESettingsWindow::getAssetEditingSettings(%this)
    }
    
    SettingsInspector.startGroup("Assets Importing");
-   SettingsInspector.addField("Edit Asset Configs", "Edit Asset Import Configs", "button", "Open Asset Import Config Editor", "", "Canvas.pushDialog(AssetImportConfigEditor);");
+   SettingsInspector.addField("Edit Import Configs", "Edit Asset Import Configs", "button", "Open Asset Import Config Editor", "", "Canvas.pushDialog(AssetImportConfigEditor);");
    SettingsInspector.addSettingsField("Assets/AssetImporDefaultConfig", "Default Asset Import Config", "list", "", %formattedConfigList); 
    SettingsInspector.addSettingsField("Assets/AutoImport", "Automatically Import using default config", "bool", "If on, the asset importing process" @
                                                                                                                         "will attempt to automatically import any inbound assets"@

+ 1 - 1
Templates/BaseGame/game/tools/settings.xml

@@ -35,7 +35,7 @@
         <Setting
             name="AssetImporDefaultConfig">DefaultImportConfig</Setting>
         <Setting
-            name="AutoImport">1</Setting>
+            name="AutoImport">0</Setting>
         <Group
             name="Browser">
             <Setting

+ 0 - 2
Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript

@@ -158,8 +158,6 @@ function EditorGui::init(%this)
    {
       exec("tools/gui/EditorSettingsWindow.ed.gui");
       exec("tools/gui/editorSettingsWindow.ed." @ $TorqueScriptFileExtension);
-      %this.add( ESettingsWindow );
-      ESettingsWindow.setVisible(false);
       
       // Start the standard settings tabs pages
       /*exec( "~/worldEditor/gui/GeneralSettingsTab.ed.gui" );

+ 0 - 142
Templates/BaseGame/game/tools/worldEditor/scripts/editorSettingsWindow.ed.tscript

@@ -1,142 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-function ESettingsWindow::startup( %this )
-{
-   ESettingsWindowTabBook.selectPage( 0 );
-   ESettingsWindowList.setSelectedById( 0 );
-}
-
-function ESettingsWindow::onWake( %this )
-{
-}
-
-function ESettingsWindow::hideDialog( %this )
-{
-   %this.setVisible(false);
-}
-
-function ESettingsWindow::ToggleVisibility()
-{
-   if ( ESettingsWindow.visible  )
-   {
-      ESettingsWindow.setVisible(false);
-   }
-   else
-   {
-      ESettingsWindow.setVisible(true);
-      ESettingsWindow.selectWindow();
-      ESettingsWindow.setCollapseGroup(false);
-   }
-}
-
-function ESettingsWindow::addTabPage( %this, %page )
-{
-   ESettingsWindowTabBook.add( %page );
-   ESettingsWindowList.addRow( ESettingsWindowTabBook.getSelectedPage(), %page.text );
-   ESettingsWindowList.sort(0);
-}
-
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowList::onSelect( %this, %id, %text )
-{
-   ESettingsWindowTabBook.selectPage( %id );
-}
-
-//-----------------------------------------------------------------------------
-// Standard settings GUI classes.  Editors may define their own methods of
-// working with settings and are not required to use these.
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowCheckbox::onWake( %this )
-{
-   %this.setStateOn( EditorSettings.value( %this.editorSettingsValue ));
-}
-
-function ESettingsWindowCheckbox::onClick( %this )
-{
-   EditorSettings.setValue( %this.editorSettingsValue, %this.getValue() );
-   eval(%this.editorSettingsRead);
-}
-
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowTextEdit::onWake( %this )
-{
-   %this.setText( EditorSettings.value( %this.editorSettingsValue ));
-}
-
-function ESettingsWindowTextEdit::onValidate( %this )
-{
-   EditorSettings.setValue( %this.editorSettingsValue, %this.getValue() );
-   eval(%this.editorSettingsRead);
-}
-
-function ESettingsWindowTextEdit::onGainFirstResponder( %this )
-{
-   %this.selectAllText();
-}
-
-//-----------------------------------------------------------------------------
-
-function ESettingsWindowColor::apply( %this, %color )
-{
-   EditorSettings.setValue( %this.editorSettingsValue, %color );
-   eval(%this.editorSettingsRead);
-
-   %this.findObjectByInternalName("ColorEdit", true).setText( %color);
-   %this.findObjectByInternalName("ColorButton", true).color = ColorIntToFloat( %color );
-}
-
-function ESettingsWindowColorEdit::onWake( %this )
-{
-   %this.setText( EditorSettings.value( %this.getParent().editorSettingsValue ));
-}
-
-function ESettingsWindowColorEdit::onValidate( %this )
-{
-   %this.getParent().apply( %this.getValue() );
-}
-
-function ESettingsWindowColorEdit::onGainFirstResponder( %this )
-{
-   %this.selectAllText();
-}
-
-function ESettingsWindowColorButton::onWake( %this )
-{
-   %this.color = ColorIntToFloat( EditorSettings.value( %this.getParent().editorSettingsValue ) );
-}
-
-function ESettingsWindowColorButton::onClick( %this )
-{
-   getColorI( ColorFloatToInt( %this.color ), %this.getId() @ ".apply", %this.getRoot() );
-   //EditorSettings.setValue( %this.editorSettingsValue, %this.getValue() );
-   //eval(%this.editorSettingsRead);
-}
-
-function ESettingsWindowColorButton::apply( %this, %color )
-{
-   %this.getParent().apply(%color);
-   echo("ESettingsWindowColorButton::apply(): " @ %color);
-}