forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessAnimationJobStruct.cs
More file actions
61 lines (49 loc) · 1.93 KB
/
Copy pathProcessAnimationJobStruct.cs
File metadata and controls
61 lines (49 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs.LowLevel.Unsafe;
namespace UnityEngine.Animations
{
internal enum JobMethodIndex
{
ProcessRootMotionMethodIndex = 0,
ProcessAnimationMethodIndex,
MethodIndexCount
}
internal struct ProcessAnimationJobStruct<T>
where T : struct, IAnimationJob
{
private static IntPtr jobReflectionData;
public static IntPtr GetJobReflectionData()
{
if (jobReflectionData == IntPtr.Zero)
{
jobReflectionData = JobsUtility.CreateJobReflectionData(
typeof(T),
JobType.Single,
(ExecuteJobFunction)Execute);
}
return jobReflectionData;
}
public delegate void ExecuteJobFunction(ref T data, IntPtr animationStreamPtr, IntPtr unusedPtr, ref JobRanges ranges, int jobIndex);
public static unsafe void Execute(ref T data, IntPtr animationStreamPtr, IntPtr methodIndex, ref JobRanges ranges, int jobIndex)
{
AnimationStream animationStream;
UnsafeUtility.CopyPtrToStructure((void*)animationStreamPtr, out animationStream);
JobMethodIndex jobMethodIndex = (JobMethodIndex)methodIndex.ToInt32();
switch (jobMethodIndex)
{
case JobMethodIndex.ProcessRootMotionMethodIndex:
data.ProcessRootMotion(animationStream);
break;
case JobMethodIndex.ProcessAnimationMethodIndex:
data.ProcessAnimation(animationStream);
break;
default:
throw new NotImplementedException("Invalid Animation jobs method index.");
}
}
}
}