02-02-2016, 10:19 AM
Yeah, this is glitch that will be handled in the 2.0.5 update. AdaptOnChange does not handle deletion of CP's properly.
To help you understand what's going on:
The SplineController keeps a TF "pointer" internally. By adding/removing CPs the same TF would result in a different position and this causes the jumps you're noticing.
Note that even after 2.0.5 AdaptOnChange can't handle multiple actions in a single frame, so the easiest way is to handle it by yourself, because you know where you delete/add what. Two ways to handle this:
1.) Use SplineController.Spline.TFToSegment(SplineController.RelativePosition) to get the current segment and local position within. Then add/remove CP's at will (not the one you're over, but anything else is fine), then set the controller to the new TF (shortened): RelativePosition=seg.LocalFToTF(localF)
2.) Store the distance from start (SplineController.AbsolutePosition). Adding CP's in front of the current position is fine, if you remove CP's behind it, subtract the length of the deleted segment from the stored distance. After done, set SplineController.AbsoluteDistance to your stored value.
I'd prefer the former solution because of better accuracy.
To help you understand what's going on:
The SplineController keeps a TF "pointer" internally. By adding/removing CPs the same TF would result in a different position and this causes the jumps you're noticing.
Note that even after 2.0.5 AdaptOnChange can't handle multiple actions in a single frame, so the easiest way is to handle it by yourself, because you know where you delete/add what. Two ways to handle this:
1.) Use SplineController.Spline.TFToSegment(SplineController.RelativePosition) to get the current segment and local position within. Then add/remove CP's at will (not the one you're over, but anything else is fine), then set the controller to the new TF (shortened): RelativePosition=seg.LocalFToTF(localF)
2.) Store the distance from start (SplineController.AbsolutePosition). Adding CP's in front of the current position is fine, if you remove CP's behind it, subtract the length of the deleted segment from the stored distance. After done, set SplineController.AbsoluteDistance to your stored value.
I'd prefer the former solution because of better accuracy.