ImGuiLYAssetExplorer.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #include "ImGuiManager.h"
  10. #ifdef IMGUI_ENABLED
  11. #include "ImGuiBus.h"
  12. #include <AzCore/Asset/AssetCommon.h>
  13. #include <AzCore/Asset/AssetManagerBus.h>
  14. #include <AzCore/Component/TickBus.h>
  15. #include <AzCore/std/containers/map.h>
  16. namespace ImGui
  17. {
  18. struct MeshInstanceOptions
  19. {
  20. bool m_selectedForDraw; // Has this Instance been selected in the Selection Filter
  21. bool m_mousedOverForDraw; // Is this Instance Moused Over in ImGui for Draw In World
  22. bool m_verifiedThisFrame; // Is this Instance verified as being active still? ( Used when rescanning the Scene heirarchy for Meshes )
  23. bool m_passesFilter; // Does this Entity Name/ID pass the String Filter ( only figured when filter string changes, flag stored here )
  24. AZStd::string m_instanceLabel; // A String made at struct creation time with Entity Name and ID, for quick searching later.
  25. };
  26. struct MeshInstanceDisplayList
  27. {
  28. AZStd::string m_meshPath; // The Full Path String for this Mesh Asset
  29. AZStd::map<AZ::EntityId, MeshInstanceOptions> m_instanceOptionMap; // A Map of Entities that have been found with this mesh, to options for that instance
  30. bool m_selectedForDraw; // Has this Mesh been selected in the Selection Filter
  31. bool m_mousedOverForDraw; // Is this Instance Moused Over in ImGui for Draw In World
  32. bool m_childMousedOverForDraw; // Are one of this Mesh's children moused over for draw? ( Helps not disclude this Mesh when drawing later )
  33. bool m_passesFilter; // Does this Mesh Path Name pass the String Filter ( only figured when the filter string changes, flag stored here )
  34. bool m_childrenPassFilter; // Does even one of this entities Children Pass their Entity Name Filters ( used to hide when there are zero relevant children )
  35. };
  36. class ImGuiLYAssetExplorer
  37. : public ImGuiAssetExplorerRequestBus::Handler
  38. {
  39. public:
  40. ImGuiLYAssetExplorer();
  41. ~ImGuiLYAssetExplorer();
  42. // Called from owner
  43. void Initialize();
  44. void Shutdown();
  45. // Draw the ImGui Menu
  46. void ImGuiUpdate();
  47. // -- ImGuiAssetExplorerRequestBus::Handler Interface ----------------------
  48. void SetEnabled(bool enabled) override { m_enabled = enabled; m_meshDebugEnabled = enabled; }
  49. // -- ImGuiAssetExplorerRequestBus::Handler Interface ----------------------
  50. // Toggle the menu on and off
  51. void ToggleEnabled() { m_enabled = !m_enabled; }
  52. private:
  53. // flag for if the entire Menu enabled / visible
  54. bool m_enabled;
  55. // Mesh Debugger Enabled and Filter Options
  56. bool m_meshDebugEnabled;
  57. bool m_lodDebugEnabled;
  58. bool m_distanceFilter;
  59. bool m_selectionFilter;
  60. bool m_enabledMouseOvers;
  61. bool m_anyMousedOverForDraw;
  62. float m_distanceFilter_near;
  63. float m_distanceFilter_far;
  64. bool m_meshNameFilter;
  65. AZStd::string m_meshNameFilterStr;
  66. bool m_entityNameFilter;
  67. AZStd::string m_entityNameFilterStr;
  68. // In World Display Options
  69. bool m_inWorld_drawOriginSphere;
  70. float m_inWorld_originSphereRadius;
  71. bool m_inWorld_drawLabel;
  72. bool m_inWorld_label_monoSpace;
  73. bool m_inWorld_label_framed;
  74. ImColor m_inWorld_label_textColor;
  75. float m_inWorld_labelTextSize;
  76. bool m_inWorld_drawAABB;
  77. bool m_inWorld_debugDrawMesh;
  78. bool m_inWorld_label_entityName;
  79. bool m_inWorld_label_materialName;
  80. bool m_inWorld_label_totalLods;
  81. bool m_inWorld_label_miscLod;
  82. // Get a Mesh Display List from the Map and init it if it is new.
  83. MeshInstanceDisplayList& FindOrCreateMeshInstanceList(const char* meshName);
  84. // Iterate through our Map and check for Mesh and Entity Name filters
  85. void MeshInstanceList_CheckMeshFilter();
  86. void MeshInstanceList_CheckEntityFilter();
  87. // The Primary list of Meshes and Instances of them
  88. AZStd::list<MeshInstanceDisplayList> m_meshInstanceDisplayList;
  89. // Helper functions for the ImGui Update
  90. void ImGuiUpdate_DrawMenu();
  91. void ImGuiUpdate_DrawViewOptions();
  92. void ImGuiUpdate_DrawMeshMouseOver(MeshInstanceDisplayList& meshDisplayList);
  93. void ImGuiUpdate_DrawEntityInstanceMouseOver(MeshInstanceDisplayList& meshDisplayList, AZ::EntityId& entityInstance, AZStd::string& entityName, MeshInstanceOptions& instanceOptions);
  94. };
  95. }
  96. #endif // IMGUI_ENABLED