MotionUpdateJob<TValue, TOptions, TAdapter>
Evaluate motions in a NativeArray in parallel. Provide output storage and reserve the completed-index list before scheduling.
public struct MotionUpdateJob<TValue, TOptions, TAdapter> : IJobParallelFor
where TValue : unmanaged
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter<TValue, TOptions>MotionUpdateJob.cs · L9Evaluate a float in a job
Add using MeatMotion;, using MeatMotion.Adapters;, using Unity.Collections; and using Unity.Jobs;. Reserve output and retirement capacity for one entry and complete the job before reading the result of 4.
using var motions = new NativeArray<MotionUpdateJob<float, NoOptions, FloatMotionAdapter>.Motion>(
1, Allocator.TempJob);
using var output = new NativeArray<float>(1, Allocator.TempJob);
using var retired = new NativeList<int>(1, Allocator.TempJob);
var entries = motions;
entries[0] = new MotionUpdateJob<float, NoOptions, FloatMotionAdapter>.Motion(0f, 8f, 1f);
var job = new MotionUpdateJob<float, NoOptions, FloatMotionAdapter>
{
Motions = motions, Output = output, CompletedIndexList = retired.AsParallelWriter(),
DeltaTime = 0.5, UnscaledDeltaTime = 0.5, RealDeltaTime = 0.5
};
job.Schedule(1, 1).Complete();
float value = output[0];
Members
Motions
NativeArray containing the motion entries to evaluate.
public NativeArray<Motion> Motions;DeltaTime
Scaled delta in seconds for entries using MotionTimeKind.Time.
public double DeltaTime;UnscaledDeltaTime
Unscaled delta in seconds for entries using MotionTimeKind.UnscaledTime.
public double UnscaledDeltaTime;RealDeltaTime
Real-time delta in seconds for entries using MotionTimeKind.Realtime.
public double RealDeltaTime;Output
Receive evaluated values at the same indices as the input motions.
public NativeArray<TValue> Output;CompletedIndexList
Receives retired indices. Reserve capacity for every potentially retired motion before scheduling.
public NativeList<int>.ParallelWriter CompletedIndexList;Execute
Evaluate one indexed entry using its selected clock and update its state and output.
public void Execute(int index)Parameters
indexintIndex of the entry to operate on.
MeatMotion