streamline shape asset

shape asset now has the same import "@" as image asset
cut out extra filename parameters that arent needed
refresh hopefully fixed
This commit is contained in:
marauder2k7 2025-06-20 15:58:20 +01:00
parent 542563feaf
commit fd7342668c
15 changed files with 185 additions and 465 deletions

View file

@ -3035,31 +3035,15 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str());
String shapeFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension();
String shapeFileName = "@" + assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension();
String constructorFileName = assetItem->filePath.getFileName() + "." TORQUE_SCRIPT_EXTENSION;
String assetPath = targetPath + "/" + shapeFileName;
String constructorPath = targetPath + "/" + constructorFileName;
constructorFileName = "@" + constructorFileName;
String tamlPath = targetPath + "/" + assetName + ".asset.taml";
String originalPath = assetItem->filePath.getFullPath().c_str();
String originalConstructorPath = assetItem->filePath.getPath() + "/" + constructorFileName;
char qualifiedFromFile[2048];
char qualifiedToFile[2048];
char qualifiedFromCSFile[2048];
char qualifiedToCSFile[2048];
#ifndef TORQUE_SECURE_VFS
Platform::makeFullPathName(originalPath.c_str(), qualifiedFromFile, sizeof(qualifiedFromFile));
Platform::makeFullPathName(assetPath.c_str(), qualifiedToFile, sizeof(qualifiedToFile));
Platform::makeFullPathName(originalConstructorPath.c_str(), qualifiedFromCSFile, sizeof(qualifiedFromCSFile));
Platform::makeFullPathName(constructorPath.c_str(), qualifiedToCSFile, sizeof(qualifiedToCSFile));
#else
dStrcpy(qualifiedFromFile, originalPath.c_str(), sizeof(qualifiedFromFile));
dStrcpy(qualifiedToFile, assetPath.c_str(), sizeof(qualifiedToFile));
dStrcpy(qualifiedFromCSFile, originalConstructorPath.c_str(), sizeof(qualifiedFromCSFile));
dStrcpy(qualifiedToCSFile, constructorPath.c_str(), sizeof(qualifiedToCSFile));
#endif
newAsset->setAssetName(assetName);
newAsset->setShapeFile(shapeFileName.c_str());
newAsset->setShapeConstructorFile(constructorFileName.c_str());
@ -3076,9 +3060,9 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
//If it's not a re-import, check that the file isn't being in-place imported. If it isn't, store off the original
//file path for reimporting support later
if (!isReimport && String::compare(qualifiedFromFile, qualifiedToFile) && Torque::FS::IsFile(qualifiedFromFile))
if (!isReimport && Torque::FS::IsFile(originalPath))
{
newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile);
newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, originalPath.c_str());
}
//iterate through and write out the material maps dependencies
@ -3118,8 +3102,8 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
if (Con::getBoolVariable("$TSLastDetail::dumpImposters", false))
{
String imposterPath = assetItem->assetName + "_imposter.png";
String normalsPath = assetItem->assetName + "_imposter_normals.png";
String imposterPath = "@" + assetItem->assetName + "_imposter.png";
String normalsPath = "@" + assetItem->assetName + "_imposter_normals.png";
newAsset->setDiffuseImposterFile(imposterPath.c_str());
newAsset->setNormalImposterFile(normalsPath.c_str());
@ -3138,67 +3122,37 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
bool makeNewConstructor = true;
if (!isReimport)
{
bool isInPlace = !String::compare(qualifiedFromFile, qualifiedToFile);
if (!isInPlace && !Torque::FS::CopyFile(qualifiedFromFile, qualifiedToFile, !isReimport))
//We're doing an in-place import, so double check we've already got a constructor file in the expected spot
if (Torque::FS::IsFile(constructorPath))
{
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromFile);
//Yup, found it, we're good to go
makeNewConstructor = false;
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", constructorPath.c_str());
activityLog.push_back(importLogBuffer);
return "";
}
if (!isInPlace)
{
if (Torque::FS::IsFile(qualifiedFromCSFile))
{
if (!Torque::FS::CopyFile(qualifiedFromCSFile, qualifiedToCSFile, !isReimport))
{
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromCSFile);
activityLog.push_back(importLogBuffer);
}
else
{
//We successfully copied the original constructor file, so no extra work required
makeNewConstructor = false;
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Successfully copied original TSShape Constructor file %s", qualifiedFromCSFile);
activityLog.push_back(importLogBuffer);
}
}
}
else
{
//We're doing an in-place import, so double check we've already got a constructor file in the expected spot
if (Torque::FS::IsFile(qualifiedFromCSFile))
//Didn't work, but it's possible it's using the old .cs extension when our extension variable is set to something else, so check that one as well just to be sure
Torque::Path constrFilePath = constructorPath;
constrFilePath.setExtension("cs");
if (Torque::FS::IsFile(constrFilePath.getFullPath().c_str()))
{
//Yup, found it, we're good to go
makeNewConstructor = false;
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", qualifiedFromCSFile);
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", constrFilePath.getFullPath().c_str());
activityLog.push_back(importLogBuffer);
}
else
{
//Didn't work, but it's possible it's using the old .cs extension when our extension variable is set to something else, so check that one as well just to be sure
Torque::Path constrFilePath = qualifiedFromCSFile;
constrFilePath.setExtension("cs");
if (Torque::FS::IsFile(constrFilePath.getFullPath().c_str()))
{
//Yup, found it, we're good to go
makeNewConstructor = false;
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Existing TSShape Constructor file %s found", constrFilePath.getFullPath().c_str());
activityLog.push_back(importLogBuffer);
}
}
}
}
if (makeNewConstructor)
{
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning creation of new TSShapeConstructor file: %s", qualifiedToCSFile);
dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning creation of new TSShapeConstructor file: %s", constructorPath.c_str());
activityLog.push_back(importLogBuffer);
//find/create shape constructor
TSShapeConstructor* constructor = TSShapeConstructor::findShapeConstructorByFilename(Torque::Path(qualifiedToFile).getFullPath());
TSShapeConstructor* constructor = TSShapeConstructor::findShapeConstructorByFilename(Torque::Path(constructorPath).getFullPath());
if (constructor == nullptr)
{
String fullAssetName = assetItem->moduleName + ":" + assetItem->assetName;
@ -3302,7 +3256,7 @@ Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem)
PersistenceManager* constructorPersist = new PersistenceManager();
constructorPersist->registerObject();
constructorPersist->setDirty(constructor, qualifiedToCSFile);
constructorPersist->setDirty(constructor, constructorPath);
if (!constructorPersist->saveDirtyObject(constructor))
{