Olivier Dionne
6 年前
当前提交
939f74ef
共有 4 个文件被更改,包括 106 次插入 和 21 次删除
-
37Assets/Scenes/CopyLocation.unity
-
2Packages/manifest.json
-
77Assets/Constraints/CopyLocationStep0.cs
-
11Assets/Constraints/CopyLocationStep0.cs.meta
|
|||
using UnityEngine; |
|||
using UnityEngine.Animations.Rigging; |
|||
using UnityEngine.Experimental.Animations; |
|||
using Unity.Burst; |
|||
using Unity.Mathematics; |
|||
|
|||
[BurstCompile] |
|||
public struct CopyLocationStep0Job : IWeightedAnimationJob |
|||
{ |
|||
public ReadWriteTransformHandle constrained; |
|||
public ReadOnlyTransformHandle source; |
|||
|
|||
// TODO : Add invert axis mask
|
|||
|
|||
public FloatProperty jobWeight { get; set; } |
|||
|
|||
public void ProcessRootMotion(AnimationStream stream) { } |
|||
|
|||
public void ProcessAnimation(AnimationStream stream) |
|||
{ |
|||
float w = jobWeight.Get(stream); |
|||
if (w > 0f) |
|||
{ |
|||
// TODO : Change code to consider inverted axis positions instead
|
|||
|
|||
constrained.SetPosition( |
|||
stream, |
|||
math.lerp(constrained.GetPosition(stream), -source.GetPosition(stream), w) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[System.Serializable] |
|||
public struct CopyLocationStep0Data : IAnimationJobData |
|||
{ |
|||
public Transform constrainedObject; |
|||
[SyncSceneToStream] public Transform sourceObject; |
|||
|
|||
// TODO : Add invert axis booleans
|
|||
|
|||
public bool IsValid() |
|||
{ |
|||
return !(constrainedObject == null || sourceObject == null); |
|||
} |
|||
|
|||
public void SetDefaultValues() |
|||
{ |
|||
constrainedObject = null; |
|||
sourceObject = null; |
|||
|
|||
// TODO : Set initial values to invert booleans
|
|||
} |
|||
} |
|||
|
|||
public class CopyLocationStep0Binder : AnimationJobBinder<CopyLocationStep0Job, CopyLocationStep0Data> |
|||
{ |
|||
public override CopyLocationStep0Job Create(Animator animator, ref CopyLocationStep0Data data, Component component) |
|||
{ |
|||
return new CopyLocationStep0Job() |
|||
{ |
|||
constrained = ReadWriteTransformHandle.Bind(animator, data.constrainedObject), |
|||
source = ReadOnlyTransformHandle.Bind(animator, data.sourceObject) |
|||
}; |
|||
} |
|||
|
|||
public override void Destroy(CopyLocationStep0Job job) { } |
|||
} |
|||
|
|||
[DisallowMultipleComponent, AddComponentMenu("SIGGRAPH 2019/Copy Location (Step 0)")] |
|||
public class CopyLocationStep0 : RigConstraint< |
|||
CopyLocationStep0Job, |
|||
CopyLocationStep0Data, |
|||
CopyLocationStep0Binder |
|||
> |
|||
{ |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 18bfd3261384fc9479894a4e72ffd52f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue