mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-26 18:13:47 +00:00
Expands/Cleans up a lot of the asset functionality, including management, file association, and creation/importing
This commit is contained in:
parent
a366f65047
commit
4422082035
73 changed files with 4468 additions and 1876 deletions
|
|
@ -92,10 +92,6 @@ ShapeAsset::ShapeAsset()
|
|||
|
||||
ShapeAsset::~ShapeAsset()
|
||||
{
|
||||
// If the asset manager does not own the asset then we own the
|
||||
// asset definition so delete it.
|
||||
if (!getOwned())
|
||||
delete mpAssetDefinition;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -105,7 +101,8 @@ void ShapeAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("fileName", TypeFilename, Offset(mFileName, ShapeAsset), "Path to the shape file we want to render");
|
||||
addProtectedField("fileName", TypeAssetLooseFilePath, Offset(mFileName, ShapeAsset),
|
||||
&setShapeFile, &getShapeFile, "Path to the shape file we want to render");
|
||||
}
|
||||
|
||||
void ShapeAsset::setDataField(StringTableEntry slotName, const char *array, const char *value)
|
||||
|
|
@ -127,7 +124,36 @@ void ShapeAsset::initializeAsset()
|
|||
// Call parent.
|
||||
Parent::initializeAsset();
|
||||
|
||||
if (dStrcmp(mFileName, "") == 0)
|
||||
if (mFileName == StringTable->EmptyString())
|
||||
return;
|
||||
|
||||
ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged);
|
||||
|
||||
loadShape();
|
||||
}
|
||||
|
||||
void ShapeAsset::setShapeFile(const char* pShapeFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pShapeFile != NULL, "Cannot use a NULL shape file.");
|
||||
|
||||
// Fetch image file.
|
||||
pShapeFile = StringTable->insert(pShapeFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pShapeFile == mFileName)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mFileName = getOwned() ? expandAssetFilePath(pShapeFile) : StringTable->insert(pShapeFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void ShapeAsset::_onResourceChanged(const Torque::Path &path)
|
||||
{
|
||||
if (path != Torque::Path(mFileName) )
|
||||
return;
|
||||
|
||||
loadShape();
|
||||
|
|
@ -152,12 +178,12 @@ bool ShapeAsset::loadShape()
|
|||
|
||||
if (assetType == StringTable->insert("MaterialAsset"))
|
||||
{
|
||||
mMaterialAssetIds.push_back(assetDependenciesItr->value);
|
||||
mMaterialAssetIds.push_front(assetDependenciesItr->value);
|
||||
|
||||
//Force the asset to become initialized if it hasn't been already
|
||||
AssetPtr<MaterialAsset> matAsset = assetDependenciesItr->value;
|
||||
|
||||
mMaterialAssets.push_back(matAsset);
|
||||
mMaterialAssets.push_front(matAsset);
|
||||
}
|
||||
else if (assetType == StringTable->insert("ShapeAnimationAsset"))
|
||||
{
|
||||
|
|
@ -227,6 +253,8 @@ bool ShapeAsset::loadShape()
|
|||
}
|
||||
}
|
||||
|
||||
onShapeChanged.trigger(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue