Moved the material slot list from ModelLodAsset to ModelAsset, so all the slots live in one main list. This removes data duplication between LODs and cleans up the code a bit.
I had to update the ModelLod class to take in both the ModelLodAsset and ModelAsset for initialization so it can fetch the slots for each mesh. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
This commit is contained in:
@@ -367,6 +367,9 @@ namespace AZ
|
||||
|
||||
MorphTargetMetaAssetCreator morphTargetMetaCreator;
|
||||
morphTargetMetaCreator.Begin(MorphTargetMetaAsset::ConstructAssetId(modelAssetId, modelAssetName));
|
||||
|
||||
ModelAssetCreator modelAssetCreator;
|
||||
modelAssetCreator.Begin(modelAssetId);
|
||||
|
||||
uint32_t lodIndex = 0;
|
||||
for (const SourceMeshContentList& sourceMeshContentList : sourceMeshContentListsByLod)
|
||||
@@ -429,7 +432,7 @@ namespace AZ
|
||||
|
||||
for (const ProductMeshView& meshView : lodMeshViews)
|
||||
{
|
||||
if (!CreateMesh(meshView, indexBuffer, streamBuffers, lodAssetCreator, context.m_materialsByUid))
|
||||
if (!CreateMesh(meshView, indexBuffer, streamBuffers, modelAssetCreator, lodAssetCreator, context.m_materialsByUid))
|
||||
{
|
||||
return AZ::SceneAPI::Events::ProcessingResult::Failure;
|
||||
}
|
||||
@@ -469,10 +472,6 @@ namespace AZ
|
||||
}
|
||||
sourceMeshContentListsByLod.clear();
|
||||
|
||||
// Build the final asset structure
|
||||
ModelAssetCreator modelAssetCreator;
|
||||
modelAssetCreator.Begin(modelAssetId);
|
||||
|
||||
// Finalize all LOD assets
|
||||
for (auto& lodAsset : lodAssets)
|
||||
{
|
||||
@@ -1796,6 +1795,7 @@ namespace AZ
|
||||
const ProductMeshView& meshView,
|
||||
const BufferAssetView& lodIndexBuffer,
|
||||
const AZStd::vector<ModelLodAsset::Mesh::StreamBufferInfo>& lodStreamBuffers,
|
||||
ModelAssetCreator& modelAssetCreator,
|
||||
ModelLodAssetCreator& lodAssetCreator,
|
||||
const MaterialAssetsByUid& materialAssetsByUid)
|
||||
{
|
||||
@@ -1811,7 +1811,8 @@ namespace AZ
|
||||
materialSlot.m_displayName = iter->second.m_name;
|
||||
materialSlot.m_defaultMaterialAsset = iter->second.m_asset;
|
||||
|
||||
lodAssetCreator.SetMeshMaterialSlot(materialSlot);
|
||||
modelAssetCreator.AddMaterialSlot(materialSlot);
|
||||
lodAssetCreator.SetMeshMaterialSlot(materialSlot.m_stableId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user