| 6 | namespace PCGExMath |
| 7 | { |
| 8 | FVector NRM( |
| 9 | const int32 A, const int32 B, const int32 C, |
| 10 | const TArray<FVector>& InPositions, |
| 11 | const PCGExData::TBuffer<FVector>* UpVectorCache, |
| 12 | const FVector& UpVector) |
| 13 | { |
| 14 | const FVector VA = *(InPositions.GetData() + A); |
| 15 | const FVector VB = *(InPositions.GetData() + B); |
| 16 | const FVector VC = *(InPositions.GetData() + C); |
| 17 | |
| 18 | FVector UpAverage = UpVector; |
| 19 | if (UpVectorCache) |
| 20 | { |
| 21 | UpAverage += UpVectorCache->Read(A); |
| 22 | UpAverage += UpVectorCache->Read(B); |
| 23 | UpAverage += UpVectorCache->Read(C); |
| 24 | UpAverage /= 3; |
| 25 | UpAverage = UpAverage.GetSafeNormal(); |
| 26 | } |
| 27 | |
| 28 | return FMath::Lerp(GetNormal(VA, VB, VB + UpAverage), GetNormal(VB, VC, VC + UpAverage), 0.5).GetSafeNormal(); |
| 29 | } |
| 30 | } |