From 26576208463fd3b0bebb9d36d57740042a6a98ae Mon Sep 17 00:00:00 2001 From: santorac <55155825+santorac@users.noreply.github.com> Date: Mon, 15 Nov 2021 23:56:10 -0800 Subject: [PATCH] Minor code cleanup. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com> --- .../RPI/Code/Include/Atom/RPI.Edit/Material/MaterialUtils.h | 3 +-- .../Atom/RPI/Code/Source/RPI.Edit/Material/MaterialUtils.cpp | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialUtils.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialUtils.h index f39b8e7aaa..c1183c7aa1 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialUtils.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Edit/Material/MaterialUtils.h @@ -32,8 +32,7 @@ namespace AZ { Empty, //! No image was actually requested, the path was empty Found, //! The requested asset was found - Missing, //! The requested asset was not found, and a placeholder asset was used instead - MissingNoFallback //! The requested asset was not found, and a placeholder asset was not found either + Missing //! The requested asset was not found, and a placeholder asset was used instead }; //! Finds an ImageAsset referenced by a material file (or a placeholder) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialUtils.cpp b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialUtils.cpp index fbc06e7294..2b51be736e 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialUtils.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Material/MaterialUtils.cpp @@ -43,6 +43,11 @@ namespace AZ if (!imageAssetId.IsSuccess()) { + // When the AssetId cannot be found, we don't want to outright fail, because the runtime has mechanisms for displaying fallback textures which gives the + // user a better recovery workflow. On the other hand we can't just provide an empty/invalid Asset because that would be interpreted as simply + // no value was present and result in using no texture, and this would amount to a silent failure. + // So we use a randomly generated (well except for the "BADA55E7" bit ;) UUID which the runtime and tools will interpret as a missing asset and represent + // it as such. static const Uuid InvalidAssetPlaceholderId = "{BADA55E7-1A1D-4940-B655-9D08679BD62F}"; imageAsset = Data::Asset{InvalidAssetPlaceholderId, azrtti_typeid(), imageFilePath}; return GetImageAssetResult::Missing;