private AnimationClip CopyAndNeutralize(AnimationClip animationClipToBePreserved, HashSet <CurveKey> allApplicableCurveKeys, bool useExhaustiveAnimations) { var copyOfAnimationClip = new AnimationClip { name = "zAutogeneratedExp_" + animationClipToBePreserved.name + "_DO_NOT_EDIT" }; AnimationUtility.SetAnimationClipSettings(copyOfAnimationClip, AnimationUtility.GetAnimationClipSettings(animationClipToBePreserved)); var originalBindings = AnimationUtility.GetCurveBindings(animationClipToBePreserved); foreach (var binding in originalBindings) { var curveKey = CurveKey.FromBinding(binding); var canCopyCurve = _compilerConflictFxLayerMode == ConflictFxLayerMode.KeepBoth || !ShouldRemoveCurve(curveKey); if (canCopyCurve) { var curve = AnimationUtility.GetEditorCurve(animationClipToBePreserved, binding); if (!_doNotFixSingleKeyframes && curve.keys.Length == 1) { curve = new AnimationCurve(MakeSingleKeyframeIntoTwo(curve)); } AnimationUtility.SetEditorCurve(copyOfAnimationClip, binding, curve); } } if (useExhaustiveAnimations) { var thisAnimationPaths = originalBindings .Select(CurveKey.FromBinding) .ToList(); AddMissingCurveKeys(allApplicableCurveKeys, thisAnimationPaths, copyOfAnimationClip); } return(copyOfAnimationClip); }
public override int GetHashCode() { unchecked { return((CurveKey.GetHashCode() * 397) ^ SampleValue.GetHashCode()); } }
private static Dictionary <CurveKey, float> ExtractFirstKeyframeValueOf(AnimationClip clip) { var curveKeyToFallbackValue = new Dictionary <CurveKey, float>(); foreach (var editorCurveBinding in AnimationUtility.GetCurveBindings(clip)) { var curve = AnimationUtility.GetEditorCurve(clip, editorCurveBinding); if (curve.keys.Length > 0) { curveKeyToFallbackValue.Add(CurveKey.FromBinding(editorCurveBinding), curve.keys[0].value); } } return(curveKeyToFallbackValue); }
private bool ShouldRemoveCurve(CurveKey curveKey) { switch (_compilerConflictFxLayerMode) { case ConflictFxLayerMode.RemoveTransformsAndMuscles: return(curveKey.IsTransformOrMuscleCurve()); case ConflictFxLayerMode.KeepOnlyTransformsAndMuscles: return(!curveKey.IsTransformOrMuscleCurve()); case ConflictFxLayerMode.KeepOnlyTransforms: return(!curveKey.IsTransformCurve()); case ConflictFxLayerMode.KeepBoth: default: throw new ArgumentOutOfRangeException(); } }
public bool Equals(SampledCurveKey other) { return(CurveKey.Equals(other.CurveKey) && SampleValue.Equals(other.SampleValue)); }
public SampledCurveKey(CurveKey curveKey, float sampleValue) { CurveKey = curveKey; SampleValue = sampleValue; }
public bool Equals(CurveKey other) { return(Path == other.Path && Equals(Type, other.Type) && PropertyName == other.PropertyName); }