using Unity.Burst; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; ///////////////////////////////////////////////////////////////////////////////// namespace Rukhanka { [UpdateInGroup(typeof(RukhankaAnimationInjectionSystemGroup))] public partial struct FABRIKSystem: ISystem { struct FABRIKData { public NativeArray chainWorldPositions; public NativeArray chainInitialDirections; public NativeArray chainLengths; public NativeArray chainBoneIndices; } ///////////////////////////////////////////////////////////////////////////////// [BurstCompile] public void OnCreate(ref SystemState ss) { var q = SystemAPI.QueryBuilder() .WithAll() .Build(); ss.RequireForUpdate(q); } ///////////////////////////////////////////////////////////////////////////////// [BurstCompile] public void OnUpdate(ref SystemState ss) { var rigDefLookup = SystemAPI.GetComponentLookup(true); var localTransformLookup = SystemAPI.GetComponentLookup(true); var parentLookup = SystemAPI.GetComponentLookup(true); var animatorEntityRefLookup = SystemAPI.GetComponentLookup(true); ref var runtimeData = ref SystemAPI.GetSingletonRW().ValueRW; var ikJob = new FABRIKJob() { parentLookup = parentLookup, localTransformLookup = localTransformLookup, rigDefLookup = rigDefLookup, animatorEntityRefLookup = animatorEntityRefLookup, runtimeData = runtimeData }; ikJob.ScheduleParallel(); } } }