4.7p3 Changing Closed Loop on a spline doesn't cause its length to change
If you have a spline that is not a closed loop, get its length, call set close loop to true, and get its length again, it still returns the original length. Vice versa if it started closed, its length never gets shorter if you later change it to open.
Create a new blueprint, say spline_test. Open it up and add two splines, first spline and second spline. Leave first spline as open loop and set second spline closed loop to true.
I made a debug function in this spline_test BP like this:
And a function to print out a spline, its current open/closed state, and its current length. Then flip the close loop flag on the spline for next time.
Finally a quick bit in the level map to debug this by pressing F key.
So now you can see when it starts up, s1 is an open spline and has length of 100. s2 is a close spline with a length of 200, twice as long as you would expect. Now hit F key. You see that s1 and s2 both alternate between open and closed loops as expected, however you will see that s1 always reports its length as 100 and s2 always as 200 no matter their open/closed states.
I have a fix for this which is currently in internal review and will be submitted soon. The problem is, as you suspected, that the Blueprint function to set the closed loop state wasn't updating the spline afterwards.
I'll report back here when there's a changelist you can integrate. Meanwhile, if you want a rough and ready fix, you can add the following line into USplineComponent::SetClosedLoop:
It's not especially optimal, but there'll be some spline component optimizations coming in the near future which should improve performance.
answered Jan 22 '15 at 03:13 PM
Richard Talbot-Watkins STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here