Esempio n. 1
0
        /// <summary>
        /// Create a spline job from this spline
        /// </summary>
        /// <param name="spline">spline to generate a job from</param>
        /// <param name="progress">progress to use when initializing job</param>
        /// <param name="allocator">allocator to use for result values</param>
        /// <returns>spline point retrieval job</returns>
        public static ISplineJob3D ExtractJob(this ISpline3D spline, SplineProgress progress = default, Allocator allocator = Allocator.None)
        {
            switch (spline.SplineDataType)
            {
            case SplineType.Empty:
                return(new Empty3DPointJob(spline, allocator));

            case SplineType.Single:
                return(new SinglePoint3DPointJob(spline, allocator));

            case SplineType.Bezier:
                return(new BezierSpline3DPointJob(spline, progress, allocator));

            case SplineType.CubicLinear:
                return(new LinearCubicSpline3DPointJob(spline, progress, allocator));

            case SplineType.Cubic:
            //todo
            case SplineType.BSpline:
            //todo
            case SplineType.CatmullRom:
            //todo
            case SplineType.Linear:     // falls over to the default by design
            default:
                return(new LinearSpline3DPointJob(spline, progress, allocator));
            }
        }
Esempio n. 2
0
        public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            NativeArray <SplineProgress> movers = chunk.GetNativeArray(MoverDef);
            NativeArray <TraversalSpeed> speed  = chunk.GetNativeArray(SpeedDef);

            for (int i = chunk.Count - 1; i >= 0; i--)
            {
                float progress = movers[i].Progress;
                progress += ((speed[i].Speed / SplineLength) * DeltaTime);
                progress %= 1f;
                movers[i] = new SplineProgress()
                {
                    Progress = progress
                };
            }
        }