| 1093 | { |
| 1094 | TRACE_CPUPROFILER_EVENT_SCOPE(UTurnInPlace::DetermineStepSize); |
| 1095 | |
| 1096 | // Cache the turn angle and step angle |
| 1097 | const float TurnAngle = Angle; |
| 1098 | const float StepAngle = FMath::Abs(TurnAngle) + Params.SelectOffset; |
| 1099 | |
| 1100 | // Determine if we are turning right or left |
| 1101 | bTurnRight = TurnAngle > 0.f; |
| 1102 | |
| 1103 | // No step sizes, return 0 |
| 1104 | if (Params.StepSizes.Num() == 0) |
| 1105 | { |
| 1106 | ensureMsgf(false, TEXT("No StepSizes found in TurnInPlaceParams")); |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | // Determine the step size based on the select mode |
| 1111 | int32 StepSize = 0; |
| 1112 | switch(Params.SelectMode) |
| 1113 | { |
| 1114 | case ETurnAnimSelectMode::Nearest: |
| 1115 | { |
| 1116 | // Find the animation nearest to the angle |
| 1117 | float Diff = 0.f; |
| 1118 | for (int32 i = 0; i < Params.StepSizes.Num(); i++) |
| 1119 | { |
| 1120 | const int32& TAngle = Params.StepSizes[i]; |
| 1121 | const float AngleDiff = FMath::Abs(StepAngle - (float)TAngle); |
| 1122 | if (i == 0 || AngleDiff < Diff) |
| 1123 | { |
| 1124 | Diff = AngleDiff; |
| 1125 | StepSize = i; |
| 1126 | } |
| 1127 | } |
| 1128 | } |
| 1129 | break; |
| 1130 | case ETurnAnimSelectMode::Greater: |
| 1131 | { |
| 1132 | // Find the highest animation that exceeds the angle |
| 1133 | for (int32 i = 0; i < Params.StepSizes.Num(); i++) |
| 1134 | { |
| 1135 | const int32& TAngle = Params.StepSizes[i]; |
| 1136 | if (FMath::FloorToInt(StepAngle) >= TAngle) |
| 1137 | { |
| 1138 | StepSize = i; |
| 1139 | } |
| 1140 | } |
| 1141 | } |
| 1142 | break; |
| 1143 | default: ; |
| 1144 | } |
| 1145 | |
| 1146 | return StepSize; |
| 1147 | } |
| 1148 | |
| 1149 | void UTurnInPlace::DebugRotation() const |
| 1150 | { |
| 1151 | #if UE_ENABLE_DEBUG_DRAWING |
| 1152 | if (!IsValid(GetOwner())) |
nothing calls this directly
no outgoing calls
no test coverage detected