Files
2026-03-04 09:37:33 +08:00

51 lines
1.2 KiB
C#

using KINEMATION.KAnimationCore.Runtime.Core;
using Unity.Collections;
using UnityEngine.Animations;
namespace KINEMATION.MagicBlend.Runtime
{
public struct PoseJob : IAnimationJob
{
[ReadOnly]
public bool alwaysAnimate;
[ReadOnly]
public bool readPose;
[ReadOnly]
public TransformSceneHandle root;
public NativeArray<BlendStreamAtom> atoms;
public void ProcessAnimation(AnimationStream stream)
{
if (alwaysAnimate || readPose)
{
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
{
position = value.handle.GetPosition(stream),
rotation = value.handle.GetRotation(stream)
};
worldTransform = kTransform.GetRelativeTransform(worldTransform, useScale: false);
value.activePose.basePose = worldTransform;
value.activePose.basePose.position = value.handle.GetLocalPosition(stream);
atoms[i] = value;
}
}
}
public void ProcessRootMotion(AnimationStream stream)
{
}
}
}