MCPcopy Create free account
hub / github.com/PCGEx/PCGExtendedToolkit / Mutate

Method Mutate

Source/PCGExtendedToolkit/Private/Graph/PCGExGraph.cpp:14–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "Graph/Data/PCGExClusterData.h"
13
14void FPCGExBasicEdgeSolidificationDetails::Mutate(FPCGPoint& InEdgePoint, const FPCGPoint& InStart, const FPCGPoint& InEnd, const double InLerp) const
15{
16 const FVector A = InStart.Transform.GetLocation();
17 const FVector B = InEnd.Transform.GetLocation();
18
19
20 InEdgePoint.Transform.SetLocation(FMath::Lerp(A, B, InLerp));
21 if (SolidificationAxis == EPCGExMinimalAxis::None) { return; }
22
23 const FVector EdgeDirection = (A - B).GetSafeNormal();
24
25 const double EdgeLength = FVector::Dist(A, B);
26 const double StartRadius = InStart.GetScaledExtents().Size();
27 const double EndRadius = InStart.GetScaledExtents().Size();
28
29 double Rad = 0;
30
31 switch (RadiusType)
32 {
33 case EPCGExBasicEdgeRadius::Average:
34 Rad = (StartRadius + EndRadius) * 0.5 * RadiusScale;
35 break;
36 case EPCGExBasicEdgeRadius::Lerp:
37 Rad = FMath::Lerp(StartRadius, EndRadius, InLerp) * RadiusScale;
38 break;
39 case EPCGExBasicEdgeRadius::Min:
40 Rad = FMath::Min(StartRadius, EndRadius) * RadiusScale;
41 break;
42 case EPCGExBasicEdgeRadius::Max:
43 Rad = FMath::Max(StartRadius, EndRadius) * RadiusScale;
44 break;
45 default:
46 case EPCGExBasicEdgeRadius::Fixed:
47 Rad = RadiusConstant;
48 break;
49 }
50
51 FRotator EdgeRot;
52 FVector BoundsMin = FVector(-Rad);
53 FVector BoundsMax = FVector(Rad);
54
55 const FVector PtScale = InEdgePoint.Transform.GetScale3D();
56 const FVector InvScale = FVector::One() / PtScale;
57
58 const double LerpInv = 1 - InLerp;
59 bool bProcessAxis;
60
61#define PCGEX_SOLIDIFY_DIMENSION(_AXIS)\
62 bProcessAxis = SolidificationAxis == EPCGExMinimalAxis::_AXIS;\
63 if (bProcessAxis){\
64 if (SolidificationAxis == EPCGExMinimalAxis::_AXIS){ BoundsMin._AXIS = (-EdgeLength * LerpInv) * InvScale._AXIS; BoundsMax._AXIS = (EdgeLength * InLerp) * InvScale._AXIS; } \
65 else{ BoundsMin._AXIS = (-Rad) * InvScale._AXIS; BoundsMax._AXIS = (Rad) * InvScale._AXIS; }}
66
67 PCGEX_FOREACH_XYZ(PCGEX_SOLIDIFY_DIMENSION)
68#undef PCGEX_SOLIDIFY_DIMENSION
69
70 switch (SolidificationAxis)
71 {

Callers 1

CompileRangeMethod · 0.45

Calls 3

MinFunction · 0.85
MaxFunction · 0.85
LerpFunction · 0.50

Tested by

no test coverage detected