Adjusts handling so if a file being processed for importing is not actually imported as a new, successful asset it does not return an id, allowing tooling to only worry about actual new assets.

Adds utility functions to TerrainBlock to be able to replace names of materials in the terrain file, mostly used for importing legacy files
Adjusts terrainblock save asset logic to be able to save on a non-networked terrainblock such as when loaded temporarily on the server, for tooling purposes.
Changes handling of not-found terrain materials when loading a terrain block so it will create a dummy terrain material with the same name as the not-found, but set the texture as the Warning image, instead of thrashing the original material names data
Adds logic for testing newly imported terrain files' materials and if needbe, replacing them with the new terrain material asset ids.
Adds logic in the project importer for if a would-be level asset's name already exists, we attempt to slap a "Level" suffix onto it to sidestep collisions.
Changed LegacyImport config to try always adding shape suffix to help minimize probable naming collisions.
Fixed handling of mission file's MissionGroup defines by specially checking for MissionGroup objects and processing the line into a Scene() declaration instead.
This commit is contained in:
JeffR 2022-03-20 16:17:06 -05:00
parent ee4253c982
commit cf8659735b
7 changed files with 176 additions and 24 deletions

View file

@ -30,6 +30,8 @@
#include "console/persistenceManager.h"
#endif
#include "T3D/assets/TerrainMaterialAsset.h"
#include <string>
@ -166,6 +168,18 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
if ( mat )
return mat;
StringTableEntry assetId = TerrainMaterialAsset::getAssetIdByMaterialName(nameOrPath);
if (assetId != StringTable->EmptyString())
{
TerrainMaterialAsset* terrMatAsset = AssetDatabase.acquireAsset<TerrainMaterialAsset>(assetId);
if (terrMatAsset)
{
mat = terrMatAsset->getMaterialDefinition();
if (mat)
return mat;
}
}
// We didn't find it... so see if its a path to a
// file. If it is lets assume its the texture.
if ( GBitmap::sFindFiles( nameOrPath, NULL ) )
@ -178,15 +192,9 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
return mat;
}
// Ok... return a debug material then.
mat = dynamic_cast<TerrainMaterial*>( set->findObjectByInternalName( StringTable->insert( "warning_material" ) ) );
if ( !mat )
{
// This shouldn't happen.... the warning_texture should
// have already been defined in script, but we put this
// fallback here just in case it gets "lost".
// Ok... return a placeholder material then.
mat = new TerrainMaterial();
mat->setInternalName( "warning_material" );
mat->setInternalName(nameOrPath);
mat->_setDiffuseMap(GFXTextureManager::getWarningTexturePath());
mat->mDiffuseSize = 500;
mat->_setDetailMap(StringTable->EmptyString());
@ -195,8 +203,7 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
mat->mMacroSize = 200;
mat->registerObject();
Sim::getRootGroup()->addObject( mat );
}
Sim::getRootGroup()->addObject(mat);
return mat;
}