MovieSceneFloatChannelSerializationHelper.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 "AkInclude.h"
  17. #include "MovieSceneSection.h"
  18. #include "Channels/MovieSceneFloatChannel.h"
  19. #include "MovieSceneFloatChannelSerializationHelper.generated.h"
  20. USTRUCT()
  21. struct FMovieSceneTangentDataSerializationHelper
  22. {
  23. GENERATED_BODY()
  24. FMovieSceneTangentDataSerializationHelper() {}
  25. FMovieSceneTangentDataSerializationHelper(const FMovieSceneTangentData TangentData)
  26. : ArriveTangent(TangentData.ArriveTangent)
  27. , LeaveTangent(TangentData.LeaveTangent)
  28. , TangentWeightMode(TangentData.TangentWeightMode)
  29. , ArriveTangentWeight(TangentData.ArriveTangentWeight)
  30. , LeaveTangentWeight(TangentData.LeaveTangentWeight)
  31. {
  32. }
  33. UPROPERTY()
  34. float ArriveTangent = 0.f;
  35. UPROPERTY()
  36. float LeaveTangent = 0.f;
  37. UPROPERTY()
  38. TEnumAsByte<ERichCurveTangentWeightMode> TangentWeightMode = ERichCurveTangentWeightMode();
  39. UPROPERTY()
  40. float ArriveTangentWeight = 0.f;
  41. UPROPERTY()
  42. float LeaveTangentWeight = 0.f;
  43. };
  44. USTRUCT()
  45. struct FMovieSceneFloatValueSerializationHelper
  46. {
  47. GENERATED_BODY()
  48. FMovieSceneFloatValueSerializationHelper() {}
  49. FMovieSceneFloatValueSerializationHelper(FMovieSceneFloatValue FloatValue)
  50. : Value(FloatValue.Value)
  51. , InterpMode(FloatValue.InterpMode)
  52. , TangentMode(FloatValue.TangentMode)
  53. , Tangent(FloatValue.Tangent)
  54. {
  55. }
  56. FMovieSceneFloatValue ToFloatValue()
  57. {
  58. FMovieSceneFloatValue ValueToReturn(Value);
  59. ValueToReturn.InterpMode = InterpMode;
  60. ValueToReturn.TangentMode = TangentMode;
  61. ValueToReturn.Tangent.ArriveTangent = Tangent.ArriveTangent;
  62. ValueToReturn.Tangent.ArriveTangentWeight = Tangent.ArriveTangentWeight;
  63. ValueToReturn.Tangent.LeaveTangent = Tangent.LeaveTangent;
  64. ValueToReturn.Tangent.LeaveTangentWeight = Tangent.LeaveTangentWeight;
  65. ValueToReturn.Tangent.TangentWeightMode = Tangent.TangentWeightMode;
  66. return ValueToReturn;
  67. }
  68. UPROPERTY()
  69. float Value = 0.f;
  70. UPROPERTY()
  71. TEnumAsByte<ERichCurveInterpMode> InterpMode = ERichCurveInterpMode();
  72. UPROPERTY()
  73. TEnumAsByte<ERichCurveTangentMode> TangentMode = ERichCurveTangentMode();
  74. UPROPERTY()
  75. FMovieSceneTangentDataSerializationHelper Tangent;
  76. };
  77. USTRUCT()
  78. struct FMovieSceneFloatChannelSerializationHelper
  79. {
  80. GENERATED_BODY()
  81. FMovieSceneFloatChannelSerializationHelper() {}
  82. const FMovieSceneFloatChannelSerializationHelper& operator= (const FMovieSceneFloatChannel& FloatChannel)
  83. {
  84. Times.Reset();
  85. Values.Reset();
  86. PreInfinityExtrap = FloatChannel.PreInfinityExtrap;
  87. PostInfinityExtrap = FloatChannel.PostInfinityExtrap;
  88. auto FloatChannelTimes = FloatChannel.GetTimes();
  89. auto FloatChannelValues = FloatChannel.GetValues();
  90. for (int i = 0; i < FloatChannelTimes.Num(); i++)
  91. {
  92. Times.Add(FloatChannelTimes[i].Value);
  93. Values.Add(FMovieSceneFloatValueSerializationHelper(FloatChannelValues[i]));
  94. }
  95. bHasDefaultValue = FloatChannel.GetDefault().IsSet();
  96. if (bHasDefaultValue)
  97. {
  98. DefaultValue = FloatChannel.GetDefault().GetValue();
  99. }
  100. return *this;
  101. }
  102. void ToFloatChannel(FMovieSceneFloatChannel& FloatChannel)
  103. {
  104. FloatChannel.Reset();
  105. FloatChannel.PreInfinityExtrap = PreInfinityExtrap;
  106. FloatChannel.PostInfinityExtrap = PostInfinityExtrap;
  107. TArray<FFrameNumber> FloatChannelTimes;
  108. TArray<FMovieSceneFloatValue> FloatChannelValues;
  109. for (int i = 0; i < Times.Num(); i++)
  110. {
  111. FloatChannelTimes.Add(Times[i]);
  112. FloatChannelValues.Add(Values[i].ToFloatValue());
  113. }
  114. FloatChannel.Set(FloatChannelTimes, FloatChannelValues);
  115. if (bHasDefaultValue)
  116. {
  117. FloatChannel.SetDefault(DefaultValue);
  118. }
  119. }
  120. UPROPERTY()
  121. TEnumAsByte<ERichCurveExtrapolation> PreInfinityExtrap = ERichCurveExtrapolation();
  122. UPROPERTY()
  123. TEnumAsByte<ERichCurveExtrapolation> PostInfinityExtrap = ERichCurveExtrapolation();
  124. UPROPERTY()
  125. TArray<int32> Times;
  126. UPROPERTY()
  127. TArray<FMovieSceneFloatValueSerializationHelper> Values;
  128. UPROPERTY()
  129. float DefaultValue = 0.f;
  130. UPROPERTY()
  131. bool bHasDefaultValue = false;
  132. };