3
0

AttachmentImageAsset.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/RPI.Reflect/Image/AttachmentImageAsset.h>
  9. namespace AZ
  10. {
  11. namespace RPI
  12. {
  13. const char* AttachmentImageAsset::DisplayName = "AttachmentImageAsset";
  14. const char* AttachmentImageAsset::Group = "Image";
  15. const char* AttachmentImageAsset::Extension = "attimage";
  16. void AttachmentImageAsset::Reflect(ReflectContext* context)
  17. {
  18. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  19. {
  20. serializeContext->Class<AttachmentImageAsset, ImageAsset>()
  21. ->Version(2)
  22. ->Field("Name", &AttachmentImageAsset::m_name)
  23. ->Field("IsUniqueName", &AttachmentImageAsset::m_isUniqueName)
  24. ->Field("OptimizedClearValue", &AttachmentImageAsset::m_optimizedClearValue)
  25. ;
  26. }
  27. }
  28. const Data::Asset<ResourcePoolAsset>& AttachmentImageAsset::GetPoolAsset() const
  29. {
  30. return m_poolAsset;
  31. }
  32. const RHI::ClearValue* AttachmentImageAsset::GetOptimizedClearValue() const
  33. {
  34. return m_optimizedClearValue.get();
  35. }
  36. const AZ::Name& AttachmentImageAsset::GetName() const
  37. {
  38. return m_name;
  39. }
  40. RHI::AttachmentId AttachmentImageAsset::GetAttachmentId() const
  41. {
  42. if (HasUniqueName())
  43. {
  44. return m_name;
  45. }
  46. return Name(m_assetId.ToString<AZStd::string>());
  47. }
  48. bool AttachmentImageAsset::HasUniqueName() const
  49. {
  50. // The name can still be empty if the asset was loaded for data file but not from AttachmentImageAssetCreator
  51. return m_isUniqueName && !m_name.IsEmpty();
  52. }
  53. }
  54. }