This commit is contained in:
corn
2026-06-07 22:59:32 +08:00
commit a62ff7379b
7171 changed files with 10015624 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
namespace Dreamteck.Splines
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class ColorModifier : SplineSampleModifier
{
[System.Serializable]
public class ColorKey : Key
{
public enum BlendMode { Lerp, Multiply, Add, Subtract }
public Color color = Color.white;
public BlendMode blendMode = BlendMode.Lerp;
public ColorKey(double f, double t, ColorModifier modifier) : base(f, t, modifier)
{
}
public Color Blend(Color input, float percent)
{
switch (blendMode)
{
case BlendMode.Lerp: return Color.Lerp(input, color, blend * percent);
case BlendMode.Add: return input + color * blend * percent;
case BlendMode.Subtract: return input - color * blend * percent;
case BlendMode.Multiply: return Color.Lerp(input, input * color, blend * percent);
default: return input;
}
}
}
public List<ColorKey> keys = new List<ColorKey>();
public ColorModifier()
{
keys = new List<ColorKey>();
}
public override List<Key> GetKeys()
{
List<Key> output = new List<Key>();
for (int i = 0; i < keys.Count; i++) output.Add(keys[i]);
return output;
}
public override void SetKeys(List<Key> input)
{
keys = new List<ColorKey>();
for (int i = 0; i < input.Count; i++) keys.Add((ColorKey)input[i]);
base.SetKeys(input);
}
public void AddKey(double f, double t)
{
keys.Add(new ColorKey(f, t, this));
}
public override void Apply(SplineSample result)
{
if (keys.Count == 0) return;
base.Apply(result);
for (int i = 0; i < keys.Count; i++)
{
result.color = keys[i].Blend(result.color, keys[i].Evaluate(result.percent));
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07c5bf379e882994f9828b66623ef12f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ab66b80f71b94c540922050b21bf0d4a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
namespace Dreamteck.Splines.Editor
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class ColorModifierEditor : SplineSampleModifierEditor
{
private float addTime = 0f;
public ColorModifierEditor(SplineUser user, SplineUserEditor editor, ColorModifier input) : base(user, editor, input)
{
module = input;
title = "Color Modifiers";
}
public void ClearSelection()
{
selected = -1;
}
public override void DrawInspector()
{
base.DrawInspector();
if (!isOpen) return;
if (GUILayout.Button("Add New Color"))
{
((ColorModifier)module).AddKey(addTime - 0.1, addTime + 0.1);
user.Rebuild();
}
}
protected override void KeyGUI(SplineSampleModifier.Key key)
{
ColorModifier.ColorKey offsetKey = (ColorModifier.ColorKey)key;
base.KeyGUI(key);
offsetKey.color = EditorGUILayout.ColorField("Color", offsetKey.color);
offsetKey.blendMode = (ColorModifier.ColorKey.BlendMode)EditorGUILayout.EnumPopup("Blend Mode", offsetKey.blendMode);
}
protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
{
if (!isOpen) return;
base.KeyHandles(key, edit);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e4533e035e560d64aaa86e06610a58ed
timeCreated: 1482695688
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,78 @@
namespace Dreamteck.Splines.Editor
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class OffsetModifierEditor : SplineSampleModifierEditor
{
public bool allowSelection = true;
private float addTime = 0f;
Matrix4x4 matrix = new Matrix4x4();
public OffsetModifierEditor(SplineUser user, SplineUserEditor editor, OffsetModifier input) : base(user, editor, input)
{
module = input;
title = "Offset Modifiers";
}
public void ClearSelection()
{
selected = -1;
}
public override void DrawInspector()
{
base.DrawInspector();
if (!isOpen) return;
if (GUILayout.Button("Add New Offset"))
{
((OffsetModifier)module).AddKey(Vector2.zero, addTime - 0.1, addTime + 0.1);
user.Rebuild();
}
}
protected override void KeyGUI(SplineSampleModifier.Key key)
{
OffsetModifier.OffsetKey offsetKey = (OffsetModifier.OffsetKey)key;
base.KeyGUI(key);
offsetKey.offset = EditorGUILayout.Vector2Field("Offset", offsetKey.offset);
}
protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
{
if (!isOpen) return;
bool is2D = user.spline != null && user.spline.is2D;
SplineSample result = new SplineSample();
OffsetModifier.OffsetKey offsetKey = (OffsetModifier.OffsetKey)key;
user.spline.Evaluate(offsetKey.position, result);
matrix.SetTRS(result.position, Quaternion.LookRotation(result.forward, result.up), Vector3.one * result.size);
Vector3 pos = matrix.MultiplyPoint(offsetKey.offset);
if (is2D)
{
Handles.DrawLine(result.position, result.position + result.right * offsetKey.offset.x * result.size);
Handles.DrawLine(result.position, result.position - result.right * offsetKey.offset.x * result.size);
}
else Handles.DrawWireDisc(result.position, result.forward, offsetKey.offset.magnitude * result.size);
Handles.DrawLine(result.position, pos);
if (edit)
{
Vector3 lastPos = pos;
pos = SplineEditorHandles.FreeMoveRectangle(pos, HandleUtility.GetHandleSize(pos) * 0.1f);
if (pos != lastPos)
{
pos = matrix.inverse.MultiplyPoint(pos);
pos.z = 0f;
if (is2D) offsetKey.offset = Vector2.right * pos.x;
else offsetKey.offset = pos;
user.Rebuild();
}
}
base.KeyHandles(key, edit);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: eaf21c57b8cb8f548984f66d80cfe07d
timeCreated: 1482695688
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
namespace Dreamteck.Splines.Editor
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class RotationModifierEditor : SplineSampleModifierEditor
{
public bool allowSelection = true;
private float addTime = 0f;
public RotationModifierEditor(SplineUser user, SplineUserEditor parent, RotationModifier input) : base(user, parent, input)
{
title = "Rotation Modifiers";
}
public void ClearSelection()
{
selected = -1;
}
public override void DrawInspector()
{
base.DrawInspector();
if (!isOpen) return;
if (GUILayout.Button("Add New Rotation"))
{
((RotationModifier)module).AddKey(Vector3.zero, addTime - 0.1, addTime + 0.1);
user.Rebuild();
}
}
protected override void KeyGUI(SplineSampleModifier.Key key)
{
RotationModifier.RotationKey rotationKey = (RotationModifier.RotationKey)key;
base.KeyGUI(key);
if (!rotationKey.useLookTarget) rotationKey.rotation = EditorGUILayout.Vector3Field("Rotation", rotationKey.rotation);
rotationKey.useLookTarget = EditorGUILayout.Toggle("Use Look Target", rotationKey.useLookTarget);
if (rotationKey.useLookTarget) rotationKey.target = (Transform)EditorGUILayout.ObjectField("Target", rotationKey.target, typeof(Transform), true);
}
protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
{
RotationModifier.RotationKey rotationKey = (RotationModifier.RotationKey)key;
SplineSample result = new SplineSample();
user.spline.Evaluate(rotationKey.position, result);
if (rotationKey.useLookTarget)
{
if (rotationKey.target != null)
{
Handles.DrawDottedLine(result.position, rotationKey.target.position, 5f);
if (edit)
{
Vector3 lastPos = rotationKey.target.position;
rotationKey.target.position = Handles.PositionHandle(rotationKey.target.position, Quaternion.identity);
if (lastPos != rotationKey.target.position) user.Rebuild();
}
}
}
else
{
Quaternion directionRot = Quaternion.LookRotation(result.forward, result.up);
Quaternion rot = directionRot * Quaternion.Euler(rotationKey.rotation);
SplineEditorHandles.DrawArrowCap(result.position, rot, HandleUtility.GetHandleSize(result.position));
if (edit)
{
Vector3 lastEuler = rot.eulerAngles;
rot = Handles.RotationHandle(rot, result.position);
rot = Quaternion.Inverse(directionRot) * rot;
rotationKey.rotation = rot.eulerAngles;
if (rot.eulerAngles != lastEuler) user.Rebuild();
}
}
base.KeyHandles(key, edit);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 610b2b9894ff02a4abf2f483a19aeccc
timeCreated: 1482695688
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,43 @@
namespace Dreamteck.Splines.Editor
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class SizeModifierEditor : SplineSampleModifierEditor
{
public bool allowSelection = true;
private float addTime = 0f;
public SizeModifierEditor(SplineUser user, SplineUserEditor editor, SizeModifier input) : base(user, editor, input)
{
module = input;
title = "Size Modifiers";
}
public void ClearSelection()
{
selected = -1;
}
public override void DrawInspector()
{
base.DrawInspector();
if (!isOpen) return;
if (GUILayout.Button("Add New Size"))
{
((SizeModifier)module).AddKey(addTime - 0.1, addTime + 0.1);
user.Rebuild();
}
}
protected override void KeyGUI(SplineSampleModifier.Key key)
{
SizeModifier.SizeKey offsetKey = (SizeModifier.SizeKey)key;
base.KeyGUI(key);
offsetKey.size = EditorGUILayout.FloatField("Size", offsetKey.size);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dbfe0843022c91745a4144f758c78367
timeCreated: 1482695688
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,147 @@
namespace Dreamteck.Splines.Editor
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class SplineSampleModifierEditor : SplineUserSubEditor
{
protected SplineSampleModifier module;
protected int selected = -1;
protected bool drawAllKeys = false;
public SplineSampleModifierEditor(SplineUser user, SplineUserEditor editor, SplineSampleModifier input) : base(user, editor)
{
module = input;
title = "Tracer Module";
}
public override void DrawInspector()
{
base.DrawInspector();
if (!isOpen) return;
List<SplineSampleModifier.Key> keys = module.GetKeys();
if (keys.Count > 0) drawAllKeys = EditorGUILayout.Toggle("Draw all Modules", drawAllKeys);
for (int i = 0; i < keys.Count; i++)
{
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
if (selected == i)
{
EditorGUI.BeginChangeCheck();
KeyGUI(keys[i]);
if (EditorGUI.EndChangeCheck()) user.Rebuild();
}
else EditorGUILayout.LabelField(i + " [" + (Mathf.Round((float)keys[i].start * 10) / 10f) + " - " + (Mathf.Round((float)keys[i].end * 10) / 10f) + "]");
EditorGUILayout.EndVertical();
Rect lastRect = GUILayoutUtility.GetLastRect();
if (lastRect.Contains(Event.current.mousePosition))
{
if(Event.current.type == EventType.MouseDown)
{
if(Event.current.button == 0)
{
selected = i;
editor.Repaint();
} else if (Event.current.button == 1)
{
int index = i;
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Delete"), false, delegate
{
keys.RemoveAt(index);
module.SetKeys(keys);
editor.Repaint();
});
menu.ShowAsContext();
}
}
}
}
EditorGUILayout.Space();
if (keys.Count > 0) module.blend = EditorGUILayout.Slider("Blend", module.blend, 0f, 1f);
}
public override void DrawScene()
{
base.DrawScene();
List<SplineSampleModifier.Key> keys = module.GetKeys();
for (int i = 0; i < keys.Count; i++)
{
if(selected == i || drawAllKeys) KeyHandles(keys[i], selected == i);
}
}
protected virtual void KeyGUI(SplineSampleModifier.Key key)
{
EditorGUILayout.BeginHorizontal();
EditorGUIUtility.labelWidth = 50f;
key.start = EditorGUILayout.Slider("Start", (float)key.start, 0f, 1f);
key.end = EditorGUILayout.Slider("End", (float)key.end, 0f, 1f);
EditorGUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = 0f;
float centerStart = (float)key.centerStart, centerEnd = (float)key.centerEnd;
EditorGUILayout.MinMaxSlider("Center", ref centerStart, ref centerEnd, 0f, 1f);
key.centerStart = centerStart;
key.centerEnd = centerEnd;
if (key.interpolation == null) key.interpolation = AnimationCurve.Linear(0f, 0f, 1f, 1f);
key.interpolation = EditorGUILayout.CurveField("Interpolation", key.interpolation);
key.blend = EditorGUILayout.Slider("Blend", key.blend, 0f, 1f);
}
protected virtual void KeyHandles(SplineSampleModifier.Key key, bool edit)
{
if (!isOpen) return;
bool changed = false;
double value = 0f;
value = key.start;
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "Start", SplineEditorHandles.SplineSliderGizmo.ForwardTriangle, 0.8f);
if (key.start != value)
{
key.start = value;
changed = true;
}
value = key.globalCenterStart;
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Rectangle, 0.6f);
if (key.globalCenterStart != value)
{
key.globalCenterStart = value;
changed = true;
}
value = key.globalCenterEnd;
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Rectangle, 0.6f);
if (key.globalCenterEnd != value)
{
key.globalCenterEnd = value;
changed = true;
}
value = key.end;
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "End", SplineEditorHandles.SplineSliderGizmo.BackwardTriangle, 0.8f);
if (key.end != value)
{
key.end = value;
changed = true;
}
if (Event.current.control)
{
value = key.position;
double lastValue = value;
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Circle, 0.4f);
if (value != lastValue)
{
key.position = value;
changed = true;
}
}
if (changed) user.Rebuild();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1cc10f0a74040154da18f19ce3fe2ccc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
namespace Dreamteck.Splines
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class OffsetModifier : SplineSampleModifier
{
[System.Serializable]
public class OffsetKey : Key
{
public Vector2 offset = Vector2.zero;
public OffsetKey(Vector2 o, double f, double t, OffsetModifier modifier) : base(f, t, modifier)
{
offset = o;
}
}
public List<OffsetKey> keys = new List<OffsetKey>();
public OffsetModifier()
{
keys = new List<OffsetKey>();
}
public override List<Key> GetKeys()
{
List<Key> output = new List<Key>();
for (int i = 0; i < keys.Count; i++) output.Add(keys[i]);
return output;
}
public override void SetKeys(List<Key> input)
{
keys = new List<OffsetKey>();
for (int i = 0; i < input.Count; i++) keys.Add((OffsetKey)input[i]);
base.SetKeys(input);
}
public void AddKey(Vector2 offset, double f, double t)
{
keys.Add(new OffsetKey(offset, f, t, this));
}
public override void Apply(SplineSample result)
{
if (keys.Count == 0) return;
base.Apply(result);
Vector2 offset = Evaluate(result.percent);
result.position += result.right * offset.x + result.up * offset.y;
}
Vector2 Evaluate(double time)
{
if (keys.Count == 0) return Vector2.zero;
Vector2 offset = Vector2.zero;
for(int i = 0; i < keys.Count; i++) offset += keys[i].offset * keys[i].Evaluate(time);
return offset * blend;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9d0cc7c794f1e3148acddeb3d008c597
timeCreated: 1482692196
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Dreamteck.Splines
{
[System.Serializable]
public class RotationModifier : SplineSampleModifier
{
[System.Serializable]
public class RotationKey : Key
{
public bool useLookTarget = false;
public Transform target = null;
public Vector3 rotation = Vector3.zero;
public RotationKey(Vector3 rotation, double f, double t, RotationModifier modifier) : base(f, t, modifier)
{
this.rotation = rotation;
}
}
public List<RotationKey> keys = new List<RotationKey>();
public RotationModifier()
{
keys = new List<RotationKey>();
}
public override List<Key> GetKeys()
{
List<Key> output = new List<Key>();
for (int i = 0; i < keys.Count; i++) output.Add(keys[i]);
return output;
}
public override void SetKeys(List<Key> input)
{
keys = new List<RotationKey>();
for (int i = 0; i < input.Count; i++) keys.Add((RotationKey)input[i]);
base.SetKeys(input);
}
public void AddKey(Vector3 rotation, double f, double t)
{
keys.Add(new RotationKey(rotation, f, t, this));
}
public override void Apply(SplineSample result)
{
if (keys.Count == 0) return;
base.Apply(result);
Quaternion offset = Quaternion.identity, look = result.rotation;
for (int i = 0; i < keys.Count; i++)
{
if (keys[i].useLookTarget && keys[i].target != null)
{
Quaternion lookDir = Quaternion.LookRotation(keys[i].target.position - result.position);
look = Quaternion.Slerp(look, lookDir, keys[i].Evaluate(result.percent));
}
else
{
Quaternion euler = Quaternion.Euler(keys[i].rotation.x, keys[i].rotation.y, keys[i].rotation.z);
offset = Quaternion.Slerp(offset, offset * euler, keys[i].Evaluate(result.percent));
}
}
Quaternion rotation = look * offset;
Vector3 invertedNormal = Quaternion.Inverse(result.rotation) * result.up;
result.forward = rotation * Vector3.forward;
result.up = rotation * invertedNormal;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0049066920c0f4549af72ec0044c71c6
timeCreated: 1482692196
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
namespace Dreamteck.Splines
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class SizeModifier : SplineSampleModifier
{
[System.Serializable]
public class SizeKey : Key
{
public float size = 0f;
public SizeKey(double f, double t, SizeModifier modifier) : base(f, t, modifier)
{
}
}
public List<SizeKey> keys = new List<SizeKey>();
public SizeModifier()
{
keys = new List<SizeKey>();
}
public override List<Key> GetKeys()
{
List<Key> output = new List<Key>();
for (int i = 0; i < keys.Count; i++) output.Add(keys[i]);
return output;
}
public override void SetKeys(List<Key> input)
{
keys = new List<SizeKey>();
for (int i = 0; i < input.Count; i++)
{
input[i].modifier = this;
keys.Add((SizeKey)input[i]);
}
}
public void AddKey(double f, double t)
{
keys.Add(new SizeKey(f, t, this));
}
public override void Apply(SplineSample result)
{
if (keys.Count == 0) return;
base.Apply(result);
for (int i = 0; i < keys.Count; i++)
{
result.size += keys[i].Evaluate(result.percent) * keys[i].size;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 896008ffd57dfab499f9f0745f7dbb4f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,189 @@
namespace Dreamteck.Splines
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class SplineSampleModifier
{
public float blend = 1f;
public virtual List<Key> GetKeys()
{
return new List<Key>();
}
public virtual void SetKeys(List<Key> input)
{
for (int i = 0; i < input.Count; i++) input[i].modifier = this;
}
public virtual void Apply(SplineSample result)
{
}
public virtual void Apply(SplineSample source, SplineSample destination)
{
destination.CopyFrom(source);
Apply(destination);
}
[System.Serializable]
public class Key
{
public double start
{
get { return _featherStart; }
set {
if (value != _featherStart)
{
_featherStart = DMath.Clamp01(value);
}
}
}
public double end
{
get { return _featherEnd; }
set {
if (value != _featherEnd)
{
_featherEnd = DMath.Clamp01(value);
}
}
}
public double centerStart
{
get { return _centerStart; }
set {
if (value != _centerStart)
{
_centerStart = DMath.Clamp01(value);
if (_centerStart > _centerEnd) _centerStart = _centerEnd;
}
}
}
public double centerEnd
{
get { return _centerEnd; }
set {
if (value != _centerEnd)
{
_centerEnd = DMath.Clamp01(value);
if (_centerEnd < _centerStart) _centerEnd = _centerStart;
}
}
}
public double globalCenterStart
{
get {
return LocalToGlobalPercent(centerStart);
}
set
{
centerStart = DMath.Clamp01(GlobalToLocalPercent(value));
}
}
public double globalCenterEnd
{
get
{
return LocalToGlobalPercent(centerEnd);
}
set
{
centerEnd = DMath.Clamp01(GlobalToLocalPercent(value));
}
}
public double position
{
get
{
double center = DMath.Lerp(_centerStart, _centerEnd, 0.5);
if (start > end)
{
double pos = DMath.Lerp(_featherStart, _featherEnd, center);
double fromToEndDistance = 1.0 - _featherStart;
double centerDistance = center * (fromToEndDistance + _featherEnd);
pos = _featherStart + centerDistance;
if (pos > 1.0) pos -= 1.0;
return pos;
}
else return DMath.Lerp(_featherStart, _featherEnd, center);
}
set
{
double delta = value - position;
start += delta;
end += delta;
}
}
[SerializeField]
private double _featherStart = 0.0, _featherEnd = 0.0, _centerStart = 0.25, _centerEnd = 0.75;
[SerializeField]
internal SplineSampleModifier modifier = null;
public AnimationCurve interpolation;
public float blend = 1f;
internal Key(double f, double t, SplineSampleModifier modifier)
{
this.modifier = modifier;
start = f;
end = t;
interpolation = AnimationCurve.Linear(0f, 0f, 1f, 1f);
}
double GlobalToLocalPercent(double t)
{
if (_featherStart > _featherEnd)
{
if (t > _featherStart) return DMath.InverseLerp(_featherStart, _featherStart + (1.0 - _featherStart) + _featherEnd, t);
else if (t < _featherEnd) return DMath.InverseLerp(-(1.0 - _featherStart), _featherEnd, t);
else return 0f;
}
return DMath.InverseLerp(_featherStart, _featherEnd, t);
}
double LocalToGlobalPercent(double t)
{
if (_featherStart > _featherEnd)
{
t = DMath.Lerp(_featherStart, _featherStart + (1.0 - _featherStart) + _featherEnd, t);
if (t > 1.0) t -= 1.0;
return t;
}
return DMath.Lerp(_featherStart, _featherEnd, t);
}
public float Evaluate(double t)
{
t = (float)GlobalToLocalPercent(t);
if(t < _centerStart) return interpolation.Evaluate((float)t / (float)_centerStart);
if(t > _centerEnd) return interpolation.Evaluate(1f - (float)DMath.InverseLerp(_centerEnd, 1.0, t));
return interpolation.Evaluate(1f) * blend;
}
public virtual Key Duplicate()
{
Key newKey = new Key(start, end, modifier);
newKey._centerStart = _centerStart;
newKey._centerEnd = _centerEnd;
newKey.blend = blend;
newKey.interpolation = DuplicateUtility.DuplicateCurve(interpolation);
return newKey;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 26a8731450d83c541afa4dd71666f85d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: