您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

53 行
1.6 KiB

using System;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Jobs;
namespace UniVRM10.FastSpringBones.System
{
public sealed class FastSpringBoneScheduler : IDisposable
{
private readonly FastSpringBoneBufferCombiner _bufferCombiner;
public FastSpringBoneScheduler(FastSpringBoneBufferCombiner bufferCombiner)
{
_bufferCombiner = bufferCombiner;
}
public JobHandle Schedule(float deltaTime)
{
var handle = default(JobHandle);
handle = _bufferCombiner.ReconstructIfDirty(handle);
if (!_bufferCombiner.HasBuffer)
{
return handle;
}
handle = new PullTransformJob
{
Transforms = _bufferCombiner.Transforms
}.Schedule(_bufferCombiner.TransformAccessArray, handle);
handle = new UpdateFastSpringBoneJob
{
Colliders = _bufferCombiner.Colliders,
Joints = _bufferCombiner.Joints,
Logics = _bufferCombiner.Logics,
Springs = _bufferCombiner.Springs,
Transforms = _bufferCombiner.Transforms,
DeltaTime = deltaTime,
}.Schedule(_bufferCombiner.Springs.Length, 1, handle);
handle = new PushTransformJob
{
Transforms = _bufferCombiner.Transforms
}.Schedule(_bufferCombiner.TransformAccessArray, handle);
return handle;
}
public void Dispose()
{
_bufferCombiner.Dispose();
}
}
}