52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using KINEMATION.KAnimationCore.Runtime.Core;
|
|
using Unity.Collections;
|
|
using UnityEngine.Animations;
|
|
|
|
namespace KINEMATION.MagicBlend.Runtime
|
|
{
|
|
public struct OverlayJob : IAnimationJob
|
|
{
|
|
[ReadOnly]
|
|
public bool alwaysAnimate;
|
|
|
|
[ReadOnly]
|
|
public bool cachePose;
|
|
|
|
[ReadOnly]
|
|
public TransformSceneHandle root;
|
|
|
|
public NativeArray<BlendStreamAtom> atoms;
|
|
|
|
public void ProcessAnimation(AnimationStream stream)
|
|
{
|
|
if (alwaysAnimate || cachePose)
|
|
{
|
|
KTransform kTransform = new KTransform
|
|
{
|
|
rotation = root.GetRotation(stream),
|
|
position = root.GetPosition(stream)
|
|
};
|
|
int length = atoms.Length;
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
BlendStreamAtom value = atoms[i];
|
|
KTransform worldTransform = new KTransform
|
|
{
|
|
rotation = value.handle.GetRotation(stream),
|
|
position = value.handle.GetPosition(stream)
|
|
};
|
|
worldTransform = kTransform.GetRelativeTransform(worldTransform, useScale: false);
|
|
value.activePose.overlayPose = worldTransform;
|
|
value.activePose.overlayPose.position = value.handle.GetLocalPosition(stream);
|
|
value.activePose.localOverlayRotation = value.handle.GetLocalRotation(stream);
|
|
atoms[i] = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ProcessRootMotion(AnimationStream stream)
|
|
{
|
|
}
|
|
}
|
|
}
|