From 667a0db76004193bcc494a77b5ae0b18c5f8de5c Mon Sep 17 00:00:00 2001 From: Areloch Date: Mon, 8 May 2023 21:18:23 -0500 Subject: [PATCH] Fixed getAssetBy... functions so the lookup loop is more stable and doesn't fail if null results return Added sanity check to reflectionProbe preview shape so if the material didn't load right, it doesn't crash Added logic to better control if module groups as a whole should fail if a module dependency in that group fails, defaulted to off Added sanity check if a shape's material failed to load so it doesn't crash when checking accumulation rules Added search bar to SimView control for easier use --- Engine/source/T3D/assets/MaterialAsset.cpp | 10 +- Engine/source/T3D/assets/SoundAsset.cpp | 10 +- .../T3D/assets/TerrainMaterialAsset.cpp | 10 +- .../source/T3D/lighting/reflectionProbe.cpp | 3 + Engine/source/module/moduleManager.cpp | 10 +- Engine/source/module/moduleManager.h | 1 + Engine/source/ts/tsShapeInstance.cpp | 2 +- ...Group.asset.taml => simViewDlg.asset.taml} | 2 +- .../BaseGame/game/tools/gui/simViewDlg.ed.gui | 317 ++++++------------ 9 files changed, 130 insertions(+), 235 deletions(-) rename Templates/BaseGame/game/tools/gui/{simViewDlg, EditorGuiGroup.asset.taml => simViewDlg.asset.taml} (79%) diff --git a/Engine/source/T3D/assets/MaterialAsset.cpp b/Engine/source/T3D/assets/MaterialAsset.cpp index 5332da0b1..ec8397685 100644 --- a/Engine/source/T3D/assets/MaterialAsset.cpp +++ b/Engine/source/T3D/assets/MaterialAsset.cpp @@ -362,16 +362,16 @@ StringTableEntry MaterialAsset::getAssetIdByMaterialName(StringTableEntry matNam U32 foundCount = AssetDatabase.findAssetType(&query, "MaterialAsset"); if (foundCount != 0) { - for (U32 i = 0; i < foundCount; i++) + for (U32 i = 0; i < foundCount && materialAssetId == MaterialAsset::smNoMaterialAssetFallback; i++) { MaterialAsset* matAsset = AssetDatabase.acquireAsset(query.mAssetList[i]); - if (matAsset && matAsset->getMaterialDefinitionName() == matName) + if (matAsset) { - materialAssetId = matAsset->getAssetId(); + if (matAsset->getMaterialDefinitionName() == matName) + materialAssetId = matAsset->getAssetId(); + AssetDatabase.releaseAsset(query.mAssetList[i]); - break; } - AssetDatabase.releaseAsset(query.mAssetList[i]); } } diff --git a/Engine/source/T3D/assets/SoundAsset.cpp b/Engine/source/T3D/assets/SoundAsset.cpp index 2c4d9697b..7d49bb30d 100644 --- a/Engine/source/T3D/assets/SoundAsset.cpp +++ b/Engine/source/T3D/assets/SoundAsset.cpp @@ -274,16 +274,16 @@ StringTableEntry SoundAsset::getAssetIdByFileName(StringTableEntry fileName) U32 foundCount = AssetDatabase.findAssetType(&query, "SoundAsset"); if (foundCount != 0) { - for (U32 i = 0; i < foundCount; i++) + for (U32 i = 0; i < foundCount && soundAssetId == StringTable->EmptyString(); i++) { SoundAsset* soundAsset = AssetDatabase.acquireAsset(query.mAssetList[i]); - if (soundAsset && soundAsset->getSoundPath() == fileName) + if (soundAsset) { - soundAssetId = soundAsset->getAssetId(); + if (soundAsset->getSoundPath() == fileName) + soundAssetId = soundAsset->getAssetId(); + AssetDatabase.releaseAsset(query.mAssetList[i]); - break; } - AssetDatabase.releaseAsset(query.mAssetList[i]); } } diff --git a/Engine/source/T3D/assets/TerrainMaterialAsset.cpp b/Engine/source/T3D/assets/TerrainMaterialAsset.cpp index 88980b3b7..97635f162 100644 --- a/Engine/source/T3D/assets/TerrainMaterialAsset.cpp +++ b/Engine/source/T3D/assets/TerrainMaterialAsset.cpp @@ -378,16 +378,16 @@ StringTableEntry TerrainMaterialAsset::getAssetIdByMaterialName(StringTableEntry U32 foundCount = AssetDatabase.findAssetType(&query, "TerrainMaterialAsset"); if (foundCount != 0) { - for (U32 i = 0; i < foundCount; i++) + for (U32 i = 0; i < foundCount && materialAssetId == StringTable->EmptyString(); i++) { TerrainMaterialAsset* matAsset = AssetDatabase.acquireAsset(query.mAssetList[i]); - if (matAsset && matAsset->getMaterialDefinitionName() == matName) + if (matAsset) { - materialAssetId = matAsset->getAssetId(); + if (matAsset->getMaterialDefinitionName() == matName) + materialAssetId = matAsset->getAssetId(); + AssetDatabase.releaseAsset(query.mAssetList[i]); - break; } - AssetDatabase.releaseAsset(query.mAssetList[i]); } } diff --git a/Engine/source/T3D/lighting/reflectionProbe.cpp b/Engine/source/T3D/lighting/reflectionProbe.cpp index 9d92b69ce..f993b795c 100644 --- a/Engine/source/T3D/lighting/reflectionProbe.cpp +++ b/Engine/source/T3D/lighting/reflectionProbe.cpp @@ -883,6 +883,9 @@ void ReflectionProbe::prepRenderImage(SceneRenderState *state) BaseMatInstance* probePrevMat = mEditorShapeInst->getMaterialList()->getMaterialInst(0); + if (probePrevMat == nullptr) + return; + setPreviewMatParameters(state, probePrevMat); // GFXTransformSaver is a handy helper class that restores diff --git a/Engine/source/module/moduleManager.cpp b/Engine/source/module/moduleManager.cpp index 38685735d..c8c2b8a3b 100644 --- a/Engine/source/module/moduleManager.cpp +++ b/Engine/source/module/moduleManager.cpp @@ -104,6 +104,7 @@ S32 ModuleManager::moduleDependencySort(ModuleDefinition* const* a, ModuleDefini ModuleManager::ModuleManager() : mEnforceDependencies(true), mEchoInfo(false), + mFailGroupIfModuleFail(false), mDatabaseLocks( 0 ), mIgnoreLoadedGroups(false) { @@ -148,6 +149,7 @@ void ModuleManager::initPersistFields() addField( "EnforceDependencies", TypeBool, Offset(mEnforceDependencies, ModuleManager), "Whether the module manager enforces any dependencies on module definitions it discovers or not." ); addField( "EchoInfo", TypeBool, Offset(mEchoInfo, ModuleManager), "Whether the module manager echos extra information to the console or not." ); + addField( "FailGroupIfModuleFail", TypeBool, Offset(mFailGroupIfModuleFail, ModuleManager), "Whether the module manager will fail to load an entire module group if a single module fails to load."); } //----------------------------------------------------------------------------- @@ -292,8 +294,8 @@ bool ModuleManager::loadModuleGroup( const char* pModuleGroup ) StringTableEntry moduleId = *moduleIdItr; // Finish if we could not resolve the dependencies for module Id (of any version Id). - if ( !resolveModuleDependencies( moduleId, 0, moduleGroup, false, moduleResolvingQueue, moduleReadyQueue ) ) - return false; + if (!resolveModuleDependencies(moduleId, 0, moduleGroup, false, moduleResolvingQueue, moduleReadyQueue) && mFailGroupIfModuleFail) + return false; } // Check the modules we want to load to ensure that we do not have incompatible modules loaded already. @@ -524,8 +526,8 @@ bool ModuleManager::unloadModuleGroup( const char* pModuleGroup ) StringTableEntry moduleId = *moduleIdItr; // Finish if we could not resolve the dependencies for module Id (of any version Id). - if ( !resolveModuleDependencies( moduleId, 0, moduleGroup, false, moduleResolvingQueue, moduleReadyQueue ) ) - return false; + if (!resolveModuleDependencies(moduleId, 0, moduleGroup, false, moduleResolvingQueue, moduleReadyQueue) && mFailGroupIfModuleFail) + return false; } // Check the modules we want to load to ensure that we do not have incompatible modules loaded already. diff --git a/Engine/source/module/moduleManager.h b/Engine/source/module/moduleManager.h index 00f30c59f..dad530057 100644 --- a/Engine/source/module/moduleManager.h +++ b/Engine/source/module/moduleManager.h @@ -117,6 +117,7 @@ private: /// Miscellaneous. bool mEnforceDependencies; bool mEchoInfo; + bool mFailGroupIfModuleFail; S32 mDatabaseLocks; char mModuleExtension[256]; Taml mTaml; diff --git a/Engine/source/ts/tsShapeInstance.cpp b/Engine/source/ts/tsShapeInstance.cpp index 6d5c830dd..f757fdbbc 100644 --- a/Engine/source/ts/tsShapeInstance.cpp +++ b/Engine/source/ts/tsShapeInstance.cpp @@ -891,7 +891,7 @@ bool TSShapeInstance::hasAccumulation() for ( U32 i = 0; i < mMaterialList->size(); ++i ) { BaseMatInstance* mat = mMaterialList->getMaterialInst(i); - if ( mat->hasAccumulation() ) + if (mat != nullptr && mat->hasAccumulation() ) result = true; } return result; diff --git a/Templates/BaseGame/game/tools/gui/simViewDlg, EditorGuiGroup.asset.taml b/Templates/BaseGame/game/tools/gui/simViewDlg.asset.taml similarity index 79% rename from Templates/BaseGame/game/tools/gui/simViewDlg, EditorGuiGroup.asset.taml rename to Templates/BaseGame/game/tools/gui/simViewDlg.asset.taml index 3b664e559..1090830d3 100644 --- a/Templates/BaseGame/game/tools/gui/simViewDlg, EditorGuiGroup.asset.taml +++ b/Templates/BaseGame/game/tools/gui/simViewDlg.asset.taml @@ -1,7 +1,7 @@ diff --git a/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui b/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui index 7b35a7284..ed1b0db94 100644 --- a/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui @@ -1,262 +1,142 @@ //--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(simViewDlg, EditorGuiGroup) { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "0 0"; - Extent = "800 600"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; +$guiContent = new GuiControl(simViewDlg,EditorGuiGroup) { + extent = "1024 768"; + minExtent = "8 8"; + profile = "ToolsGuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + canSaveDynamicFields = "1"; new GuiWindowCtrl() { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiWindowProfile"; - HorizSizing = "center"; - VertSizing = "center"; - position = "70 43"; - Extent = "685 489"; - MinExtent = "602 440"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; text = "Torque SimView"; - maxLength = "1024"; - resizeWidth = "1"; - resizeHeight = "1"; - canMove = "1"; - canClose = "1"; - canMinimize = "1"; - canMaximize = "1"; - minSize = "50 50"; closeCommand = "Canvas.popDialog(simViewDlg);"; + position = "169 139"; + extent = "685 489"; + minExtent = "602 440"; + horizSizing = "center"; + vertSizing = "center"; + profile = "ToolsGuiWindowProfile"; + tooltipProfile = "GuiToolTipProfile"; new GuiScrollCtrl() { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiScrollProfile"; - HorizSizing = "width"; - VertSizing = "height"; - position = "10 28"; - Extent = "255 448"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - willFirstRespond = "1"; hScrollBar = "dynamic"; - vScrollBar = "alwaysOn"; - lockHorizScroll = "false"; - lockVertScroll = "false"; - constantThumbHeight = "0"; - childMargin = "0 0"; + position = "10 51"; + extent = "255 425"; + minExtent = "8 8"; + horizSizing = "width"; + vertSizing = "height"; + profile = "ToolsGuiScrollProfile"; + tooltipProfile = "GuiToolTipProfile"; new GuiTreeViewCtrl(InspectTreeView) { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiTreeViewProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "2 2"; - Extent = "212 21"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - tabSize = "16"; - textOffset = "2"; - fullRowSelect = "0"; itemHeight = "21"; - destroyTreeOnSleep = "1"; - MouseDragging = "1"; - MultipleSelections = "1"; - DeleteObjectAllowed = "1"; - DragToItemAllowed = "1"; + position = "2 25"; + extent = "212 21"; + minExtent = "8 8"; + profile = "ToolsGuiTreeViewProfile"; + tooltipProfile = "GuiToolTipProfile"; }; }; new GuiScrollCtrl() { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiScrollProfile"; - HorizSizing = "left"; - VertSizing = "height"; - position = "272 96"; - Extent = "404 380"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - willFirstRespond = "1"; hScrollBar = "alwaysOff"; - vScrollBar = "alwaysOn"; - lockHorizScroll = "true"; - lockVertScroll = "false"; - constantThumbHeight = "0"; - childMargin = "0 0"; + lockHorizScroll = "1"; + position = "272 96"; + extent = "404 380"; + minExtent = "8 8"; + horizSizing = "left"; + vertSizing = "height"; + profile = "ToolsGuiScrollProfile"; + tooltipProfile = "GuiToolTipProfile"; new GuiInspector(InspectFields) { - StackingType = "Vertical"; - HorizStacking = "Left to Right"; - VertStacking = "Top to Bottom"; - Padding = "1"; - canSaveDynamicFields = "0"; - Profile = "ToolsGuiTransparentProfile"; - HorizSizing = "width"; - VertSizing = "bottom"; - position = "2 2"; - Extent = "382 8"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; + position = "1 1"; + extent = "389 8"; + minExtent = "8 8"; + horizSizing = "width"; + profile = "ToolsGuiTransparentProfile"; + tooltipProfile = "GuiToolTipProfile"; }; }; + new GuiTextEditCtrl(SimViewTreeFilter) { + position = "11 27"; + extent = "255 18"; + profile = "ToolsGuiTextEditProfile"; + tooltipProfile = "GuiToolTipProfile"; + placeholderText = "Filter..."; + }; new GuiControl() { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiButtonProfile"; - HorizSizing = "left"; - VertSizing = "bottom"; position = "272 28"; - Extent = "403 61"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; + extent = "403 61"; + horizSizing = "left"; + profile = "ToolsGuiButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; new GuiTextEditCtrl(InspectObjectName) { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiTextEditProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; position = "121 8"; - Extent = "195 18"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - maxLength = "1024"; - historySize = "0"; - password = "0"; - tabComplete = "0"; - sinkAllKeyEvents = "0"; - password = "0"; - passwordMask = "*"; + extent = "195 18"; + minExtent = "8 8"; + profile = "ToolsGuiTextEditProfile"; + tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl() { - canSaveDynamicFields = "0"; - Profile = "EditorTextHLRight"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "217 35"; - Extent = "44 18"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; text = "Sim ID:"; - maxLength = "1024"; + position = "217 35"; + extent = "44 18"; + minExtent = "8 8"; + profile = "GuiTextProfile"; + tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl() { - canSaveDynamicFields = "0"; - Profile = "EditorTextHLRight"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "10 35"; - Extent = "106 18"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; text = "Internal Name:"; - maxLength = "1024"; + position = "10 35"; + extent = "106 18"; + minExtent = "8 8"; + profile = "GuiTextProfile"; + tooltipProfile = "GuiToolTipProfile"; }; new GuiTextEditCtrl(InspectObjectInternalName) { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiTextEditProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; position = "121 35"; - Extent = "93 18"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - maxLength = "1024"; - historySize = "0"; - password = "0"; - tabComplete = "0"; - sinkAllKeyEvents = "0"; - password = "0"; - passwordMask = "*"; + extent = "93 18"; + minExtent = "8 8"; + profile = "ToolsGuiTextEditProfile"; + tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl() { - canSaveDynamicFields = "0"; - Profile = "EditorTextHLBoldRight"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "10 8"; - Extent = "106 18"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; text = "Selected Object:"; - maxLength = "1024"; + position = "10 8"; + extent = "106 18"; + minExtent = "8 8"; + profile = "GuiTextProfile"; + tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl() { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiButtonProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "321 33"; - Extent = "76 22"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "InspectApply();"; - hovertime = "1000"; - text = "Refresh"; - groupNum = "-1"; - buttonType = "PushButton"; - bitmapAsset = "ToolsModule:iconRefresh_image"; - sizeIconToButton = "0"; + BitmapAsset = "ToolsModule:iconRefresh_image"; textLocation = "Right"; - textMargin = "4"; - buttonMargin = "4 4"; + text = "Refresh"; + position = "321 33"; + extent = "76 22"; + profile = "ToolsGuiButtonProfile"; + command = "InspectApply();"; + tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl(InspectObjectSimID) { - canSaveDynamicFields = "0"; - Profile = "EditorTextHLBoldCenter"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "265 35"; - Extent = "51 18"; - MinExtent = "8 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; text = "0"; - maxLength = "1024"; + position = "265 35"; + extent = "51 18"; + minExtent = "8 8"; + profile = "GuiTextProfile"; + tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl() { - canSaveDynamicFields = "0"; - Profile = "ToolsGuiButtonProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "321 6"; - Extent = "76 22"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "InspectDelete();"; - hovertime = "1000"; - text = "Delete"; - groupNum = "-1"; - buttonType = "PushButton"; - bitmapAsset = "ToolsModule:iconDelete_image"; - sizeIconToButton = "0"; + BitmapAsset = "ToolsModule:iconDelete_image"; textLocation = "Right"; - textMargin = "4"; - buttonMargin = "4 4"; + text = "Delete"; + position = "321 6"; + extent = "76 22"; + profile = "ToolsGuiButtonProfile"; + command = "InspectDelete();"; + tooltipProfile = "GuiToolTipProfile"; }; }; }; @@ -346,3 +226,12 @@ function GuiInspector::setAllGroupStateScript(%this, %obj, %groupState) %this.setAllGroupState(%groupState); %this.inspect(%obj); } + +function SimViewTreeFilter::onReturn(%this) +{ + %text = %this.getText(); + if( %text $= "" ) + %this.reset(); + else + InspectTreeView.setFilterText( %text ); +}