AkSurfaceReflectorSetUtils.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 "AkSurfaceReflectorSetUtils.generated.h"
  18. namespace AkSurfaceReflectorUtils
  19. {
  20. static float EQUALITY_THRESHOLD = 0.001f;
  21. }
  22. /** An edge between two vertices */
  23. USTRUCT()
  24. struct FAkSurfaceEdgeVerts
  25. {
  26. GENERATED_BODY()
  27. static bool EdgesShareVertex(const FAkSurfaceEdgeVerts& Edge1, const FAkSurfaceEdgeVerts& Edge2);
  28. FAkSurfaceEdgeVerts() {}
  29. FAkSurfaceEdgeVerts(FVector InV0, FVector InV1) : V0(InV0), V1(InV1) {}
  30. FVector V0 = FVector::ZeroVector;
  31. FVector V1 = FVector::ZeroVector;
  32. FVector GetUnitVector() const { return (V1 - V0).GetSafeNormal(); }
  33. FAkSurfaceEdgeVerts GetTransformedEdge(const FTransform& Transform) const;
  34. void TransformEdge(const FTransform& Transform);
  35. void Invert();
  36. };
  37. /** Information about an edge */
  38. USTRUCT()
  39. struct FAkSurfaceEdgeInfo
  40. {
  41. GENERATED_BODY()
  42. FAkSurfaceEdgeVerts EdgeVerts;
  43. FVector Normal;
  44. bool IsEnabled = true;
  45. bool IsBoundary = true;
  46. bool IsFlat = false;
  47. const FVector V0() const { return EdgeVerts.V0; }
  48. const FVector V1() const { return EdgeVerts.V1; }
  49. void SetV0(FVector V0) { EdgeVerts.V0 = V0; }
  50. void SetV1(FVector V1) { EdgeVerts.V1 = V1; }
  51. int64 GetHash()
  52. {
  53. int64 H0 = GetTypeHash(V0());
  54. int64 H1 = GetTypeHash(V1());
  55. if (H1 > H0)
  56. {
  57. int64 temp = H0;
  58. H0 = H1;
  59. H1 = temp;
  60. }
  61. return H1 << 32 | H0;
  62. }
  63. FAkSurfaceEdgeInfo();
  64. FAkSurfaceEdgeInfo(FVector InV0, FVector InV1);
  65. };
  66. /** Contains the properties of a face from the ParentBrush of a UAkSurfaceReflectorSetComponent. */
  67. USTRUCT(BlueprintType)
  68. struct FAkSurfacePoly
  69. {
  70. GENERATED_BODY()
  71. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Audiokinetic|AkSurfaceReflectorSet")
  72. UAkAcousticTexture* Texture = nullptr;
  73. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Audiokinetic|AkSurfaceReflectorSet", DisplayName = "Transmission Loss", meta = (ClampMin = "0.0", ClampMax = "1.0"))
  74. float Occlusion = 1.f;
  75. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Audiokinetic|AkSurfaceReflectorSet")
  76. bool EnableSurface = true;
  77. void SetSurfaceArea(float area) { SurfaceArea = area; }
  78. float GetSurfaceArea() const { return SurfaceArea; }
  79. #if WITH_EDITOR
  80. FVector Normal;
  81. FVector MidPoint;
  82. /* The edges of the polygon */
  83. TArray<FAkSurfaceEdgeVerts> Edges;
  84. /* Keeps track of the optimal dot product between the chosen up vector and view camera up vector.
  85. This is used to minimize the flickering of text as it switches between edges each frame. */
  86. mutable float OptimalEdgeDP = 0.0f;
  87. void ClearEdgeInfo();
  88. FText GetPolyText(bool includeOcclusion) const;
  89. #endif
  90. private:
  91. UPROPERTY()
  92. float SurfaceArea = 0.0f;
  93. };