mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-01 11:33:48 +00:00
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:
parent
ee4253c982
commit
cf8659735b
7 changed files with 176 additions and 24 deletions
|
|
@ -480,16 +480,21 @@ bool TerrainBlock::saveAsset()
|
|||
|
||||
AssetDatabase.findAssetType(pAssetQuery, "TerrainMaterialAsset");
|
||||
|
||||
TerrainBlock* clientTerr = static_cast<TerrainBlock*>(getClientObject());
|
||||
TerrainBlock* terr = static_cast<TerrainBlock*>(getClientObject());
|
||||
if (!terr)
|
||||
{
|
||||
Con::warnf("No active client terrain while trying to save asset. Could be a server action, but should check to be sure!");
|
||||
terr = this;
|
||||
}
|
||||
|
||||
for (U32 i = 0; i < pAssetQuery->mAssetList.size(); i++)
|
||||
{
|
||||
//Acquire it so we can check it for matches
|
||||
AssetPtr<TerrainMaterialAsset> terrMatAsset = pAssetQuery->mAssetList[i];
|
||||
|
||||
for (U32 m = 0; m < clientTerr->mFile->mMaterials.size(); m++)
|
||||
for (U32 m = 0; m < terr->mFile->mMaterials.size(); m++)
|
||||
{
|
||||
StringTableEntry intMatName = clientTerr->mFile->mMaterials[m]->getInternalName();
|
||||
StringTableEntry intMatName = terr->mFile->mMaterials[m]->getInternalName();
|
||||
|
||||
StringTableEntry assetMatDefName = terrMatAsset->getMaterialDefinitionName();
|
||||
if (assetMatDefName == intMatName)
|
||||
|
|
@ -1456,6 +1461,25 @@ void TerrainBlock::getUtilizedAssets(Vector<StringTableEntry>* usedAssetsList)
|
|||
// Console Methods
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool TerrainBlock::renameTerrainMaterial(StringTableEntry oldMatName, StringTableEntry newMatName)
|
||||
{
|
||||
TerrainMaterial* newMat = TerrainMaterial::findOrCreate(newMatName);
|
||||
if (!newMat)
|
||||
return false;
|
||||
|
||||
U32 terrainMaterialCount = mFile->mMaterials.size();
|
||||
for (U32 i = 0; i < terrainMaterialCount; i++)
|
||||
{
|
||||
if (mFile->mMaterials[i]->getInternalName() == oldMatName)
|
||||
{
|
||||
TerrainMaterial* oldMat = mFile->mMaterials[i];
|
||||
mFile->mMaterials[i] = newMat;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DefineEngineMethod( TerrainBlock, save, bool, ( const char* fileName),,
|
||||
"@brief Saves the terrain block's terrain file to the specified file name.\n\n"
|
||||
|
||||
|
|
@ -1623,3 +1647,21 @@ DefineEngineMethod(TerrainBlock, setTerrain, bool, (const char* terrain), , "Ter
|
|||
{
|
||||
return object->_setTerrain(StringTable->insert(terrain));
|
||||
}
|
||||
|
||||
DefineEngineMethod(TerrainBlock, getTerrainMaterialCount, S32, (), , "Gets the number of terrain materials for this block")
|
||||
{
|
||||
return object->getTerrainMaterialCount();
|
||||
}
|
||||
|
||||
DefineEngineMethod(TerrainBlock, getTerrainMaterialName, const char*, (S32 index), , "Gets the number of terrain materials for this block")
|
||||
{
|
||||
if (index < 0 || index >= object->getTerrainMaterialCount())
|
||||
return StringTable->EmptyString();
|
||||
|
||||
return object->getTerrainMaterialName(index);
|
||||
}
|
||||
|
||||
DefineEngineMethod(TerrainBlock, renameTerrainMaterial, bool, (const char* oldMaterialName, const char* newMaterialName), , "Updates the terrain material from the original to the new name in the file. Mostly used for import/conversions.")
|
||||
{
|
||||
return object->renameTerrainMaterial(StringTable->insert(oldMaterialName), StringTable->insert(newMaterialName));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue