3
0

MaterialPropertiesLayout.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/Material/MaterialPropertiesLayout.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. namespace AZ
  11. {
  12. namespace RPI
  13. {
  14. void MaterialPropertiesLayout::Reflect(ReflectContext* context)
  15. {
  16. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  17. {
  18. serializeContext->Class<MaterialPropertiesLayout>()
  19. ->Version(1)
  20. ->Field("Indexes", &MaterialPropertiesLayout::m_materialPropertyIndexes)
  21. ->Field("Properties", &MaterialPropertiesLayout::m_materialPropertyDescriptors)
  22. ;
  23. }
  24. IdReflectionMapForMaterialProperties::Reflect(context);
  25. MaterialPropertyOutputId::Reflect(context);
  26. MaterialPropertyDescriptor::Reflect(context);
  27. }
  28. size_t MaterialPropertiesLayout::GetPropertyCount() const
  29. {
  30. return m_materialPropertyDescriptors.size();
  31. }
  32. MaterialPropertyIndex MaterialPropertiesLayout::FindPropertyIndex(const Name& propertyId) const
  33. {
  34. return m_materialPropertyIndexes.Find(propertyId);
  35. }
  36. const MaterialPropertyDescriptor* MaterialPropertiesLayout::GetPropertyDescriptor(MaterialPropertyIndex index) const
  37. {
  38. if (index.IsValid() && index.GetIndex() < m_materialPropertyDescriptors.size())
  39. {
  40. return &m_materialPropertyDescriptors[index.GetIndex()];
  41. }
  42. else
  43. {
  44. return nullptr;
  45. }
  46. }
  47. } // namespace RPI
  48. } // namespace AZ