Case: 1410516
Hey, so this is kind of a big bug which I am surprised made it in, unless of course I am somehow missing something.
When EvaluatePosition(..)
is called on a NativeSpline
in a IJobFor
’s Execute(..)
method, a IndexOutOfRangeException: Index 29 is out of restricted IJobParallelFor range [0...0] in ReadWriteBuffer.
exception is thrown.
Simply add a script with the follow code to a GameObject along with a SplineContainer component (with at least two knots) and hit play.
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Splines;
public class SplineJobSample : MonoBehaviour
{
private void Start()
{
var spline = GetComponent<SplineContainer>().Spline;
var nativeSpline = new NativeSpline(spline, Allocator.TempJob);
var splineJob = new SplineTestJob()
{
NativeSpline = nativeSpline,
};
splineJob.Schedule(1, default).Complete();
nativeSpline.Dispose();
}
private struct SplineTestJob : IJobFor
{
public NativeSpline NativeSpline;
public void Execute(int index)
{
var result = NativeSpline.EvaluatePosition(0.5f);
Debug.Log("Result: " + result);
}
}
}