mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-06-06 05:26:36 +00:00
Adds logic to correctly write out a shape's materials as fields to the asset taml file so they can register as dependencies with the assetdatabase
This commit is contained in:
parent
b44158cb89
commit
de26f519f9
2 changed files with 27 additions and 0 deletions
|
|
@ -626,6 +626,32 @@ void ShapeAsset::onTamlPostWrite(void)
|
|||
mNormalImposterFileName = expandAssetFilePath(mNormalImposterFileName);
|
||||
}
|
||||
|
||||
void ShapeAsset::onTamlCustomWrite(TamlCustomNodes& customNodes)
|
||||
{
|
||||
// Debug Profiling.
|
||||
PROFILE_SCOPE(ShapeAsset_OnTamlCustomWrite);
|
||||
|
||||
// Call parent.
|
||||
Parent::onTamlCustomWrite(customNodes);
|
||||
|
||||
if (!mShape)
|
||||
return;
|
||||
|
||||
TamlCustomNode* materialsData = customNodes.addNode(StringTable->insert("Materials"));
|
||||
U32 matCount = mShape->materialList->size();
|
||||
Vector<String>& mat_names = const_cast<Vector<String>&>(mShape->materialList->getMaterialNameList());
|
||||
for (U32 i=0; i < mat_names.size(); i++)
|
||||
{
|
||||
StringTableEntry matAssetId = MaterialAsset::getAssetIdByMaterialName(StringTable->insert(mat_names[i].c_str()));
|
||||
if (matAssetId != StringTable->EmptyString())
|
||||
{
|
||||
String fieldName = String::ToString("materialSlot%d", i);
|
||||
String fieldData = String::ToString("%s%s", ASSET_ID_FIELD_PREFIX, matAssetId);
|
||||
materialsData->addField(fieldName.c_str(), matAssetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TORQUE_TOOLS
|
||||
const char* ShapeAsset::generateCachedPreviewImage(S32 resolution, String overrideMaterial)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ protected:
|
|||
/// Taml callbacks.
|
||||
void onTamlPreWrite(void) override;
|
||||
void onTamlPostWrite(void) override;
|
||||
void onTamlCustomWrite(TamlCustomNodes& customNodes) override;
|
||||
|
||||
protected:
|
||||
static bool setShapeFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast<ShapeAsset*>(obj)->setShapeFile(data); return false; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue