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

Method Boot

Source/PCGExtendedToolkit/Private/Paths/PCGExBevelPath.cpp:30–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30bool FPCGExBevelPathElement::Boot(FPCGExContext* InContext) const
31{
32 if (!FPCGExPathProcessorElement::Boot(InContext)) { return false; }
33
34 PCGEX_CONTEXT_AND_SETTINGS(BevelPath)
35
36 if (Settings->bFlagEndpoints) { PCGEX_VALIDATE_NAME(Settings->EndpointsFlagName) }
37 if (Settings->bFlagStartPoint) { PCGEX_VALIDATE_NAME(Settings->StartPointFlagName) }
38 if (Settings->bFlagEndPoint) { PCGEX_VALIDATE_NAME(Settings->EndPointFlagName) }
39 if (Settings->bFlagSubdivision) { PCGEX_VALIDATE_NAME(Settings->SubdivisionFlagName) }
40
41 if (Settings->Type == EPCGExBevelProfileType::Custom)
42 {
43 const TSharedPtr<PCGExData::FPointIO> CustomProfileIO = PCGExData::TryGetSingleInput(Context, PCGExBevelPath::SourceCustomProfile, false, true);
44 if (!CustomProfileIO) { return false; }
45
46 if (CustomProfileIO->GetNum() < 2)
47 {
48 PCGE_LOG(Error, GraphAndLog, FTEXT("Custom profile must have at least two points."));
49 return false;
50 }
51
52 Context->CustomProfileFacade = MakeShared<PCGExData::FFacade>(CustomProfileIO.ToSharedRef());
53
54 const TArray<FPCGPoint>& ProfilePoints = CustomProfileIO->GetIn()->GetPoints();
55 PCGEx::InitArray(Context->CustomProfilePositions, ProfilePoints.Num());
56
57 const FVector Start = ProfilePoints[0].Transform.GetLocation();
58 const FVector End = ProfilePoints.Last().Transform.GetLocation();
59 const double Factor = 1 / FVector::Dist(Start, End);
60
61 const FVector ProjectionNormal = (End - Start).GetSafeNormal(1E-08, FVector::ForwardVector);
62 const FQuat ProjectionQuat = FQuat::FindBetweenNormals(ProjectionNormal, FVector::ForwardVector);
63
64 for (int i = 0; i < ProfilePoints.Num(); i++)
65 {
66 Context->CustomProfilePositions[i] = ProjectionQuat.RotateVector((ProfilePoints[i].Transform.GetLocation() - Start) * Factor);
67 }
68 }
69
70 return true;
71}
72
73bool FPCGExBevelPathElement::ExecuteInternal(FPCGContext* InContext) const
74{

Callers

nothing calls this directly

Calls 4

TryGetSingleInputFunction · 0.85
InitArrayFunction · 0.85
GetNumMethod · 0.80
NumMethod · 0.80

Tested by

no test coverage detected