浏览代码

Update final copylocation constraint with new Vector3BoolProperty instead

/main
Olivier Dionne 6 年前
当前提交
61c7f75b
共有 1 个文件被更改,包括 10 次插入16 次删除
  1. 26
      Assets/AnimationRiggingWorkshop/Constraints/CopyLocation.cs

26
Assets/AnimationRiggingWorkshop/Constraints/CopyLocation.cs


public ReadWriteTransformHandle constrained;
public ReadOnlyTransformHandle source;
public BoolProperty xInvert;
public BoolProperty yInvert;
public BoolProperty zInvert;
public Vector3BoolProperty invert;
public FloatProperty jobWeight { get; set; }

float w = jobWeight.Get(stream);
if (w > 0f)
{
float3 invertMask = new float3(
math.select(1f, -1f, xInvert.Get(stream)),
math.select(1f, -1f, yInvert.Get(stream)),
math.select(1f, -1f, zInvert.Get(stream))
var tmp = invert.Get(stream);
float3 mask = new float3(
math.select(1f, -1f, tmp.x),
math.select(1f, -1f, tmp.y),
math.select(1f, -1f, tmp.z)
math.lerp(constrained.GetPosition(stream), source.GetPosition(stream) * invertMask, w)
math.lerp(constrained.GetPosition(stream), source.GetPosition(stream) * mask, w)
);
}
}

{
public Transform constrainedObject;
[SyncSceneToStream] public Transform sourceObject;
[SyncSceneToStream] public bool xInvert;
[SyncSceneToStream] public bool yInvert;
[SyncSceneToStream] public bool zInvert;
[SyncSceneToStream] public Vector3Bool invert;
public bool IsValid()
{

{
constrainedObject = null;
sourceObject = null;
xInvert = yInvert = zInvert = false;
invert = new Vector3Bool(false);
}
}

{
constrained = ReadWriteTransformHandle.Bind(animator, data.constrainedObject),
source = ReadOnlyTransformHandle.Bind(animator, data.sourceObject),
xInvert = BoolProperty.Bind(animator, component, PropertyUtils.ConstructConstraintDataPropertyName(nameof(data.xInvert))),
yInvert = BoolProperty.Bind(animator, component, PropertyUtils.ConstructConstraintDataPropertyName(nameof(data.yInvert))),
zInvert = BoolProperty.Bind(animator, component, PropertyUtils.ConstructConstraintDataPropertyName(nameof(data.zInvert)))
invert = Vector3BoolProperty.Bind(animator, component, PropertyUtils.ConstructConstraintDataPropertyName(nameof(data.invert)))
};
}

正在加载...
取消
保存