mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Merge pull request #1725 from Areloch/AssetReimportFixes
Various fixes for Asset Reimporting functionality
This commit is contained in:
commit
ebefc62955
13 changed files with 160 additions and 144 deletions
|
|
@ -556,6 +556,7 @@ void AssetImporter::initPersistFields()
|
||||||
addField("finalImportedAssetPath", TypeRealString, Offset(finalImportedAssetPath, AssetImporter), "The Id of the module the assets are to be imported into");
|
addField("finalImportedAssetPath", TypeRealString, Offset(finalImportedAssetPath, AssetImporter), "The Id of the module the assets are to be imported into");
|
||||||
addField("targetPath", TypeRealString, Offset(targetPath, AssetImporter), "The path any imported assets are placed in as their destination");
|
addField("targetPath", TypeRealString, Offset(targetPath, AssetImporter), "The path any imported assets are placed in as their destination");
|
||||||
addField("dumpLogs", TypeBool, Offset(mDumpLogs, AssetImporter), "Indicates if the importer always dumps its logs or not");
|
addField("dumpLogs", TypeBool, Offset(mDumpLogs, AssetImporter), "Indicates if the importer always dumps its logs or not");
|
||||||
|
addField("isReimport", TypeBool, Offset(isReimport, AssetImporter), "Indicates if the importing action being performed is a re-import of an existing asset");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -3051,6 +3052,8 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
|
||||||
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
|
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
|
||||||
String originalPath = assetItem->filePath.getFullPath().c_str();
|
String originalPath = assetItem->filePath.getFullPath().c_str();
|
||||||
String originalConstructorPath = assetItem->filePath.getPath() + "/" + constructorFileName;
|
String originalConstructorPath = assetItem->filePath.getPath() + "/" + constructorFileName;
|
||||||
|
String fullAssetName = assetItem->moduleName + ":" + assetItem->assetName;
|
||||||
|
TSShapeConstructor* constructor = NULL;
|
||||||
|
|
||||||
newAsset->setAssetName(assetName);
|
newAsset->setAssetName(assetName);
|
||||||
newAsset->setShapeFile(shapeFileName.c_str());
|
newAsset->setShapeFile(shapeFileName.c_str());
|
||||||
|
|
@ -3153,17 +3156,20 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (makeNewConstructor)
|
|
||||||
{
|
{
|
||||||
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning creation of new TSShapeConstructor file: %s", constructorPath.c_str());
|
//If we're re-importing, we probably have an existing constructor. Try to find it
|
||||||
|
constructor = TSShapeConstructor::findShapeConstructorByAssetId(StringTable->insert(fullAssetName.c_str()));
|
||||||
|
if (constructor)
|
||||||
|
makeNewConstructor = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning setup of TSShapeConstructor file: %s", constructorPath.c_str());
|
||||||
activityLog.push_back(importLogBuffer);
|
activityLog.push_back(importLogBuffer);
|
||||||
|
|
||||||
//find/create shape constructor
|
//find/create shape constructor
|
||||||
TSShapeConstructor* constructor = TSShapeConstructor::findShapeConstructorByFilename(Torque::Path(constructorPath).getFullPath());
|
if (makeNewConstructor)
|
||||||
if (constructor == NULL)
|
|
||||||
{
|
{
|
||||||
String fullAssetName = assetItem->moduleName + ":" + assetItem->assetName;
|
|
||||||
constructor = new TSShapeConstructor(StringTable->insert(fullAssetName.c_str()));
|
constructor = new TSShapeConstructor(StringTable->insert(fullAssetName.c_str()));
|
||||||
|
|
||||||
String constructorName = assetItem->filePath.getFileName() + assetItem->filePath.getExtension().substr(0, 3);
|
String constructorName = assetItem->filePath.getFileName() + assetItem->filePath.getExtension().substr(0, 3);
|
||||||
|
|
@ -3174,6 +3180,13 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
|
||||||
constructor->registerObject(constructorName.c_str());
|
constructor->registerObject(constructorName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!constructor)
|
||||||
|
{
|
||||||
|
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Faled to find or create a new shape constructor for shape file: ", shapeFileName.c_str());
|
||||||
|
activityLog.push_back(importLogBuffer);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
//now we write the import config logic into the constructor itself to ensure we load like we wanted it to
|
//now we write the import config logic into the constructor itself to ensure we load like we wanted it to
|
||||||
String neverImportMats;
|
String neverImportMats;
|
||||||
|
|
||||||
|
|
@ -3278,7 +3291,6 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructorPersist->destroySelf();
|
constructorPersist->destroySelf();
|
||||||
}
|
|
||||||
|
|
||||||
//restore the cached version just in case we loaded a sis file
|
//restore the cached version just in case we loaded a sis file
|
||||||
cachedConfig->CopyTo(activeImportConfig);
|
cachedConfig->CopyTo(activeImportConfig);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//--- OBJECT WRITE BEGIN ---
|
//--- OBJECT WRITE BEGIN ---
|
||||||
new TSShapeConstructor(ConePrimitive_fbx) {
|
new TSShapeConstructor(ConePrimitive_fbx) {
|
||||||
baseShapeAsset = "Prototyping:ConePrimitive";
|
baseShapeAsset = "Prototyping:ConePrimitive_shape";
|
||||||
upAxis = "DEFAULT";
|
upAxis = "DEFAULT";
|
||||||
unit = "-1";
|
unit = "-1";
|
||||||
LODType = "TrailingNumber";
|
LODType = "TrailingNumber";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//--- OBJECT WRITE BEGIN ---
|
//--- OBJECT WRITE BEGIN ---
|
||||||
new TSShapeConstructor(CubePrimitive_fbx) {
|
new TSShapeConstructor(CubePrimitive_fbx) {
|
||||||
baseShapeAsset = "Prototyping:CubePrimitive";
|
baseShapeAsset = "Prototyping:CubePrimitive_shape";
|
||||||
upAxis = "DEFAULT";
|
upAxis = "DEFAULT";
|
||||||
unit = "-1";
|
unit = "-1";
|
||||||
LODType = "TrailingNumber";
|
LODType = "TrailingNumber";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//--- OBJECT WRITE BEGIN ---
|
//--- OBJECT WRITE BEGIN ---
|
||||||
new TSShapeConstructor(CylinderPrimitive_fbx) {
|
new TSShapeConstructor(CylinderPrimitive_fbx) {
|
||||||
baseShapeAsset = "Prototyping:CylinderPrimitive";
|
baseShapeAsset = "Prototyping:CylinderPrimitive_shape";
|
||||||
upAxis = "DEFAULT";
|
upAxis = "DEFAULT";
|
||||||
unit = "-1";
|
unit = "-1";
|
||||||
LODType = "TrailingNumber";
|
LODType = "TrailingNumber";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//--- OBJECT WRITE BEGIN ---
|
//--- OBJECT WRITE BEGIN ---
|
||||||
new TSShapeConstructor(SpherePrimitive_fbx) {
|
new TSShapeConstructor(SpherePrimitive_fbx) {
|
||||||
baseShapeAsset = "Prototyping:SpherePrimitive";
|
baseShapeAsset = "Prototyping:SpherePrimitive_shape";
|
||||||
upAxis = "DEFAULT";
|
upAxis = "DEFAULT";
|
||||||
unit = "-1";
|
unit = "-1";
|
||||||
LODType = "TrailingNumber";
|
LODType = "TrailingNumber";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//--- OBJECT WRITE BEGIN ---
|
//--- OBJECT WRITE BEGIN ---
|
||||||
new TSShapeConstructor(TorusPrimitive_fbx) {
|
new TSShapeConstructor(TorusPrimitive_fbx) {
|
||||||
baseShapeAsset = "Prototyping:TorusPrimitive";
|
baseShapeAsset = "Prototyping:TorusPrimitive_shape";
|
||||||
upAxis = "DEFAULT";
|
upAxis = "DEFAULT";
|
||||||
unit = "-1";
|
unit = "-1";
|
||||||
LODType = "TrailingNumber";
|
LODType = "TrailingNumber";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//--- OBJECT WRITE BEGIN ---
|
//--- OBJECT WRITE BEGIN ---
|
||||||
new TSShapeConstructor(TubePrimitive_fbx) {
|
new TSShapeConstructor(TubePrimitive_fbx) {
|
||||||
baseShapeAsset = "Prototyping:TubePrimitive";
|
baseShapeAsset = "Prototyping:TubePrimitive_shape";
|
||||||
upAxis = "DEFAULT";
|
upAxis = "DEFAULT";
|
||||||
unit = "-1";
|
unit = "-1";
|
||||||
LODType = "TrailingNumber";
|
LODType = "TrailingNumber";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
singleton TSShapeConstructor(cardae)
|
singleton TSShapeConstructor(cardae)
|
||||||
{
|
{
|
||||||
baseShapeAsset = "./car.dae";
|
baseShapeAsset = "Prototyping:car_shape";
|
||||||
singleDetailSize = "0";
|
singleDetailSize = "0";
|
||||||
flipUVCoords = "0";
|
flipUVCoords = "0";
|
||||||
JoinIdenticalVerts = "0";
|
JoinIdenticalVerts = "0";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
singleton TSShapeConstructor(carwheeldae)
|
singleton TSShapeConstructor(carwheeldae)
|
||||||
{
|
{
|
||||||
baseShapeAsset = "./carwheel.dae";
|
baseShapeAsset = "Prototyping:carwheel_shape";
|
||||||
singleDetailSize = "0";
|
singleDetailSize = "0";
|
||||||
flipUVCoords = "0";
|
flipUVCoords = "0";
|
||||||
JoinIdenticalVerts = "0";
|
JoinIdenticalVerts = "0";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
singleton TSShapeConstructor(flierdae)
|
singleton TSShapeConstructor(flierdae)
|
||||||
{
|
{
|
||||||
baseShapeAsset = "./flier.dae";
|
baseShapeAsset = "Prototyping:flier_shape";
|
||||||
singleDetailSize = "0";
|
singleDetailSize = "0";
|
||||||
flipUVCoords = "0";
|
flipUVCoords = "0";
|
||||||
JoinIdenticalVerts = "0";
|
JoinIdenticalVerts = "0";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
singleton TSShapeConstructor(hoverboatdae)
|
singleton TSShapeConstructor(hoverboatdae)
|
||||||
{
|
{
|
||||||
baseShapeAsset = "./hoverboat.dae";
|
baseShapeAsset = "Prototyping:hoverboat_shape";
|
||||||
singleDetailSize = "0";
|
singleDetailSize = "0";
|
||||||
flipUVCoords = "0";
|
flipUVCoords = "0";
|
||||||
JoinIdenticalVerts = "0";
|
JoinIdenticalVerts = "0";
|
||||||
|
|
|
||||||
|
|
@ -1213,13 +1213,16 @@ function AssetBrowser::changeAsset(%this)
|
||||||
function AssetBrowser::reImportAsset(%this)
|
function AssetBrowser::reImportAsset(%this)
|
||||||
{
|
{
|
||||||
//Find out what type it is
|
//Find out what type it is
|
||||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
%assetDef = AssetDatabase.acquireAsset(%this.popupMenu.objectData);
|
||||||
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
|
%assetType = %this.popupMenu.objectType;
|
||||||
|
|
||||||
if(%assetType $= "ShapeAsset" || %assetType $= "ImageAsset" || %assetType $= "SoundAsset")
|
if(%assetType $= "ShapeAsset" || %assetType $= "ImageAsset" || %assetType $= "SoundAsset")
|
||||||
{
|
{
|
||||||
AssetBrowser.isAssetReImport = true;
|
%this.isAssetReImport = true;
|
||||||
AssetBrowser.reImportingAssetId = EditAssetPopup.assetId;
|
%this.reImportingAssetId = %assetDef.getAssetId();
|
||||||
|
|
||||||
|
//just to force it to be fully loaded and prepped on the off chance the asset isn't yet
|
||||||
|
%assetDef.load();
|
||||||
|
|
||||||
%reimportingPath = %assetDef.originalFilePath;
|
%reimportingPath = %assetDef.originalFilePath;
|
||||||
|
|
||||||
|
|
@ -1262,14 +1265,15 @@ function AssetBrowser::reImportAsset(%this)
|
||||||
%dlg.delete();
|
%dlg.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetBrowser.onBeginDropFiles();
|
ImportAssetWindow.importer.isReimport = true;
|
||||||
AssetBrowser.onDropFile(%reimportingPath);
|
%this.onBeginDropFiles();
|
||||||
AssetBrowser.onEndDropFiles();
|
%this.onDropFile(%reimportingPath);
|
||||||
|
%this.onEndDropFiles();
|
||||||
|
|
||||||
%module = AssetDatabase.getAssetModule(EditAssetPopup.assetId);
|
%module = AssetDatabase.getAssetModule(%this.reImportingAssetId);
|
||||||
|
|
||||||
//get the selected module data
|
//get the selected module data
|
||||||
ImportAssetModuleList.setText(%module.ModuleId);
|
AssetImportTargetModule.setText(%module.ModuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ function ImportAssetWindow::Close(%this)
|
||||||
if(ImportAssetWindow.isAwake())
|
if(ImportAssetWindow.isAwake())
|
||||||
ImportAssetWindow.refresh();
|
ImportAssetWindow.refresh();
|
||||||
|
|
||||||
//ImportAssetItems.empty();
|
ImportAssetWindow.importer.isReimport = false;
|
||||||
|
|
||||||
Canvas.popDialog();
|
Canvas.popDialog();
|
||||||
}
|
}
|
||||||
|
|
@ -336,8 +336,8 @@ function AssetBrowser::addImportingAsset( %this, %assetType, %filePath, %parentA
|
||||||
if(%filePath !$= "")
|
if(%filePath !$= "")
|
||||||
%filePath = filePath(%filePath) @ "/" @ fileBase(%filePath) @ fileExt(%filePath);
|
%filePath = filePath(%filePath) @ "/" @ fileBase(%filePath) @ fileExt(%filePath);
|
||||||
|
|
||||||
%moduleName = AssetBrowser.SelectedModule;
|
%moduleName = %this.SelectedModule;
|
||||||
ImportAssetModuleList.text = %moduleName;
|
AssetImportTargetModule.text = %moduleName;
|
||||||
|
|
||||||
%assetName = strreplace( %assetName, " ", "_" );
|
%assetName = strreplace( %assetName, " ", "_" );
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue