first commit
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The Blend constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct BlendConstraintData : IAnimationJobData, IBlendConstraintData
|
||||
{
|
||||
[SerializeField] Transform m_ConstrainedObject;
|
||||
|
||||
[SyncSceneToStream, SerializeField] Transform m_SourceA;
|
||||
[SyncSceneToStream, SerializeField] Transform m_SourceB;
|
||||
[SyncSceneToStream, SerializeField] bool m_BlendPosition;
|
||||
[SyncSceneToStream, SerializeField] bool m_BlendRotation;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_PositionWeight;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_RotationWeight;
|
||||
|
||||
[NotKeyable, SerializeField] bool m_MaintainPositionOffsets;
|
||||
[NotKeyable, SerializeField] bool m_MaintainRotationOffsets;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform sourceObjectA { get => m_SourceA; set => m_SourceA = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform sourceObjectB { get => m_SourceB; set => m_SourceB = value; }
|
||||
/// <summary>Toggles whether position is blended in the constraint.</summary>
|
||||
public bool blendPosition { get => m_BlendPosition; set => m_BlendPosition = value; }
|
||||
/// <summary>Toggles whether rotation is blended in the constraint.</summary>
|
||||
public bool blendRotation { get => m_BlendRotation; set => m_BlendRotation = value; }
|
||||
/// <summary>
|
||||
/// Specifies the weight with which to blend position.
|
||||
/// A weight of zero will result in the position of sourceObjectA, while a weight of one will result in the position of sourceObjectB.
|
||||
/// </summary>
|
||||
public float positionWeight { get => m_PositionWeight; set => m_PositionWeight = Mathf.Clamp01(value); }
|
||||
/// <summary>
|
||||
/// Specifies the weight with which to blend rotation.
|
||||
/// A weight of zero will result in the rotation of sourceObjectA, while a weight of one will result in the rotation of sourceObjectB.
|
||||
/// </summary>
|
||||
public float rotationWeight { get => m_RotationWeight; set => m_RotationWeight = Mathf.Clamp01(value); }
|
||||
/// <inheritdoc />
|
||||
public bool maintainPositionOffsets { get => m_MaintainPositionOffsets; set => m_MaintainPositionOffsets = value; }
|
||||
/// <inheritdoc />
|
||||
public bool maintainRotationOffsets { get => m_MaintainRotationOffsets; set => m_MaintainRotationOffsets = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string IBlendConstraintData.blendPositionBoolProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_BlendPosition));
|
||||
/// <inheritdoc />
|
||||
string IBlendConstraintData.blendRotationBoolProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_BlendRotation));
|
||||
/// <inheritdoc />
|
||||
string IBlendConstraintData.positionWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_PositionWeight));
|
||||
/// <inheritdoc />
|
||||
string IBlendConstraintData.rotationWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_RotationWeight));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid() => !(m_ConstrainedObject == null || m_SourceA == null || m_SourceB == null);
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_ConstrainedObject = null;
|
||||
m_SourceA = null;
|
||||
m_SourceB = null;
|
||||
m_BlendPosition = true;
|
||||
m_BlendRotation = true;
|
||||
m_PositionWeight = 0.5f;
|
||||
m_RotationWeight = 0.5f;
|
||||
m_MaintainPositionOffsets = false;
|
||||
m_MaintainRotationOffsets = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Blend constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Blend Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/BlendConstraint.html")]
|
||||
public class BlendConstraint : RigConstraint<
|
||||
BlendConstraintJob,
|
||||
BlendConstraintData,
|
||||
BlendConstraintJobBinder<BlendConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
m_Data.positionWeight = Mathf.Clamp01(m_Data.positionWeight);
|
||||
m_Data.rotationWeight = Mathf.Clamp01(m_Data.rotationWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a2cc48f812a19f40a5c644fbc9b4d9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The ChainIK constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct ChainIKConstraintData : IAnimationJobData, IChainIKConstraintData
|
||||
{
|
||||
internal const int k_MinIterations = 1;
|
||||
internal const int k_MaxIterations = 50;
|
||||
internal const float k_MinTolerance = 0f;
|
||||
internal const float k_MaxTolerance = 0.01f;
|
||||
|
||||
[SerializeField] Transform m_Root;
|
||||
[SerializeField] Transform m_Tip;
|
||||
|
||||
[SyncSceneToStream, SerializeField] Transform m_Target;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_ChainRotationWeight;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_TipRotationWeight;
|
||||
|
||||
[NotKeyable, SerializeField, Range(k_MinIterations, k_MaxIterations)] int m_MaxIterations;
|
||||
[NotKeyable, SerializeField, Range(k_MinTolerance, k_MaxTolerance)] float m_Tolerance;
|
||||
[NotKeyable, SerializeField] bool m_MaintainTargetPositionOffset;
|
||||
[NotKeyable, SerializeField] bool m_MaintainTargetRotationOffset;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform root { get => m_Root; set => m_Root = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform tip { get => m_Tip; set => m_Tip = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform target { get => m_Target; set => m_Target = value; }
|
||||
/// <summary>The weight for which ChainIK target has an effect on chain (up to tip Transform). This is a value in between 0 and 1.</summary>
|
||||
public float chainRotationWeight { get => m_ChainRotationWeight; set => m_ChainRotationWeight = Mathf.Clamp01(value); }
|
||||
/// <summary>The weight for which ChainIK target has and effect on tip Transform. This is a value in between 0 and 1.</summary>
|
||||
public float tipRotationWeight { get => m_TipRotationWeight; set => m_TipRotationWeight = Mathf.Clamp01(value); }
|
||||
/// <inheritdoc />
|
||||
public int maxIterations { get => m_MaxIterations; set => m_MaxIterations = Mathf.Clamp(value, k_MinIterations, k_MaxIterations); }
|
||||
/// <inheritdoc />
|
||||
public float tolerance { get => m_Tolerance; set => m_Tolerance = Mathf.Clamp(value, k_MinTolerance, k_MaxTolerance); }
|
||||
/// <inheritdoc />
|
||||
public bool maintainTargetPositionOffset { get => m_MaintainTargetPositionOffset; set => m_MaintainTargetPositionOffset = value; }
|
||||
/// <inheritdoc />
|
||||
public bool maintainTargetRotationOffset { get => m_MaintainTargetRotationOffset; set => m_MaintainTargetRotationOffset = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string IChainIKConstraintData.chainRotationWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_ChainRotationWeight));
|
||||
/// <inheritdoc />
|
||||
string IChainIKConstraintData.tipRotationWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_TipRotationWeight));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid()
|
||||
{
|
||||
if (m_Root == null || m_Tip == null || m_Target == null)
|
||||
return false;
|
||||
|
||||
int count = 1;
|
||||
Transform tmp = m_Tip;
|
||||
while (tmp != null && tmp != m_Root)
|
||||
{
|
||||
tmp = tmp.parent;
|
||||
++count;
|
||||
}
|
||||
|
||||
return (tmp == m_Root && count > 2);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_Root = null;
|
||||
m_Tip = null;
|
||||
m_Target = null;
|
||||
m_ChainRotationWeight = 1f;
|
||||
m_TipRotationWeight = 1f;
|
||||
m_MaxIterations = 15;
|
||||
m_Tolerance = 0.0001f;
|
||||
m_MaintainTargetPositionOffset = false;
|
||||
m_MaintainTargetRotationOffset = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ChainIK constraint
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Chain IK Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/ChainIKConstraint.html")]
|
||||
public class ChainIKConstraint : RigConstraint<
|
||||
ChainIKConstraintJob,
|
||||
ChainIKConstraintData,
|
||||
ChainIKConstraintJobBinder<ChainIKConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
m_Data.chainRotationWeight = Mathf.Clamp01(m_Data.chainRotationWeight);
|
||||
m_Data.tipRotationWeight = Mathf.Clamp01(m_Data.tipRotationWeight);
|
||||
m_Data.maxIterations = Mathf.Clamp(
|
||||
m_Data.maxIterations, ChainIKConstraintData.k_MinIterations, ChainIKConstraintData.k_MaxIterations
|
||||
);
|
||||
m_Data.tolerance = Mathf.Clamp(
|
||||
m_Data.tolerance, ChainIKConstraintData.k_MinTolerance, ChainIKConstraintData.k_MaxTolerance
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 796b75e345bd64d47a31edd757bd2670
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The DampedTransform constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct DampedTransformData : IAnimationJobData, IDampedTransformData
|
||||
{
|
||||
[SerializeField] Transform m_ConstrainedObject;
|
||||
|
||||
[SyncSceneToStream, SerializeField] Transform m_Source;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_DampPosition;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_DampRotation;
|
||||
|
||||
[NotKeyable, SerializeField] bool m_MaintainAim;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform sourceObject { get => m_Source; set => m_Source = value; }
|
||||
/// <summary>
|
||||
/// Damp position weight. Defines how much of constrained object position follows source object position.
|
||||
/// Constrained position will closely follow source object when set to 0, and will
|
||||
/// not move when set to 1.
|
||||
/// </summary>
|
||||
public float dampPosition { get => m_DampPosition; set => m_DampPosition = Mathf.Clamp01(value); }
|
||||
/// <summary>
|
||||
/// Damp rotation weight. Defines how much of constrained object rotation follows source object rotation.
|
||||
/// Constrained rotation will closely follow source object when set to 0, and will
|
||||
/// not move when set to 1.
|
||||
/// </summary>
|
||||
public float dampRotation { get => m_DampRotation; set => m_DampRotation = Mathf.Clamp01(value); }
|
||||
/// <inheritdoc />
|
||||
public bool maintainAim { get => m_MaintainAim; set => m_MaintainAim = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string IDampedTransformData.dampPositionFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_DampPosition));
|
||||
/// <inheritdoc />
|
||||
string IDampedTransformData.dampRotationFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_DampRotation));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid() => !(m_ConstrainedObject == null || m_Source == null);
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_ConstrainedObject = null;
|
||||
m_Source = null;
|
||||
m_DampPosition = 0.5f;
|
||||
m_DampRotation = 0.5f;
|
||||
m_MaintainAim = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DampedTransform constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Damped Transform")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/DampedTransform.html")]
|
||||
public class DampedTransform : RigConstraint<
|
||||
DampedTransformJob,
|
||||
DampedTransformData,
|
||||
DampedTransformJobBinder<DampedTransformData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
m_Data.dampPosition = Mathf.Clamp01(m_Data.dampPosition);
|
||||
m_Data.dampRotation = Mathf.Clamp01(m_Data.dampRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b37cffab30b939469bac076fdd82c59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,214 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The MultiAim constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct MultiAimConstraintData : IAnimationJobData, IMultiAimConstraintData
|
||||
{
|
||||
/// <summary>
|
||||
/// Axis type for MultiAimConstraint.
|
||||
/// </summary>
|
||||
public enum Axis
|
||||
{
|
||||
/// <summary>Positive X Axis (1, 0, 0)</summary>
|
||||
X,
|
||||
/// <summary>Negative X Axis (-1, 0, 0)</summary>
|
||||
X_NEG,
|
||||
/// <summary>Positive Y Axis (0, 1, 0)</summary>
|
||||
Y,
|
||||
/// <summary>Negative Y Axis (0, -1, 0)</summary>
|
||||
Y_NEG,
|
||||
/// <summary>Positive Z Axis (0, 0, 1)</summary>
|
||||
Z,
|
||||
/// <summary>Negative Z Axis (0, 0, -1)</summary>
|
||||
Z_NEG
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies how the world up vector used by the Multi-Aim constraint is defined.
|
||||
/// </summary>
|
||||
public enum WorldUpType
|
||||
{
|
||||
/// <summary>Neither defines nor uses a world up vector.</summary>
|
||||
None,
|
||||
/// <summary>Uses and defines the world up vector as the Unity Scene up vector (the Y axis).</summary>
|
||||
SceneUp,
|
||||
/// <summary>Uses and defines the world up vector as a vector from the constrained object, in the direction of the up object.</summary>
|
||||
ObjectUp,
|
||||
/// <summary>Uses and defines the world up vector as relative to the local space of the object.</summary>
|
||||
ObjectRotationUp,
|
||||
/// <summary>Uses and defines the world up vector as a vector specified by the user.</summary>
|
||||
Vector
|
||||
};
|
||||
|
||||
internal const float k_MinAngularLimit = -180f;
|
||||
internal const float k_MaxAngularLimit = 180f;
|
||||
|
||||
[SerializeField] Transform m_ConstrainedObject;
|
||||
|
||||
[SyncSceneToStream, SerializeField, WeightRange(0f, 1f)] WeightedTransformArray m_SourceObjects;
|
||||
[SyncSceneToStream, SerializeField] Vector3 m_Offset;
|
||||
[SyncSceneToStream, SerializeField, Range(k_MinAngularLimit, k_MaxAngularLimit)] float m_MinLimit;
|
||||
[SyncSceneToStream, SerializeField, Range(k_MinAngularLimit, k_MaxAngularLimit)] float m_MaxLimit;
|
||||
|
||||
[NotKeyable, SerializeField] Axis m_AimAxis;
|
||||
[NotKeyable, SerializeField] Axis m_UpAxis;
|
||||
|
||||
[NotKeyable, SerializeField] WorldUpType m_WorldUpType;
|
||||
[SyncSceneToStream, SerializeField] Transform m_WorldUpObject;
|
||||
[NotKeyable, SerializeField] Axis m_WorldUpAxis;
|
||||
|
||||
[NotKeyable, SerializeField] bool m_MaintainOffset;
|
||||
[NotKeyable, SerializeField] Vector3Bool m_ConstrainedAxes;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public WeightedTransformArray sourceObjects
|
||||
{
|
||||
get => m_SourceObjects;
|
||||
set => m_SourceObjects = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool maintainOffset { get => m_MaintainOffset; set => m_MaintainOffset = value; }
|
||||
/// <summary>
|
||||
/// Post-Rotation offset applied to the constrained Transform.
|
||||
/// </summary>
|
||||
public Vector3 offset { get => m_Offset; set => m_Offset = value; }
|
||||
|
||||
/// <summary>
|
||||
/// Minimum and maximum value of the rotation permitted for the constraint. The values are in degrees.
|
||||
/// </summary>
|
||||
public Vector2 limits
|
||||
{
|
||||
get => new Vector2(m_MinLimit, m_MaxLimit);
|
||||
|
||||
set
|
||||
{
|
||||
m_MinLimit = Mathf.Clamp(value.x, k_MinAngularLimit, k_MaxAngularLimit);
|
||||
m_MaxLimit = Mathf.Clamp(value.y, k_MinAngularLimit, k_MaxAngularLimit);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IMultiAimConstraintData.aimAxis"/>
|
||||
public Axis aimAxis { get => m_AimAxis; set => m_AimAxis = value; }
|
||||
/// <inheritdoc cref="IMultiAimConstraintData.upAxis"/>
|
||||
public Axis upAxis { get => m_UpAxis; set => m_UpAxis = value; }
|
||||
|
||||
|
||||
/// <inheritdoc cref="IMultiAimConstraintData.worldUpType"/>
|
||||
public WorldUpType worldUpType { get => m_WorldUpType; set => m_WorldUpType = value; }
|
||||
/// <inheritdoc cref="IMultiAimConstraintData.aimAxis"/>
|
||||
public Axis worldUpAxis { get => m_WorldUpAxis; set => m_WorldUpAxis = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform worldUpObject { get => m_WorldUpObject; set => m_WorldUpObject = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool constrainedXAxis { get => m_ConstrainedAxes.x; set => m_ConstrainedAxes.x = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedYAxis { get => m_ConstrainedAxes.y; set => m_ConstrainedAxes.y = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedZAxis { get => m_ConstrainedAxes.z; set => m_ConstrainedAxes.z = value; }
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
Vector3 IMultiAimConstraintData.aimAxis => Convert(m_AimAxis);
|
||||
/// <inheritdoc />
|
||||
Vector3 IMultiAimConstraintData.upAxis => Convert(m_UpAxis);
|
||||
/// <inheritdoc />
|
||||
int IMultiAimConstraintData.worldUpType => (int) m_WorldUpType;
|
||||
/// <inheritdoc />
|
||||
Vector3 IMultiAimConstraintData.worldUpAxis => Convert(m_WorldUpAxis);
|
||||
/// <inheritdoc />
|
||||
string IMultiAimConstraintData.offsetVector3Property => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_Offset));
|
||||
/// <inheritdoc />
|
||||
string IMultiAimConstraintData.minLimitFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_MinLimit));
|
||||
/// <inheritdoc />
|
||||
string IMultiAimConstraintData.maxLimitFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_MaxLimit));
|
||||
/// <inheritdoc />
|
||||
string IMultiAimConstraintData.sourceObjectsProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_SourceObjects));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid()
|
||||
{
|
||||
if (m_ConstrainedObject == null || m_SourceObjects.Count == 0)
|
||||
return false;
|
||||
|
||||
foreach (var src in m_SourceObjects)
|
||||
if (src.transform == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_ConstrainedObject = null;
|
||||
m_UpAxis = Axis.Y;
|
||||
m_AimAxis = Axis.Z;
|
||||
m_WorldUpType = WorldUpType.None;
|
||||
m_WorldUpAxis = Axis.Y;
|
||||
m_WorldUpObject = null;
|
||||
m_SourceObjects.Clear();
|
||||
m_MaintainOffset = false;
|
||||
m_Offset = Vector3.zero;
|
||||
m_ConstrainedAxes = new Vector3Bool(true);
|
||||
m_MinLimit = -180f;
|
||||
m_MaxLimit = 180f;
|
||||
}
|
||||
|
||||
static Vector3 Convert(Axis axis)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
case Axis.X:
|
||||
return Vector3.right;
|
||||
case Axis.X_NEG:
|
||||
return Vector3.left;
|
||||
case Axis.Y:
|
||||
return Vector3.up;
|
||||
case Axis.Y_NEG:
|
||||
return Vector3.down;
|
||||
case Axis.Z:
|
||||
return Vector3.forward;
|
||||
case Axis.Z_NEG:
|
||||
return Vector3.back;
|
||||
default:
|
||||
return Vector3.up;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MultiAim constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Multi-Aim Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/MultiAimConstraint.html")]
|
||||
public class MultiAimConstraint : RigConstraint<
|
||||
MultiAimConstraintJob,
|
||||
MultiAimConstraintData,
|
||||
MultiAimConstraintJobBinder<MultiAimConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
var weights = m_Data.sourceObjects;
|
||||
WeightedTransformArray.OnValidate(ref weights);
|
||||
m_Data.sourceObjects = weights;
|
||||
var limits = m_Data.limits;
|
||||
limits.x = Mathf.Clamp(
|
||||
limits.x, MultiAimConstraintData.k_MinAngularLimit, MultiAimConstraintData.k_MaxAngularLimit
|
||||
);
|
||||
limits.y = Mathf.Clamp(
|
||||
limits.y, MultiAimConstraintData.k_MinAngularLimit, MultiAimConstraintData.k_MaxAngularLimit
|
||||
);
|
||||
m_Data.limits = limits;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3c430f382484144e925c097c2d33cfe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,94 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The MultiParent constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct MultiParentConstraintData : IAnimationJobData, IMultiParentConstraintData
|
||||
{
|
||||
[SerializeField] Transform m_ConstrainedObject;
|
||||
|
||||
[SerializeField, SyncSceneToStream, WeightRange(0f, 1f)] WeightedTransformArray m_SourceObjects;
|
||||
|
||||
[NotKeyable, SerializeField] Vector3Bool m_ConstrainedPositionAxes;
|
||||
[NotKeyable, SerializeField] Vector3Bool m_ConstrainedRotationAxes;
|
||||
[NotKeyable, SerializeField] bool m_MaintainPositionOffset;
|
||||
[NotKeyable, SerializeField] bool m_MaintainRotationOffset;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public WeightedTransformArray sourceObjects
|
||||
{
|
||||
get => m_SourceObjects;
|
||||
set => m_SourceObjects = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool maintainPositionOffset { get => m_MaintainPositionOffset; set => m_MaintainPositionOffset = value; }
|
||||
/// <inheritdoc />
|
||||
public bool maintainRotationOffset { get => m_MaintainRotationOffset; set => m_MaintainRotationOffset = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool constrainedPositionXAxis { get => m_ConstrainedPositionAxes.x; set => m_ConstrainedPositionAxes.x = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedPositionYAxis { get => m_ConstrainedPositionAxes.y; set => m_ConstrainedPositionAxes.y = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedPositionZAxis { get => m_ConstrainedPositionAxes.z; set => m_ConstrainedPositionAxes.z = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedRotationXAxis { get => m_ConstrainedRotationAxes.x; set => m_ConstrainedRotationAxes.x = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedRotationYAxis { get => m_ConstrainedRotationAxes.y; set => m_ConstrainedRotationAxes.y = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedRotationZAxis { get => m_ConstrainedRotationAxes.z; set => m_ConstrainedRotationAxes.z = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string IMultiParentConstraintData.sourceObjectsProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_SourceObjects));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid()
|
||||
{
|
||||
if (m_ConstrainedObject == null || m_SourceObjects.Count == 0)
|
||||
return false;
|
||||
|
||||
foreach (var src in m_SourceObjects)
|
||||
if (src.transform == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_ConstrainedObject = null;
|
||||
m_ConstrainedPositionAxes = new Vector3Bool(true);
|
||||
m_ConstrainedRotationAxes = new Vector3Bool(true);
|
||||
m_SourceObjects.Clear();
|
||||
m_MaintainPositionOffset = false;
|
||||
m_MaintainRotationOffset = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MultiParent constraint
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Multi-Parent Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/MultiParentConstraint.html")]
|
||||
public class MultiParentConstraint : RigConstraint<
|
||||
MultiParentConstraintJob,
|
||||
MultiParentConstraintData,
|
||||
MultiParentConstraintJobBinder<MultiParentConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
var weights = m_Data.sourceObjects;
|
||||
WeightedTransformArray.OnValidate(ref weights);
|
||||
m_Data.sourceObjects = weights;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8935e03361a14ec4b8edc872f76bc822
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The MultiPosition constraint job.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct MultiPositionConstraintData : IAnimationJobData, IMultiPositionConstraintData
|
||||
{
|
||||
[SerializeField] Transform m_ConstrainedObject;
|
||||
|
||||
[SyncSceneToStream, SerializeField, WeightRange(0f, 1f)] WeightedTransformArray m_SourceObjects;
|
||||
[SyncSceneToStream, SerializeField] Vector3 m_Offset;
|
||||
|
||||
[NotKeyable, SerializeField] Vector3Bool m_ConstrainedAxes;
|
||||
[NotKeyable, SerializeField] bool m_MaintainOffset;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public WeightedTransformArray sourceObjects
|
||||
{
|
||||
get => m_SourceObjects;
|
||||
set => m_SourceObjects = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool maintainOffset { get => m_MaintainOffset; set => m_MaintainOffset = value; }
|
||||
|
||||
/// <summary>Post-Translation offset applied to the constrained Transform.</summary>
|
||||
public Vector3 offset { get => m_Offset; set => m_Offset = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool constrainedXAxis { get => m_ConstrainedAxes.x; set => m_ConstrainedAxes.x = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedYAxis { get => m_ConstrainedAxes.y; set => m_ConstrainedAxes.y = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedZAxis { get => m_ConstrainedAxes.z; set => m_ConstrainedAxes.z = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string IMultiPositionConstraintData.offsetVector3Property => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_Offset));
|
||||
/// <inheritdoc />
|
||||
string IMultiPositionConstraintData.sourceObjectsProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_SourceObjects));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid()
|
||||
{
|
||||
if (m_ConstrainedObject == null || m_SourceObjects.Count == 0)
|
||||
return false;
|
||||
|
||||
foreach (var src in m_SourceObjects)
|
||||
if (src.transform == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_ConstrainedObject = null;
|
||||
m_ConstrainedAxes = new Vector3Bool(true);
|
||||
m_SourceObjects.Clear();
|
||||
m_MaintainOffset = false;
|
||||
m_Offset = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MultiPosition constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Multi-Position Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/MultiPositionConstraint.html")]
|
||||
public class MultiPositionConstraint : RigConstraint<
|
||||
MultiPositionConstraintJob,
|
||||
MultiPositionConstraintData,
|
||||
MultiPositionConstraintJobBinder<MultiPositionConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
var weights = m_Data.sourceObjects;
|
||||
WeightedTransformArray.OnValidate(ref weights);
|
||||
m_Data.sourceObjects = weights;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c10bdb03db33fb148b858a4a3b646cea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The MultiReferential constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct MultiReferentialConstraintData : IAnimationJobData, IMultiReferentialConstraintData
|
||||
{
|
||||
[SyncSceneToStream, SerializeField] int m_Driver;
|
||||
[SyncSceneToStream, SerializeField] List<Transform> m_SourceObjects;
|
||||
|
||||
/// <summary>The driver index. This is a value in between 0 and the number of sourceObjects.</summary>
|
||||
public int driver
|
||||
{
|
||||
get => m_Driver;
|
||||
set => m_Driver = Mathf.Clamp(value, 0, m_SourceObjects.Count - 1);
|
||||
}
|
||||
|
||||
/// <summary>The list of Transforms that are affected by the specified driver.</summary>
|
||||
public List<Transform> sourceObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_SourceObjects == null)
|
||||
m_SourceObjects = new List<Transform>();
|
||||
|
||||
return m_SourceObjects;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
m_SourceObjects = value;
|
||||
m_Driver = Mathf.Clamp(m_Driver, 0, m_SourceObjects.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
Transform[] IMultiReferentialConstraintData.sourceObjects => m_SourceObjects.ToArray();
|
||||
/// <inheritdoc />
|
||||
int IMultiReferentialConstraintData.driverValue => m_Driver;
|
||||
/// <inheritdoc />
|
||||
string IMultiReferentialConstraintData.driverIntProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_Driver));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid()
|
||||
{
|
||||
if (m_SourceObjects.Count < 2)
|
||||
return false;
|
||||
|
||||
foreach (var src in m_SourceObjects)
|
||||
if (src == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_Driver = 0;
|
||||
m_SourceObjects = new List<Transform>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the driver index to match the number of source objects.
|
||||
/// </summary>
|
||||
public void UpdateDriver() =>
|
||||
m_Driver = Mathf.Clamp(m_Driver, 0, m_SourceObjects != null ? m_SourceObjects.Count - 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MultiReferential constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Multi-Referential Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/MultiReferentialConstraint.html")]
|
||||
public class MultiReferentialConstraint : RigConstraint<
|
||||
MultiReferentialConstraintJob,
|
||||
MultiReferentialConstraintData,
|
||||
MultiReferentialConstraintJobBinder<MultiReferentialConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
m_Data.UpdateDriver();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1577d1bce6e9ec47b4c95dd2d94493a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,88 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The MultiRotation constraint job.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct MultiRotationConstraintData : IAnimationJobData, IMultiRotationConstraintData
|
||||
{
|
||||
[SerializeField] Transform m_ConstrainedObject;
|
||||
|
||||
[SyncSceneToStream, SerializeField, WeightRange(0f, 1f)] WeightedTransformArray m_SourceObjects;
|
||||
[SyncSceneToStream, SerializeField] Vector3 m_Offset;
|
||||
|
||||
[NotKeyable, SerializeField] Vector3Bool m_ConstrainedAxes;
|
||||
[NotKeyable, SerializeField] bool m_MaintainOffset;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public WeightedTransformArray sourceObjects
|
||||
{
|
||||
get => m_SourceObjects;
|
||||
set => m_SourceObjects = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool maintainOffset { get => m_MaintainOffset; set => m_MaintainOffset = value; }
|
||||
/// <summary>Post-Rotation offset applied to the constrained Transform.</summary>
|
||||
public Vector3 offset { get => m_Offset; set => m_Offset = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool constrainedXAxis { get => m_ConstrainedAxes.x; set => m_ConstrainedAxes.x = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedYAxis { get => m_ConstrainedAxes.y; set => m_ConstrainedAxes.y = value; }
|
||||
/// <inheritdoc />
|
||||
public bool constrainedZAxis { get => m_ConstrainedAxes.z; set => m_ConstrainedAxes.z = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string IMultiRotationConstraintData.offsetVector3Property => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_Offset));
|
||||
/// <inheritdoc />
|
||||
string IMultiRotationConstraintData.sourceObjectsProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_SourceObjects));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid()
|
||||
{
|
||||
if (m_ConstrainedObject == null || m_SourceObjects.Count == 0)
|
||||
return false;
|
||||
|
||||
foreach (var src in m_SourceObjects)
|
||||
if (src.transform == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_ConstrainedObject = null;
|
||||
m_ConstrainedAxes = new Vector3Bool(true);
|
||||
m_SourceObjects.Clear();
|
||||
m_MaintainOffset = false;
|
||||
m_Offset = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MultiRotation constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Multi-Rotation Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/MultiRotationConstraint.html")]
|
||||
public class MultiRotationConstraint : RigConstraint<
|
||||
MultiRotationConstraintJob,
|
||||
MultiRotationConstraintData,
|
||||
MultiRotationConstraintJobBinder<MultiRotationConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
var weights = m_Data.sourceObjects;
|
||||
WeightedTransformArray.OnValidate(ref weights);
|
||||
m_Data.sourceObjects = weights;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdb90b913935e644baaa86c076d788e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The OverrideTransform constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct OverrideTransformData : IAnimationJobData, IOverrideTransformData
|
||||
{
|
||||
/// <summary>
|
||||
/// The override space controls how the override source Transform
|
||||
/// is copied unto constrained Transform.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public enum Space
|
||||
{
|
||||
/// <summary>Copy override world TR components into world TR components of the constrained Transform.</summary>
|
||||
World = OverrideTransformJob.Space.World,
|
||||
/// <summary>Copy override local TR components into local TR components of the constrained Transform.</summary>
|
||||
Local = OverrideTransformJob.Space.Local,
|
||||
/// <summary>Add override local TR components to local TR components of the constrained Transform. </summary>
|
||||
Pivot = OverrideTransformJob.Space.Pivot
|
||||
}
|
||||
|
||||
[SerializeField] Transform m_ConstrainedObject;
|
||||
|
||||
[SyncSceneToStream, SerializeField] Transform m_OverrideSource;
|
||||
[SyncSceneToStream, SerializeField] Vector3 m_OverridePosition;
|
||||
[SyncSceneToStream, SerializeField] Vector3 m_OverrideRotation;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_PositionWeight;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_RotationWeight;
|
||||
|
||||
[NotKeyable, SerializeField] Space m_Space;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform constrainedObject { get => m_ConstrainedObject; set => m_ConstrainedObject = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform sourceObject { get => m_OverrideSource; set => m_OverrideSource = value; }
|
||||
/// <summary>The override space.</summary>
|
||||
public Space space { get => m_Space; set => m_Space = value; }
|
||||
/// <summary>The override position. This is taken into account only if sourceObject is null.</summary>
|
||||
public Vector3 position { get => m_OverridePosition; set => m_OverridePosition = value; }
|
||||
/// <summary>The override rotation. This is taken into account only if sourceObject is null.</summary>
|
||||
public Vector3 rotation { get => m_OverrideRotation; set => m_OverrideRotation = value; }
|
||||
/// <summary>The weight for which override position has an effect on constrained Transform. This is a value in between 0 and 1.</summary>
|
||||
public float positionWeight { get => m_PositionWeight; set => m_PositionWeight = Mathf.Clamp01(value); }
|
||||
/// <summary>The weight for which override rotation has an effect on constrained Transform. This is a value in between 0 and 1.</summary>
|
||||
public float rotationWeight { get => m_RotationWeight; set => m_RotationWeight = Mathf.Clamp01(value); }
|
||||
|
||||
/// <inheritdoc />
|
||||
int IOverrideTransformData.space => (int)m_Space;
|
||||
/// <inheritdoc />
|
||||
string IOverrideTransformData.positionWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_PositionWeight));
|
||||
/// <inheritdoc />
|
||||
string IOverrideTransformData.rotationWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_RotationWeight));
|
||||
/// <inheritdoc />
|
||||
string IOverrideTransformData.positionVector3Property => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_OverridePosition));
|
||||
/// <inheritdoc />
|
||||
string IOverrideTransformData.rotationVector3Property => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_OverrideRotation));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid() => m_ConstrainedObject != null;
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_ConstrainedObject = null;
|
||||
m_OverrideSource = null;
|
||||
m_OverridePosition = Vector3.zero;
|
||||
m_OverrideRotation = Vector3.zero;
|
||||
m_Space = Space.Pivot;
|
||||
m_PositionWeight = 1f;
|
||||
m_RotationWeight = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OverrideTransform constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Override Transform")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/OverrideTransform.html")]
|
||||
public class OverrideTransform : RigConstraint<
|
||||
OverrideTransformJob,
|
||||
OverrideTransformData,
|
||||
OverrideTransformJobBinder<OverrideTransformData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
m_Data.positionWeight = Mathf.Clamp01(m_Data.positionWeight);
|
||||
m_Data.rotationWeight = Mathf.Clamp01(m_Data.rotationWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf219326d2292de48a0c671da18d402b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The TwistChain constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct TwistChainConstraintData : IAnimationJobData, ITwistChainConstraintData
|
||||
{
|
||||
[SerializeField] private Transform m_Root;
|
||||
[SerializeField] private Transform m_Tip;
|
||||
|
||||
[SyncSceneToStream, SerializeField] private Transform m_RootTarget;
|
||||
[SyncSceneToStream, SerializeField] private Transform m_TipTarget;
|
||||
|
||||
[SerializeField] private AnimationCurve m_Curve;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform root { get => m_Root; set => m_Root = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform tip { get => m_Tip; set => m_Tip = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform rootTarget { get => m_RootTarget; set => m_RootTarget = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform tipTarget { get => m_TipTarget; set => m_TipTarget = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public AnimationCurve curve { get => m_Curve; set => m_Curve = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid() => !(root == null || tip == null || !tip.IsChildOf(root) || rootTarget == null || tipTarget == null || curve == null);
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
root = tip = rootTarget = tipTarget = null;
|
||||
curve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TwistChain constraint
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Twist Chain Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/TwistChainConstraint.html")]
|
||||
public class TwistChainConstraint : RigConstraint<
|
||||
TwistChainConstraintJob,
|
||||
TwistChainConstraintData,
|
||||
TwistChainConstraintJobBinder<TwistChainConstraintData>
|
||||
>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afb1fbe61e5894c96b30693270a4db99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,101 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The TwistCorrection constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct TwistCorrectionData : IAnimationJobData, ITwistCorrectionData
|
||||
{
|
||||
/// <summary>
|
||||
/// Axis type for TwistCorrection.
|
||||
/// </summary>
|
||||
public enum Axis
|
||||
{
|
||||
/// <summary>X Axis.</summary>
|
||||
X,
|
||||
/// <summary>Y Axis.</summary>
|
||||
Y,
|
||||
/// <summary>Z Axis.</summary>
|
||||
Z
|
||||
}
|
||||
|
||||
[SyncSceneToStream, SerializeField] Transform m_Source;
|
||||
|
||||
[NotKeyable, SerializeField] Axis m_TwistAxis;
|
||||
[SyncSceneToStream, SerializeField, WeightRange(-1f, 1f)] WeightedTransformArray m_TwistNodes;
|
||||
|
||||
/// <summary>The source Transform that influences the twist nodes.</summary>
|
||||
public Transform sourceObject { get => m_Source; set => m_Source = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public WeightedTransformArray twistNodes
|
||||
{
|
||||
get => m_TwistNodes;
|
||||
set => m_TwistNodes = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Axis twistAxis { get => m_TwistAxis; set => m_TwistAxis = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
Transform ITwistCorrectionData.source => m_Source;
|
||||
/// <inheritdoc />
|
||||
Vector3 ITwistCorrectionData.twistAxis => Convert(m_TwistAxis);
|
||||
|
||||
/// <inheritdoc />
|
||||
string ITwistCorrectionData.twistNodesProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_TwistNodes));
|
||||
|
||||
static Vector3 Convert(Axis axis)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
return Vector3.right;
|
||||
|
||||
if (axis == Axis.Y)
|
||||
return Vector3.up;
|
||||
|
||||
return Vector3.forward;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid()
|
||||
{
|
||||
if (m_Source == null)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < m_TwistNodes.Count; ++i)
|
||||
if (m_TwistNodes[i].transform == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_Source = null;
|
||||
m_TwistAxis = Axis.Z;
|
||||
m_TwistNodes.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TwistCorrection constraint.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Twist Correction")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/TwistCorrection.html")]
|
||||
public class TwistCorrection : RigConstraint<
|
||||
TwistCorrectionJob,
|
||||
TwistCorrectionData,
|
||||
TwistCorrectionJobBinder<TwistCorrectionData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
var weights = m_Data.twistNodes;
|
||||
WeightedTransformArray.OnValidate(ref weights, -1f, 1f);
|
||||
m_Data.twistNodes = weights;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a4834896bd86034eb2aacc65cb0c593
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
namespace UnityEngine.Animations.Rigging
|
||||
{
|
||||
/// <summary>
|
||||
/// The TwoBoneIK constraint data.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public struct TwoBoneIKConstraintData : IAnimationJobData, ITwoBoneIKConstraintData
|
||||
{
|
||||
[SerializeField] Transform m_Root;
|
||||
[SerializeField] Transform m_Mid;
|
||||
[SerializeField] Transform m_Tip;
|
||||
|
||||
[SyncSceneToStream, SerializeField] Transform m_Target;
|
||||
[SyncSceneToStream, SerializeField] Transform m_Hint;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_TargetPositionWeight;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_TargetRotationWeight;
|
||||
[SyncSceneToStream, SerializeField, Range(0f, 1f)] float m_HintWeight;
|
||||
|
||||
[NotKeyable, SerializeField] bool m_MaintainTargetPositionOffset;
|
||||
[NotKeyable, SerializeField] bool m_MaintainTargetRotationOffset;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Transform root { get => m_Root; set => m_Root = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform mid { get => m_Mid; set => m_Mid = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform tip { get => m_Tip; set => m_Tip = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform target { get => m_Target; set => m_Target = value; }
|
||||
/// <inheritdoc />
|
||||
public Transform hint { get => m_Hint; set => m_Hint = value; }
|
||||
|
||||
/// <summary>The weight for which target position has an effect on IK calculations. This is a value in between 0 and 1.</summary>
|
||||
public float targetPositionWeight { get => m_TargetPositionWeight; set => m_TargetPositionWeight = Mathf.Clamp01(value); }
|
||||
/// <summary>The weight for which target rotation has an effect on IK calculations. This is a value in between 0 and 1.</summary>
|
||||
public float targetRotationWeight { get => m_TargetRotationWeight; set => m_TargetRotationWeight = Mathf.Clamp01(value); }
|
||||
/// <summary>The weight for which hint transform has an effect on IK calculations. This is a value in between 0 and 1.</summary>
|
||||
public float hintWeight { get => m_HintWeight; set => m_HintWeight = Mathf.Clamp01(value); }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool maintainTargetPositionOffset { get => m_MaintainTargetPositionOffset; set => m_MaintainTargetPositionOffset = value; }
|
||||
/// <inheritdoc />
|
||||
public bool maintainTargetRotationOffset { get => m_MaintainTargetRotationOffset; set => m_MaintainTargetRotationOffset = value; }
|
||||
|
||||
/// <inheritdoc />
|
||||
string ITwoBoneIKConstraintData.targetPositionWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_TargetPositionWeight));
|
||||
/// <inheritdoc />
|
||||
string ITwoBoneIKConstraintData.targetRotationWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_TargetRotationWeight));
|
||||
/// <inheritdoc />
|
||||
string ITwoBoneIKConstraintData.hintWeightFloatProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_HintWeight));
|
||||
|
||||
/// <inheritdoc />
|
||||
bool IAnimationJobData.IsValid() => (m_Tip != null && m_Mid != null && m_Root != null && m_Target != null && m_Tip.IsChildOf(m_Mid) && m_Mid.IsChildOf(m_Root));
|
||||
|
||||
/// <inheritdoc />
|
||||
void IAnimationJobData.SetDefaultValues()
|
||||
{
|
||||
m_Root = null;
|
||||
m_Mid = null;
|
||||
m_Tip = null;
|
||||
m_Target = null;
|
||||
m_Hint = null;
|
||||
m_TargetPositionWeight = 1f;
|
||||
m_TargetRotationWeight = 1f;
|
||||
m_HintWeight = 1f;
|
||||
m_MaintainTargetPositionOffset = false;
|
||||
m_MaintainTargetRotationOffset = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TwoBoneIK constraint
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("Animation Rigging/Two Bone IK Constraint")]
|
||||
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/constraints/TwoBoneIKConstraint.html")]
|
||||
public class TwoBoneIKConstraint : RigConstraint<
|
||||
TwoBoneIKConstraintJob,
|
||||
TwoBoneIKConstraintData,
|
||||
TwoBoneIKConstraintJobBinder<TwoBoneIKConstraintData>
|
||||
>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
m_Data.hintWeight = Mathf.Clamp01(m_Data.hintWeight);
|
||||
m_Data.targetPositionWeight = Mathf.Clamp01(m_Data.targetPositionWeight);
|
||||
m_Data.targetRotationWeight = Mathf.Clamp01(m_Data.targetRotationWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeda7bfbf984f2a4da5ab4b8967b115d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: ca41524ec86f0d84ab5675c9622cc1a2, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user