Updates the rest of the asset types to utilize separate expanded path variables to avoid breaking assetDef saving

Fixes select mode for the Asset Browser to properly filter to the selecting type
Fixes the imageType in the asset import window inspector to properly set to the importing image asset's discovered type if valid
Fixes AssetBrowser asset selection return so it returns back a valid assetId
Fixes TerrainMaterial save crash by ensuring we fill in the diffuseMapAsset
Removes saving of TerrainMaterial being saved to a generic script file if one isn't found for an existing TerrainMaterialAssets
This commit is contained in:
Areloch 2020-08-09 01:32:27 -05:00
parent 08f8d8abf2
commit 79ecc2f4a0
30 changed files with 241 additions and 106 deletions

View file

@ -124,6 +124,7 @@ ConsoleSetType(TypeTerrainAssetId)
TerrainAsset::TerrainAsset()
{
mTerrainFileName = StringTable->EmptyString();
mTerrainFilePath = StringTable->EmptyString();
}
@ -141,8 +142,8 @@ void TerrainAsset::initPersistFields()
Parent::initPersistFields();
//addField("shaderGraph", TypeRealString, Offset(mShaderGraphFile, TerrainAsset), "");
addProtectedField("terrainFile", TypeAssetLooseFilePath, Offset(mTerrainFilePath, TerrainAsset),
&setTerrainFilePath, &getTerrainFilePath, "Path to the file containing the terrain data.");
addProtectedField("terrainFile", TypeAssetLooseFilePath, Offset(mTerrainFileName, TerrainAsset),
&setTerrainFileName, &getTerrainFileName, "Path to the file containing the terrain data.");
}
void TerrainAsset::setDataField(StringTableEntry slotName, const char* array, const char* value)
@ -164,19 +165,19 @@ void TerrainAsset::initializeAsset()
// Call parent.
Parent::initializeAsset();
mTerrainFilePath = expandAssetFilePath(mTerrainFilePath);
mTerrainFilePath = expandAssetFilePath(mTerrainFileName);
loadTerrain();
}
void TerrainAsset::onAssetRefresh()
{
mTerrainFilePath = expandAssetFilePath(mTerrainFilePath);
mTerrainFilePath = expandAssetFilePath(mTerrainFileName);
loadTerrain();
}
void TerrainAsset::setTerrainFilePath(const char* pScriptFile)
void TerrainAsset::setTerrainFileName(const char* pScriptFile)
{
// Sanity!
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
@ -185,7 +186,7 @@ void TerrainAsset::setTerrainFilePath(const char* pScriptFile)
pScriptFile = StringTable->insert(pScriptFile);
// Update.
mTerrainFilePath = pScriptFile;
mTerrainFileName = pScriptFile;
// Refresh the asset.
refreshAsset();
@ -259,7 +260,7 @@ bool TerrainAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<Terrai
newTerrainAsset->setAssetName(assetName.c_str());
String terrainPathBind = terrFilePath.getFileName() + terrFilePath.getExtension();
newTerrainAsset->mTerrainFilePath = StringTable->insert(terrainPathBind.c_str());
newTerrainAsset->mTerrainFileName = StringTable->insert(terrainPathBind.c_str());
newTerrainAsset->saveAsset();
@ -350,7 +351,7 @@ StringTableEntry TerrainAsset::getAssetIdByFilename(StringTableEntry fileName)
newTerrainAsset->setAssetName(assetName.c_str());
String terrainPathBind = terrFilePath.getFileName() + "." + terrFilePath.getExtension();
newTerrainAsset->mTerrainFilePath = StringTable->insert(terrainPathBind.c_str());
newTerrainAsset->mTerrainFileName = StringTable->insert(terrainPathBind.c_str());
newTerrainAsset->saveAsset();