EditorMaterialModelUvNameMapInspector.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <Atom/RPI.Edit/Material/MaterialSourceData.h>
  11. #include <Atom/RPI.Edit/Material/MaterialTypeSourceData.h>
  12. #include <Atom/RPI.Reflect/Material/MaterialAsset.h>
  13. #include <AtomLyIntegration/CommonFeatures/Material/MaterialAssignment.h>
  14. #include <AzCore/Asset/AssetCommon.h>
  15. #include <AzCore/std/containers/vector.h>
  16. #include <AzCore/std/string/string.h>
  17. #include <AzCore/std/containers/unordered_map.h>
  18. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h>
  19. #include <AtomToolsFramework/DynamicProperty/DynamicPropertyGroup.h>
  20. #include <AtomToolsFramework/Inspector/InspectorWidget.h>
  21. #endif
  22. namespace AZ
  23. {
  24. namespace Render
  25. {
  26. namespace EditorMaterialComponentInspector
  27. {
  28. using MaterialModelUvOverrideMapChangedCallBack = AZStd::function<void(const RPI::MaterialModelUvOverrideMap&)>;
  29. class MaterialModelUvNameMapInspector
  30. : public AtomToolsFramework::InspectorWidget
  31. , public AzToolsFramework::IPropertyEditorNotify
  32. {
  33. Q_OBJECT
  34. public:
  35. AZ_CLASS_ALLOCATOR(MaterialModelUvNameMapInspector, AZ::SystemAllocator);
  36. explicit MaterialModelUvNameMapInspector(
  37. const AZ::Data::AssetId& assetId,
  38. const RPI::MaterialModelUvOverrideMap& matModUvOverrides,
  39. const AZStd::unordered_set<AZ::Name>& modelUvNames,
  40. MaterialModelUvOverrideMapChangedCallBack matModUvOverrideMapChangedCallBack,
  41. QWidget* parent = nullptr
  42. );
  43. ~MaterialModelUvNameMapInspector() override;
  44. //! AtomToolsFramework::InspectorRequestBus::Handler overrides...
  45. void Reset() override;
  46. void Populate();
  47. void SetUvNameMap(const RPI::MaterialModelUvOverrideMap& matModUvPairs);
  48. private:
  49. //! AzToolsFramework::IPropertyEditorNotify overrides...
  50. void BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
  51. void AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
  52. void SetPropertyEditingActive([[maybe_unused]] AzToolsFramework::InstanceDataNode* pNode) override {}
  53. void SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode) override;
  54. void SealUndoStack() override {}
  55. void RequestPropertyContextMenu([[maybe_unused]] AzToolsFramework::InstanceDataNode*, const QPoint&) override {}
  56. void PropertySelectionChanged([[maybe_unused]] AzToolsFramework::InstanceDataNode*, bool) override {}
  57. void ResetModelUvNameIndices();
  58. void SetModelUvNames(const AZStd::unordered_set<AZ::Name>& modelUvNames);
  59. RPI::MaterialModelUvOverrideMap m_matModUvOverrides;
  60. AZStd::vector<uint32_t> m_modelUvNameIndices; //! Used to index enum values and translate to UV pairs.
  61. RPI::MaterialUvNameMap m_materialUvNames;
  62. AZStd::vector<AZStd::string> m_modelUvNames; //! Used as enum values.
  63. MaterialModelUvOverrideMapChangedCallBack m_matModUvOverrideMapChangedCallBack;
  64. AtomToolsFramework::DynamicPropertyGroup m_group;
  65. const AtomToolsFramework::DynamicProperty* m_activeProperty = nullptr;
  66. };
  67. bool OpenInspectorDialog(
  68. const AZ::Data::AssetId& assetId,
  69. const RPI::MaterialModelUvOverrideMap& matModUvOverrides,
  70. const AZStd::unordered_set<AZ::Name>& modelUvNames,
  71. MaterialModelUvOverrideMapChangedCallBack matModUvOverrideMapChangedCallBack);
  72. } // namespace EditorMaterialComponentInspector
  73. } // namespace Render
  74. } // namespace AZ