123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- #pragma once
- #include "Components/SceneComponent.h"
- #include "AkReverbDescriptor.h"
- #if WITH_EDITOR
- #include "Components/TextRenderComponent.h"
- #endif
- #include "AkLateReverbComponent.generated.h"
- class UAkRoomComponent;
- class UAkAcousticTextureSetComponent;
- UCLASS(ClassGroup = Audiokinetic, BlueprintType, hidecategories = (Transform, Rendering, Mobility, LOD, Component, Activation, Tags), meta = (BlueprintSpawnableComponent))
- class AKAUDIO_API UAkLateReverbComponent : public USceneComponent
- {
- GENERATED_BODY()
- public:
- UAkLateReverbComponent(const class FObjectInitializer& ObjectInitializer);
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EnableComponent", meta = (DisplayName = "Enable Late Reverb"))
- bool bEnable = false;
-
- UPROPERTY(EditAnywhere,BlueprintReadWrite, Category = "Late Reverb", meta = (ClampMin = 0.0f, ClampMax = 1.0f, UIMin = 0.0f, UIMax = 1.0f))
- float SendLevel = .0f;
-
- UPROPERTY(EditAnywhere,BlueprintReadWrite, Category = "Late Reverb" ,meta = (ClampMin = 0.0f, UIMin = 0.0f))
- float FadeRate = .0f;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Late Reverb")
- float Priority = .0f;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Late Reverb")
- bool AutoAssignAuxBus = true;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (EditCondition = "!AutoAssignAuxBus"), Category = "Late Reverb")
- class UAkAuxBus* AuxBus = nullptr;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, meta = (EditCondition = "!AutoAssignAuxBus"), Category = "Late Reverb")
- FString AuxBusName;
-
- uint32 GetAuxBusId() const;
- bool HasEffectOnLocation(const FVector& Location) const;
- bool LateReverbIsActive() const { return Parent.IsValid() && bEnable && !IsRunningCommandlet(); }
- virtual void BeginPlay() override;
- virtual void BeginDestroy() override;
- virtual void OnRegister() override;
- virtual void OnUnregister() override;
- virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
- virtual bool MoveComponentImpl(
- const FVector & Delta,
- const FQuat & NewRotation,
- bool bSweep,
- FHitResult * Hit,
- EMoveComponentFlags MoveFlags,
- ETeleportType Teleport) override;
- virtual void OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport) override;
- virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
- virtual void PostLoad() override;
- virtual void Serialize(FArchive& Ar) override;
- #if WITH_EDITOR
- virtual void PreEditChange(FProperty* PropertyAboutToChange) override;
- virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
- virtual void OnAttachmentChanged() override;
- void UpdateHFDampingEstimation(float hfDamping);
- void UpdatePredelayEstimation(float predelay);
- virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override;
- virtual void InitializeComponent() override;
- virtual void OnComponentCreated() override;
- void RegisterReverbInfoEnabledCallback();
- FDelegateHandle ShowReverbInfoChangedHandle;
- #endif
- void UpdateDecayEstimation(float decay, float volume, float surfaceArea);
- void UpdateRTPCs(const UAkRoomComponent* room) const;
-
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|LateReverb|ReverbParameterEstimation")
- void AssociateAkTextureSetComponent(UAkAcousticTextureSetComponent* textureSetComponent);
- UAkAcousticTextureSetComponent* GetAttachedTextureSetComponent();
-
- void TextureSetUpdated();
- private:
- friend class FAkAudioDevice;
- TWeakObjectPtr<class UPrimitiveComponent> Parent;
-
-
- UPROPERTY()
- class UAkAuxBus* AuxBusManual = nullptr;
-
- UAkAcousticTextureSetComponent* TextureSetComponent = nullptr;
-
- FAkReverbDescriptor ReverbDescriptor;
-
- float SecondsSinceDecayUpdate = 0.0f;
- bool DecayEstimationNeedsUpdate = false;
- float SecondsSincePredelayUpdate = 0.0f;
- bool PredelayEstimationNeedsUpdate = false;
- bool ReverbAssignmentNeedsUpdate = false;
-
- bool IsIndexed = false;
- bool TextureSetHasChanged = false;
- bool ReverbParamsChanged = false;
- void OnReverbParamsChanged();
- void RecalculateDecay();
- void RecalculatePredelay();
- void InitializeParent();
- void ParentChanged();
- bool EncompassesPoint(FVector Point, float SphereRadius = 0.f, float* OutDistanceToPoint = nullptr) const;
-
- FDelegateHandle TextureParamChangedHandle;
- #if WITH_EDITOR
- void HandleObjectsReplaced(const TMap<UObject*, UObject*>& ReplacementMap);
- #endif
- #if WITH_EDITORONLY_DATA
- static float TextVisualizerHeightOffset;
- bool bTextStatusNeedsUpdate = false;
-
- UPROPERTY(SkipSerialization, NonTransactional)
- UTextRenderComponent* TextVisualizerLabels = nullptr;
- UPROPERTY(SkipSerialization, NonTransactional)
- UTextRenderComponent* TextVisualizerValues = nullptr;
- void UpdateTextVisualizerStatus();
- bool TextVisualizersInitialized() const;
- FText GetValuesLabels() const;
- void DestroyTextVisualizers();
- void InitTextVisualizers();
- void UpdateValuesLabels();
- bool WasSelected = false;
- FVector GetTextVisualizersLocation();
-
- void RegisterReverbAssignmentChangedCallback();
- FDelegateHandle ReverbAssignmentChangedHandle;
-
- void RegisterGlobalDecayAbsorptionChangedCallback();
- FDelegateHandle GlobalDecayAbsorptionChangedHandle;
-
- void RegisterReverbRTPCChangedCallback();
- FDelegateHandle RTPCChangedHandle;
- UPROPERTY(VisibleAnywhere, Category = "Late Reverb|Reverb Parameter Estimation|Primitive Geometry")
- float EnvironmentVolume = 0.0f;
- UPROPERTY(VisibleAnywhere, Category = "Late Reverb|Reverb Parameter Estimation|Primitive Geometry")
- float SurfaceArea = 0.0f;
-
- UPROPERTY(VisibleAnywhere, Category = "Late Reverb|Reverb Parameter Estimation")
- float EnvironmentDecayEstimate = 0.0f;
-
- UPROPERTY(VisibleAnywhere, Category = "Late Reverb|Reverb Parameter Estimation")
- float HFDamping = 0.0f;
-
- UPROPERTY(VisibleAnywhere, Category = "Late Reverb|Reverb Parameter Estimation")
- float TimeToFirstReflection = 0.0f;
- #endif
- };
|