Additional preview renderer checks
Preventing multiple preview renderers from being created with multiple catalog loaded notifications Purging material preview images reaching a maximum number of stored images Purging material previews if entity gets destroyed Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
+24
-1
@@ -185,7 +185,7 @@ namespace AZ
|
||||
materialAssignmentId);
|
||||
|
||||
previewRenderer->AddCaptureRequest(
|
||||
{ 128,
|
||||
{ m_materialPreviewResolution,
|
||||
AZStd::make_shared<AZ::LyIntegration::SharedPreviewContent>(
|
||||
previewRenderer->GetScene(), previewRenderer->GetView(), previewRenderer->GetEntityContextId(),
|
||||
AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultModelPath), materialAssetId,
|
||||
@@ -220,11 +220,17 @@ namespace AZ
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::OnEntityDestroyed(const AZ::EntityId& entityId)
|
||||
{
|
||||
m_materialPreviews.erase(entityId);
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::OnRenderMaterialPreviewComplete(
|
||||
[[maybe_unused]] const AZ::EntityId& entityId,
|
||||
[[maybe_unused]] const AZ::Render::MaterialAssignmentId& materialAssignmentId,
|
||||
[[maybe_unused]] const QPixmap& pixmap)
|
||||
{
|
||||
PurgePreviews();
|
||||
m_materialPreviews[entityId][materialAssignmentId] = pixmap;
|
||||
}
|
||||
|
||||
@@ -281,5 +287,22 @@ namespace AZ
|
||||
}
|
||||
return AzToolsFramework::AssetBrowser::SourceFileDetails();
|
||||
}
|
||||
|
||||
void EditorMaterialSystemComponent::PurgePreviews()
|
||||
{
|
||||
size_t materialPreviewCount = 0;
|
||||
for (const auto& [entityId, previews] : m_materialPreviews)
|
||||
{
|
||||
for (const auto& [assignmentId, images] : previews)
|
||||
{
|
||||
materialPreviewCount += previews.size();
|
||||
}
|
||||
}
|
||||
|
||||
if (materialPreviewCount > m_materialPreviewLimit)
|
||||
{
|
||||
m_materialPreviews.clear();
|
||||
}
|
||||
}
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
Reference in New Issue
Block a user