I was trying to make the spline points scale from 0 to 1 along spline length ( I then use it for spline mesh ), but i encounter a bug.
GetSplinePoints
node didn’t output the last points, no matter the number of points, it does always forget the last point
Source\PCG\Private\Data\PCGSplineData.cpp :
TArray<FSplinePoint> UPCGSplineData::GetSplinePoints() const
{
const FInterpCurveVector& ControlPointsPosition = SplineStruct.GetSplinePointsPosition();
const FInterpCurveQuat& ControlPointsRotation = SplineStruct.GetSplinePointsRotation();
const FInterpCurveVector& ControlPointsScale = SplineStruct.GetSplinePointsScale();
TArray<FSplinePoint> ControlPoints;
ControlPoints.Reserve(ControlPointsPosition.Points.Num());
for (int i = 0; i < ControlPointsPosition.Points.Num() - 1; ++i) // <<<<<<<<
{
ControlPoints.Emplace(static_cast<float>(ControlPoints.Num()),
ControlPointsPosition.Points[i].OutVal,
ControlPointsPosition.Points[i].ArriveTangent,
ControlPointsPosition.Points[i].LeaveTangent,
ControlPointsRotation.Points[i].OutVal.Rotator(),
ControlPointsScale.Points[i].OutVal,
ConvertInterpCurveModeToSplinePointType(ControlPointsPosition.Points[i].InterpMode));
}
return ControlPoints;
}
forloop line 486 : Should this -1 be removed ?
Hey @ANT0_21!
I would try removing that -1 in the conditions of the forLoop. It needs to go until you run the # of times = to .Num of the array.
“i” will rise after each pass of the loop and if you start at 0 it can double as both the index of the array AND the # of times it has run.
Once “i” = ControlPointsPosition.Points.Num(), meaning it has run the loop an amount of times equal to the amount of points in your spline, it won’t run again and prevent giving you a Null Reference.
Hope that helps! You had it figured out but I’ll reinforce your thought so you can have the confidence to push changes
Edit: I saw your edit adding the line #, we can’t see the line #'s because it’s a snippet
Thx @Mind-Brain, i made a pull request
https://github.com/EpicGames/UnrealEngine/pull/13518