SAcousticSurfacesController.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. #pragma once
  16. #include "AkAcousticTexture.h"
  17. #include "WwiseUEFeatures.h"
  18. #include "AssetThumbnail.h"
  19. #include "Framework/Application/SlateApplication.h"
  20. #include "Widgets/SCompoundWidget.h"
  21. #include "Editor.h"
  22. #if WITH_EDITOR
  23. #define GEOMETRY_EDIT_DISPLAY_NAME "Brush Editing Mode"
  24. #endif
  25. class UAkSurfaceReflectorSetComponent;
  26. class IDetailLayoutBuilder;
  27. class IDetailCategoryBuilder;
  28. class UTransBuffer;
  29. class STextBlock;
  30. struct FAkSurfacePoly;
  31. class SAcousticSurfacesLabels : public SCompoundWidget
  32. {
  33. public:
  34. SLATE_BEGIN_ARGS(SAcousticSurfacesLabels) {}
  35. SLATE_END_ARGS()
  36. AUDIOKINETICTOOLS_API void Construct(const FArguments& InArgs, TArray<TWeakObjectPtr<UObject>> ObjectsBeingCustomized);
  37. private:
  38. TArray<TWeakObjectPtr<UObject>> ComponentsBeingCustomized;
  39. // Transmission Loss and Enable Surface Visibility
  40. EVisibility TransmissionLossEnableSurfaceVisibility();
  41. };
  42. class SAcousticSurfacesController : public SCompoundWidget
  43. {
  44. public:
  45. SLATE_BEGIN_ARGS(SAcousticSurfacesController) {}
  46. SLATE_END_ARGS()
  47. AUDIOKINETICTOOLS_API void Construct(const FArguments& InArgs
  48. ,TArray<TWeakObjectPtr<UObject>> ObjectsBeingCustomized
  49. ,const TSharedPtr<IDetailLayoutBuilder>& InLayoutBuilder
  50. );
  51. ~SAcousticSurfacesController();
  52. private:
  53. void BuildSlate();
  54. /** The details layout in the editor */
  55. TWeakPtr<IDetailLayoutBuilder> LayoutBuilder;
  56. /** The list of objects being customized. This is stored because we need to change which faces to use when notified that the editor mode is changing.
  57. (See OnEditorModeChanged, OnEditorModeExited).
  58. */
  59. TArray<TWeakObjectPtr<UObject>> ComponentsToEdit;
  60. /** Map of UAkSurfaceReflectorSetComponents to sets of selected face indices. */
  61. typedef TMap<UAkSurfaceReflectorSetComponent*, TSet<int>> ReflectorSetsSelectedFaces;
  62. ReflectorSetsSelectedFaces ReflectorSetsFacesToEdit;
  63. void InitReflectorSetsFacesToEdit();
  64. /** Helper function to get an acoustic surface, with assert for indexing. */
  65. FAkSurfacePoly& GetAcousticSurfaceChecked(UAkSurfaceReflectorSetComponent* reflectorSet, int faceIndex);
  66. /** Refresh the viewport and details panel in the editor. If reinitVisualizers = true, update the edge map and recreate the text visualizers on the selected USurfaceReflectorSetComponents */
  67. void RefreshEditor(bool reinitVisualizers = false) const;
  68. void RefreshLayout() const;
  69. void BeginModify(FText TransactionText);
  70. void EndModify();
  71. FDelegateHandle OnPropertyChangedHandle;
  72. void OnPropertyChanged(UObject* ObjectBeingModified, FPropertyChangedEvent& PropertyChangedEvent);
  73. int NumFacesSelected = 0;
  74. FText GetSelectionText() const;
  75. FText GetSelectionTextTooltip() const;
  76. /** Determines whether we should apply the changes to all faces in the AkSurfaceReflectorComponent or just those that are selected.
  77. Ideally we could just check if geometry mode is enabled during Construct, and refresh the details panel when the mode is changed.
  78. However, the notifications are sent before the active modes are updated in the GLevelEditorModeTools, so this wouldn't work. */
  79. bool ApplyToAllFaces = false;
  80. void OnEditorModeChanged(const FEditorModeID& InEditorModeID, bool bIsEnteringMode);
  81. /** Update the current collective texture, occlusion, and enablement for all considered faces on the component(s) */
  82. void UpdateCurrentValues();
  83. // Texture state and controls
  84. bool TexturesDiffer = false;
  85. UAkAcousticTexture* CurrentTexture = nullptr;
  86. EVisibility OverrideTextureControlsVisibility();
  87. FReply OnOverrideTextureButtonClicked();
  88. UAkAcousticTexture* GetCollectiveTexture(bool& ValuesDiffer);
  89. void OnTextureAssetChanged(const FAssetData& InAssetData);
  90. FString GetSelectedTextureAssetPath() const;
  91. // Transmission Loss and Enable Surface Visibility
  92. EVisibility TransmissionLossEnableSurfaceVisibility();
  93. // Occlusion state and controls
  94. bool OcclusionsDiffer = false;
  95. float CurrentOcclusion = 0.0f;
  96. EVisibility OverrideOcclusionControlsVisibility();
  97. FReply OnOverrideOcclusionButtonClicked();
  98. float GetCollectiveOcclusion(bool& ValuesDiffer);
  99. TOptional<float> GetOcclusionSliderValue() const;
  100. void OnOcclusionSliderChanged(float NewValue, ETextCommit::Type Commit);
  101. // Enable Surface state and controls
  102. bool EnablementsDiffer = false;
  103. bool CurrentEnablement = false;
  104. bool GetCollectiveEnableSurface(bool& ValuesDiffer);
  105. ECheckBoxState GetEnableSurfaceCheckBoxState() const;
  106. void OnEnableCheckboxChanged(ECheckBoxState NewState);
  107. #if AK_SUPPORT_WAAPI
  108. // Register a pre-delete WAAPI callback for the acoustic texture asset (if it is valid)
  109. void RegisterTextureDeletedCallback();
  110. // Remove the existing pre-delete WAAPI callback for the acoustic texture asset.
  111. void RemoveTextureDeletedCallback();
  112. uint64 TextureDeleteSubscriptionID;
  113. #endif
  114. };