浏览代码

Added extra comments to the final version of CopyLocation constraint

/main
Olivier Dionne 5 年前
当前提交
9a81c341
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 12
      Assets/AnimationRiggingWorkshop/Constraints/CopyLocation.cs

12
Assets/AnimationRiggingWorkshop/Constraints/CopyLocation.cs


public ReadWriteTransformHandle constrained;
public ReadOnlyTransformHandle source;
// Use Vector3BoolProperty to read in the axis booleans from
// the AnimationStream
public Vector3BoolProperty invert;
public FloatProperty jobWeight { get; set; }

if (w > 0f)
{
var tmp = invert.Get(stream);
float3 mask = new float3(
float3 invertMask = new float3(
math.select(1f, -1f, tmp.x),
math.select(1f, -1f, tmp.y),
math.select(1f, -1f, tmp.z)

stream,
math.lerp(constrained.GetPosition(stream), source.GetPosition(stream) * mask, w)
math.lerp(constrained.GetPosition(stream), source.GetPosition(stream) * invertMask, w)
);
}
}

{
public Transform constrainedObject;
[SyncSceneToStream] public Transform sourceObject;
// Use SyncSceneToStream on Vector3Bool in order to add these
// properties to the AnimationStream and for them to be
// updated by the intial SyncSceneToStream job defined by the RigBuilder.
[SyncSceneToStream] public Vector3Bool invert;
public bool IsValid()

{
constrained = ReadWriteTransformHandle.Bind(animator, data.constrainedObject),
source = ReadOnlyTransformHandle.Bind(animator, data.sourceObject),
// Bind data.invert to job.invert so values can be resolved from the AnimationStream
invert = Vector3BoolProperty.Bind(animator, component, PropertyUtils.ConstructConstraintDataPropertyName(nameof(data.invert)))
};
}

正在加载...
取消
保存