mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Merge pull request #750 from Areloch/MiscToolFixes20220320
Misc tool fixes20220320
This commit is contained in:
commit
fe7f2f761e
7 changed files with 176 additions and 24 deletions
|
|
@ -2534,7 +2534,10 @@ StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath, String typ
|
||||||
|
|
||||||
dumpActivityLog();
|
dumpActivityLog();
|
||||||
|
|
||||||
if (hasIssues)
|
if (hasIssues ||
|
||||||
|
assetItem->importStatus == AssetImportObject::Skipped ||
|
||||||
|
assetItem->importStatus == AssetImportObject::UseForDependencies ||
|
||||||
|
assetItem->importStatus == AssetImportObject::Error)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -480,16 +480,21 @@ bool TerrainBlock::saveAsset()
|
||||||
|
|
||||||
AssetDatabase.findAssetType(pAssetQuery, "TerrainMaterialAsset");
|
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++)
|
for (U32 i = 0; i < pAssetQuery->mAssetList.size(); i++)
|
||||||
{
|
{
|
||||||
//Acquire it so we can check it for matches
|
//Acquire it so we can check it for matches
|
||||||
AssetPtr<TerrainMaterialAsset> terrMatAsset = pAssetQuery->mAssetList[i];
|
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();
|
StringTableEntry assetMatDefName = terrMatAsset->getMaterialDefinitionName();
|
||||||
if (assetMatDefName == intMatName)
|
if (assetMatDefName == intMatName)
|
||||||
|
|
@ -1456,6 +1461,25 @@ void TerrainBlock::getUtilizedAssets(Vector<StringTableEntry>* usedAssetsList)
|
||||||
// Console Methods
|
// 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),,
|
DefineEngineMethod( TerrainBlock, save, bool, ( const char* fileName),,
|
||||||
"@brief Saves the terrain block's terrain file to the specified file name.\n\n"
|
"@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));
|
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));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -522,6 +522,19 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool renameTerrainMaterial(StringTableEntry oldMatName, StringTableEntry newMatName);
|
||||||
|
S32 getTerrainMaterialCount() {
|
||||||
|
if (mFile)
|
||||||
|
return mFile->mMaterials.size();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringTableEntry getTerrainMaterialName(S32 index) {
|
||||||
|
if (mFile)
|
||||||
|
return mFile->mMaterials[index]->getInternalName();
|
||||||
|
|
||||||
|
return StringTable->EmptyString();
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
bool mUpdateBasetex;
|
bool mUpdateBasetex;
|
||||||
bool mIgnoreZodiacs;
|
bool mIgnoreZodiacs;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#include "console/persistenceManager.h"
|
#include "console/persistenceManager.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "T3D/assets/TerrainMaterialAsset.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -166,6 +168,18 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
|
||||||
if ( mat )
|
if ( mat )
|
||||||
return 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
|
// We didn't find it... so see if its a path to a
|
||||||
// file. If it is lets assume its the texture.
|
// file. If it is lets assume its the texture.
|
||||||
if ( GBitmap::sFindFiles( nameOrPath, NULL ) )
|
if ( GBitmap::sFindFiles( nameOrPath, NULL ) )
|
||||||
|
|
@ -178,15 +192,9 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok... return a debug material then.
|
// Ok... return a placeholder 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".
|
|
||||||
mat = new TerrainMaterial();
|
mat = new TerrainMaterial();
|
||||||
mat->setInternalName( "warning_material" );
|
mat->setInternalName(nameOrPath);
|
||||||
mat->_setDiffuseMap(GFXTextureManager::getWarningTexturePath());
|
mat->_setDiffuseMap(GFXTextureManager::getWarningTexturePath());
|
||||||
mat->mDiffuseSize = 500;
|
mat->mDiffuseSize = 500;
|
||||||
mat->_setDetailMap(StringTable->EmptyString());
|
mat->_setDetailMap(StringTable->EmptyString());
|
||||||
|
|
@ -195,8 +203,7 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
|
||||||
mat->mMacroSize = 200;
|
mat->mMacroSize = 200;
|
||||||
mat->registerObject();
|
mat->registerObject();
|
||||||
|
|
||||||
Sim::getRootGroup()->addObject( mat );
|
Sim::getRootGroup()->addObject(mat);
|
||||||
}
|
|
||||||
|
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@
|
||||||
<Setting
|
<Setting
|
||||||
name="AdjustFloor">0</Setting>
|
name="AdjustFloor">0</Setting>
|
||||||
<Setting
|
<Setting
|
||||||
name="AlwaysAddShapeSuffix">0</Setting>
|
name="AlwaysAddShapeSuffix">1</Setting>
|
||||||
<Setting
|
<Setting
|
||||||
name="calcTangentSpace">0</Setting>
|
name="calcTangentSpace">0</Setting>
|
||||||
<Setting
|
<Setting
|
||||||
|
|
|
||||||
|
|
@ -353,6 +353,7 @@ function T3Dpre4ProjectImporter::beginMaterialFilesImport(%this)
|
||||||
%file = $ProjectImporter::FileList.getKey(%i);
|
%file = $ProjectImporter::FileList.getKey(%i);
|
||||||
%rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
|
%rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
|
||||||
|
|
||||||
|
$ProjectImporter::currentFile = %rootFileSectionObject.fileDestination;
|
||||||
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/"; //give context to the file we're processing
|
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/"; //give context to the file we're processing
|
||||||
|
|
||||||
if(%rootFileSectionObject.binaryFile == true || %rootFileSectionObject.imported == true)
|
if(%rootFileSectionObject.binaryFile == true || %rootFileSectionObject.imported == true)
|
||||||
|
|
@ -458,6 +459,7 @@ function T3Dpre4ProjectImporter::beginSoundProfilesImport(%this)
|
||||||
%file = $ProjectImporter::FileList.getKey(%i);
|
%file = $ProjectImporter::FileList.getKey(%i);
|
||||||
%rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
|
%rootFileSectionObject = $ProjectImporter::FileList.getValue(%i);
|
||||||
|
|
||||||
|
$ProjectImporter::currentFile = %rootFileSectionObject.fileDestination;
|
||||||
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/"; //give context to the file we're processing
|
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/"; //give context to the file we're processing
|
||||||
|
|
||||||
if(%rootFileSectionObject.binaryFile == true || %rootFileSectionObject.imported == true)
|
if(%rootFileSectionObject.binaryFile == true || %rootFileSectionObject.imported == true)
|
||||||
|
|
@ -523,16 +525,23 @@ function T3Dpre4ProjectImporter::processScripts(%this, %arrayObj)
|
||||||
T3Dpre4ProjectImporter.call(%processFunction, %lineObj, %sanitizedName);
|
T3Dpre4ProjectImporter.call(%processFunction, %lineObj, %sanitizedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now, we process the fields to be asset-ified on our object
|
//we're gunna handle the mission group definition lines specially because we need to process against an object's NAME
|
||||||
for(%l=0; %l < %lineObj.count(); %l++)
|
//rather than just the className
|
||||||
|
if(%lineObj.objectName $= "MissionGroup")
|
||||||
{
|
{
|
||||||
%objectCodeLine = %lineObj.getKey(%l);
|
$ProjectImporter::assetQuery.clear();
|
||||||
if(!isObject(%objectCodeLine))
|
%assetsFound = AssetDatabase.findAssetLooseFile($ProjectImporter::assetQuery, $ProjectImporter::currentFile);
|
||||||
|
if(%assetsFound != 0)
|
||||||
{
|
{
|
||||||
%processLineFunction = "process" @ %subclass @ "Line";
|
//ok, valid level asset
|
||||||
if(T3Dpre4ProjectImporter.isMethod(%processLineFunction))
|
%levelAssetId = $ProjectImporter::assetQuery.getAsset(0);
|
||||||
|
%levelName = AssetDatabase.getAssetName(%levelAssetId);
|
||||||
|
|
||||||
|
//Now, we process the fields to be asset-ified on our object
|
||||||
|
for(%l=0; %l < %lineObj.count(); %l++)
|
||||||
{
|
{
|
||||||
%resultLine = T3Dpre4ProjectImporter.call(%processLineFunction, %objectCodeLine);
|
%objectCodeLine = %lineObj.getKey(%l);
|
||||||
|
%resultLine = T3Dpre4ProjectImporter.processMissionGroupLine(%objectCodeLine, %levelName);
|
||||||
|
|
||||||
if(%resultLine !$= %objectCodeLine)
|
if(%resultLine !$= %objectCodeLine)
|
||||||
{
|
{
|
||||||
|
|
@ -542,6 +551,28 @@ function T3Dpre4ProjectImporter::processScripts(%this, %arrayObj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else //regular convertwork
|
||||||
|
{
|
||||||
|
//Now, we process the fields to be asset-ified on our object
|
||||||
|
for(%l=0; %l < %lineObj.count(); %l++)
|
||||||
|
{
|
||||||
|
%objectCodeLine = %lineObj.getKey(%l);
|
||||||
|
if(!isObject(%objectCodeLine))
|
||||||
|
{
|
||||||
|
%processLineFunction = "process" @ %subclass @ "Line";
|
||||||
|
if(T3Dpre4ProjectImporter.isMethod(%processLineFunction))
|
||||||
|
{
|
||||||
|
%resultLine = T3Dpre4ProjectImporter.call(%processLineFunction, %objectCodeLine);
|
||||||
|
|
||||||
|
if(%resultLine !$= %objectCodeLine)
|
||||||
|
{
|
||||||
|
projectImporterLog(" processed line: " @ %resultLine @ " from: " @ %objectCodeLine);
|
||||||
|
%lineObj.setKey(%resultLine, %l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%lineObj.processed = true;
|
%lineObj.processed = true;
|
||||||
|
|
@ -624,6 +655,7 @@ function T3Dpre4ProjectImporter::beginScriptFilesImport(%this)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ProjectImporter::currentFile = %rootFileSectionObject.fileDestination;
|
||||||
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
|
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
|
||||||
|
|
||||||
projectImporterLog("T3Dpre4ProjectImporter::beginScriptFilesImport() - Processing script file: " @ %file);
|
projectImporterLog("T3Dpre4ProjectImporter::beginScriptFilesImport() - Processing script file: " @ %file);
|
||||||
|
|
@ -693,6 +725,7 @@ function T3Dpre4ProjectImporter::beginAssetAndModuleImport(%this)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
projectImporterLog("T3Dpre4ProjectImporter::beginAssetAndModuleImport() - processing file: " @ %file);
|
projectImporterLog("T3Dpre4ProjectImporter::beginAssetAndModuleImport() - processing file: " @ %file);
|
||||||
|
$ProjectImporter::currentFile = %rootFileSectionObject.fileDestination;
|
||||||
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
|
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
|
||||||
%this.processModuleFile(%rootFileSectionObject);
|
%this.processModuleFile(%rootFileSectionObject);
|
||||||
%rootFileSectionObject.processed = true;
|
%rootFileSectionObject.processed = true;
|
||||||
|
|
|
||||||
|
|
@ -1613,6 +1613,21 @@ function beginTerrainImport()
|
||||||
//test import config here for forcing type suffixes
|
//test import config here for forcing type suffixes
|
||||||
%assetName = fileBase(%destinationPath);
|
%assetName = fileBase(%destinationPath);
|
||||||
|
|
||||||
|
if(AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName))
|
||||||
|
{
|
||||||
|
//Attempt to rename it to avoid collisions
|
||||||
|
if(!endsWith(%assetName, "Terrain") && !AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName @ "Terrain"))
|
||||||
|
{
|
||||||
|
%assetName = %assetName @ "Terrain";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Nope, there's already a matching one for that too, so just bail
|
||||||
|
projectImporterLog("Legacy Project Importer - Error - trying to process a Terrain into an asset that already exists");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
%assetPath = filePath(%destinationPath) @ "/";
|
%assetPath = filePath(%destinationPath) @ "/";
|
||||||
|
|
||||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||||
|
|
@ -1628,6 +1643,36 @@ function beginTerrainImport()
|
||||||
{
|
{
|
||||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||||
|
|
||||||
|
//we probably need to update the terrainMaterial references if any of them got renamed, so lets do that now
|
||||||
|
%terrBlock = new TerrainBlock(tmp) {
|
||||||
|
terrainAsset = %moduleName @ ":" @ %assetName;
|
||||||
|
};
|
||||||
|
|
||||||
|
%matNamesChanged = false;
|
||||||
|
%terrMatCount = %terrBlock.getTerrainMaterialCount();
|
||||||
|
for(%tm = 0; %tm < %terrMatCount; %tm++)
|
||||||
|
{
|
||||||
|
%terrMatName = %terrBlock.getTerrainMaterialName(%tm);
|
||||||
|
%terrMatAssetId = TerrainMaterialAsset::getAssetIdByMaterialName(%terrMatName);
|
||||||
|
if(%terrMatAssetId $= "")
|
||||||
|
{
|
||||||
|
//k, one didn't map right, lets try and fix it
|
||||||
|
%terrMatAssetId = TerrainMaterialAsset::getAssetIdByMaterialName(%terrMatName @ "_terrainMat");
|
||||||
|
if(%terrMatAssetId !$= "")
|
||||||
|
{
|
||||||
|
//Ok, success, lets run the rename
|
||||||
|
if(%terrBlock.renameTerrainMaterial(%terrMatName, %terrMatAssetId))
|
||||||
|
%matNamesChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(%matNamesChanged)
|
||||||
|
{
|
||||||
|
%terrBlock.saveAsset();
|
||||||
|
%terrBlock.delete();
|
||||||
|
}
|
||||||
|
|
||||||
projectImporterLog("Finished importing Terrain file, resulting in asset with an id of: " @ %moduleName @ ":" @ %assetName);
|
projectImporterLog("Finished importing Terrain file, resulting in asset with an id of: " @ %moduleName @ ":" @ %assetName);
|
||||||
projectImporterLog("");
|
projectImporterLog("");
|
||||||
|
|
||||||
|
|
@ -1918,9 +1963,18 @@ function beginLevelImport()
|
||||||
|
|
||||||
if(AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName))
|
if(AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName))
|
||||||
{
|
{
|
||||||
projectImporterLog("Legacy Project Importer - trying to process a level into an asset that already exists");
|
//Attempt to rename it to avoid collisions
|
||||||
|
if(!endsWith(%assetName, "Level") && !AssetDatabase.isDeclaredAsset(%moduleName @ ":" @ %assetName @ "Level"))
|
||||||
|
{
|
||||||
|
%assetName = %assetName @ "Level";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Nope, there's already a matching one for that too, so just bail
|
||||||
|
projectImporterLog("Legacy Project Importer - Error - trying to process a level into an asset that already exists");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
%assetPath = %filePath @ "/";
|
%assetPath = %filePath @ "/";
|
||||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue