mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Fixed formatting to match the standard for TerrainMaterialAsset inspector fields
Added utility functions to TerrainMaterialAsset for getting the material and fx material definitions Fixed logical flaw with the initialization code that could cause the materialDefinition to be nulled in terrainmaterialassets Fixed layer handling in GroundCover to properly work with TerrainMaterialAssets Added logic to properly exit out of the onAdd in the event no internal name is assigned or if there is a collision. This prevents duplicates from appearing in the terr mat editor when creating a new material Fixed issue where going from a creator item in the AB to selecting a particular asset type would break the filtering because select mode removed collections and creator items, changing all the item ids and breaking references. Added sanity check to prevent attempting to acquire non-assets in the AB, such as creator entries, which would cause console spam Added optional field to provide an override new asset name to the New Asset window Added logic so in the event no FX Material is found when importing a terrain material, it will create a stub entry so it always has one defined Added logic to handle situations where a terrain has a reference to an assetId, but the asset does not exist for whatever reason. Will prompt to create the missing asset, then continue on with the regular saving/editing process as normal Fixed issue where the terrain material editor would try and reference the preview images being used in the display on the editor instead of the proper assetId itself
This commit is contained in:
parent
3e39347167
commit
81aa43a4bd
9 changed files with 142 additions and 134 deletions
|
|
@ -639,9 +639,18 @@ function AssetBrowser::loadDirectories( %this )
|
|||
%dataItem = AssetBrowser-->filterTree.insertItem(AssetBrowser-->filterTree.modulesIdx, "data");
|
||||
AssetBrowser-->filterTree.tagsIdx = AssetBrowser-->filterTree.insertItem(1, "Tags");
|
||||
|
||||
if(!%this.selectMode)
|
||||
AssetBrowser-->filterTree.creatorIdx = AssetBrowser-->filterTree.insertItem(1, "Creator");
|
||||
|
||||
AssetBrowser-->filterTree.clearSelection();
|
||||
|
||||
if(%this.selectMode)
|
||||
{
|
||||
AssetBrowser-->filterTree.addSelection(AssetBrowser-->filterTree.collectionsIdx);
|
||||
AssetBrowser-->filterTree.addSelection(AssetBrowser-->filterTree.creatorIdx);
|
||||
|
||||
AssetBrowser-->filterTree.hideSelection();
|
||||
}
|
||||
|
||||
%this.dirHandler.loadFolders("data", %dataItem);
|
||||
|
||||
%this.loadCollectionSets();
|
||||
|
|
@ -750,20 +759,6 @@ function AssetBrowser::loadDirectories( %this )
|
|||
|
||||
function AssetBrowser::updateSelection( %this, %asset, %moduleName )
|
||||
{
|
||||
/*%isAssetBorder = 0;
|
||||
eval("%isAssetBorder = isObject(AssetBrowser-->"@%asset@"Border);");
|
||||
if( %isAssetBorder )
|
||||
{
|
||||
eval( "AssetBrowser-->"@%asset@"Border.setStateOn(1);");
|
||||
}
|
||||
|
||||
%isAssetBorderPrevious = 0;
|
||||
eval("%isAssetBorderPrevious = isObject(AssetBrowser-->"@%this.prevSelectedMaterialHL@"Border);");
|
||||
if( %isAssetBorderPrevious )
|
||||
{
|
||||
eval( "AssetBrowser-->"@%this.prevSelectedMaterialHL@"Border.setStateOn(0);");
|
||||
}*/
|
||||
|
||||
//If we had an existing selected assetDef, clear the reference
|
||||
if(isObject(AssetBrowser.selectedAssetDef))
|
||||
AssetDatabase.releaseAsset(AssetBrowser.selectedAssetDef.getAssetId());
|
||||
|
|
@ -775,11 +770,13 @@ function AssetBrowser::updateSelection( %this, %asset, %moduleName )
|
|||
if(strstr(%moduleName, "/") != -1)
|
||||
return;
|
||||
|
||||
//Otherwise, it's an asset so we'll select the definition while we're at it
|
||||
//Check if this is an actual assetId, or if it's just a programmatic reference
|
||||
//like what we use for the creator entries
|
||||
if(AssetDatabase.isDeclaredAsset(AssetBrowser.selectedAsset))
|
||||
{
|
||||
//Looks good, it's an asset so we'll select the definition while we're at it
|
||||
AssetBrowser.selectedAssetDef = AssetDatabase.acquireAsset(AssetBrowser.selectedAsset);
|
||||
//AssetBrowser.selectedPreviewImagePath = %previewImagePath;
|
||||
|
||||
//%this.prevSelectedMaterialHL = %asset;
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::loadCollectionSets(%this)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ function NewAssetModuleBtn::onClick(%this)
|
|||
AssetBrowser_addModuleWindow.selectWindow();
|
||||
}
|
||||
|
||||
function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %callback)
|
||||
function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %callback, %nameOverride)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_newAsset);
|
||||
|
||||
|
|
@ -106,8 +106,12 @@ function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %call
|
|||
%this.newAssetSettings.assetType = %assetType;
|
||||
%this.newAssetSettings.moduleName = %moduleName;
|
||||
|
||||
%newAssetName = "New" @ %shortAssetTypeName;
|
||||
if(%nameOverride !$= "")
|
||||
%newAssetName = %nameOverride;
|
||||
|
||||
NewAssetPropertiesInspector.startGroup("General");
|
||||
NewAssetPropertiesInspector.addField("assetName", "New Asset Name", "String", "Name of the new asset", "New" @ %shortAssetTypeName, "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("assetName", "New Asset Name", "String", "Name of the new asset", %newAssetName, "", %this.newAssetSettings);
|
||||
//NewAssetPropertiesInspector.addField("AssetType", "New Asset Type", "List", "Type of the new asset", %assetType, "Component,Image,Material,Shape,Sound,State Machine", %newAssetSettings);
|
||||
|
||||
//NewAssetPropertiesInspector.addField("friendlyName", "Friendly Name", "String", "Human-readable name of new asset", "", "", %this.newAssetSettings);
|
||||
|
|
|
|||
|
|
@ -1244,6 +1244,15 @@ function T3Dpre4ProjectImporter::processTerrainMaterialObject(%this, %fileObject
|
|||
%fileObject.FXMaterial.processed = true;
|
||||
%fileObject.FXMaterial.skip = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if after all that we still have no FXMaterial, just create a new one
|
||||
%fxMat = new Material("TerrainFX_" @ %objectName)
|
||||
{
|
||||
mapTo = %objectName;
|
||||
};
|
||||
%asset.add(%fxMat);
|
||||
}
|
||||
|
||||
%success = false;
|
||||
if(TamlWrite(%asset, %tamlpath))
|
||||
|
|
|
|||
|
|
@ -474,11 +474,36 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat )
|
|||
|
||||
function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
|
||||
{
|
||||
//If we happen to have been handed an assetId, process it
|
||||
if(AssetDatabase.isDeclaredAsset(%mat))
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(%mat);
|
||||
%mat = %assetDef.getMaterialDefinition();
|
||||
}
|
||||
|
||||
// Skip over obviously bad cases.
|
||||
if ( !isObject( %mat ) ||
|
||||
!%mat.isMemberOfClass( TerrainMaterial ) )
|
||||
return;
|
||||
|
||||
//Lets validate it wasn't a generated stub. if so, we need to add an intermediate
|
||||
//step to create the asset
|
||||
%assetDef = AssetDatabase.acquireAsset(%mat.internalName);
|
||||
if(%assetDef $= "")
|
||||
{
|
||||
%moduleSplit = strpos(%mat.internalName, ":");
|
||||
%moduleName = getSubStr(%mat.internalName, 0, %moduleSplit);
|
||||
%assetName = getSubStr(%mat.internalName, %moduleSplit+1, -1);
|
||||
if(ModuleDatabase.findModule(%moduleName) !$= "")
|
||||
{
|
||||
AssetBrowser.selectedModule = %moduleName;
|
||||
}
|
||||
|
||||
//we need to create an actual asset here
|
||||
AssetBrowser.setupCreateNewAsset("TerrainMaterialAsset", AssetBrowser.selectedModule, "TerrainMaterialDlg.saveDirtyMaterial", %assetName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Read out properties from the dialog.
|
||||
|
||||
%newName = %this-->matNameCtrl.getText();
|
||||
|
|
@ -487,28 +512,28 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
|
|||
|
||||
|
||||
//---
|
||||
%newDiffuse = %this-->texDiffuseMap.getBitmap();
|
||||
if(%newDiffuse $= $TerrainMaterialEditor::emptyMaterialImage || %newDiffuse $= %blankBitmap)
|
||||
%newDiffuse = %this-->diffuseMapAssetId.text;
|
||||
if(%newDiffuse $= "None")
|
||||
%newDiffuse = "";
|
||||
|
||||
//---
|
||||
%newNormal = %this-->texNormalMap.getBitmap();
|
||||
if(%newNormal $= $TerrainMaterialEditor::emptyMaterialImage || %newNormal $= %blankBitmap)
|
||||
%newNormal = %this-->normalMapAssetId.text;
|
||||
if(%newNormal $= "None")
|
||||
%newNormal = "";
|
||||
|
||||
//---
|
||||
%newormConfig = %this-->texORMConfigMap.getBitmap();
|
||||
if(%newormConfig $= $TerrainMaterialEditor::emptyMaterialImage || %newormConfig $= %blankBitmap)
|
||||
%newormConfig = %this-->ORMMapAssetId.text;
|
||||
if(%newormConfig $= "None")
|
||||
%newormConfig = "";
|
||||
|
||||
//---
|
||||
%newDetail = %this-->texDetailMap.getBitmap();
|
||||
if(%newDetail $= $TerrainMaterialEditor::emptyMaterialImage || %newDetail $= %blankBitmap)
|
||||
%newDetail = %this-->detailMapAssetId.text;
|
||||
if(%newDetail $= "None")
|
||||
%newDetail = "";
|
||||
|
||||
//---
|
||||
%newMacro = %this-->texMacroMap.getBitmap();
|
||||
if(%newMacro $= $TerrainMaterialEditor::emptyMaterialImage || %newMacro $= %blankBitmap)
|
||||
%newMacro = %this-->macroMapAssetId.text;
|
||||
if(%newMacro $= "None")
|
||||
%newMacro = "";
|
||||
|
||||
%detailSize = %this-->detSizeCtrl.getText();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue