forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationWindowKeyframe.cs
More file actions
174 lines (148 loc) · 4.64 KB
/
Copy pathAnimationWindowKeyframe.cs
File metadata and controls
174 lines (148 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using UnityEngine;
using UnityEditor;
namespace UnityEditorInternal
{
internal class AnimationWindowKeyframe
{
public float m_InTangent;
public float m_OutTangent;
public float m_InWeight;
public float m_OutWeight;
public WeightedMode m_WeightedMode;
public int m_TangentMode;
public int m_TimeHash;
int m_Hash;
float m_time;
object m_value;
AnimationWindowCurve m_curve;
public float time
{
get { return m_time; }
set
{
m_time = value;
m_Hash = 0;
m_TimeHash = value.GetHashCode();
}
}
public object value
{
get { return m_value; }
set { m_value = value; }
}
public float inTangent
{
get { return m_InTangent; }
set { m_InTangent = value; }
}
public float outTangent
{
get { return m_OutTangent; }
set { m_OutTangent = value; }
}
public float inWeight
{
get { return m_InWeight; }
set { m_InWeight = value; }
}
public float outWeight
{
get { return m_OutWeight; }
set { m_OutWeight = value; }
}
public WeightedMode weightedMode
{
get { return m_WeightedMode; }
set { m_WeightedMode = value; }
}
public AnimationWindowCurve curve
{
get { return m_curve; }
set
{
m_curve = value;
m_Hash = 0;
}
}
public bool isPPtrCurve { get { return curve.isPPtrCurve; } }
public bool isDiscreteCurve { get { return curve.isDiscreteCurve; } }
public AnimationWindowKeyframe()
{
}
public AnimationWindowKeyframe(AnimationWindowKeyframe key)
{
this.time = key.time;
this.value = key.value;
this.curve = key.curve;
this.m_InTangent = key.m_InTangent;
this.m_OutTangent = key.m_OutTangent;
this.m_InWeight = key.inWeight;
this.m_OutWeight = key.outWeight;
this.m_WeightedMode = key.weightedMode;
this.m_TangentMode = key.m_TangentMode;
this.m_curve = key.m_curve;
}
public AnimationWindowKeyframe(AnimationWindowCurve curve, Keyframe key)
{
this.time = key.time;
this.value = key.value;
this.curve = curve;
this.m_InTangent = key.inTangent;
this.m_OutTangent = key.outTangent;
this.m_InWeight = key.inWeight;
this.m_OutWeight = key.outWeight;
this.m_WeightedMode = key.weightedMode;
this.m_TangentMode = key.tangentModeInternal;
this.m_curve = curve;
}
public AnimationWindowKeyframe(AnimationWindowCurve curve, ObjectReferenceKeyframe key)
{
this.time = key.time;
this.value = key.value;
this.curve = curve;
}
public int GetHash()
{
if (m_Hash == 0)
{
// Berstein hash
unchecked
{
m_Hash = curve.GetHashCode();
m_Hash = 33 * m_Hash + time.GetHashCode();
}
}
return m_Hash;
}
public int GetIndex()
{
for (int i = 0; i < curve.m_Keyframes.Count; i++)
{
if (curve.m_Keyframes[i] == this)
{
return i;
}
}
return -1;
}
public Keyframe ToKeyframe()
{
var keyframe = new Keyframe(time, (float)value, inTangent, outTangent);
keyframe.tangentModeInternal = m_TangentMode;
keyframe.weightedMode = weightedMode;
keyframe.inWeight = inWeight;
keyframe.outWeight = outWeight;
return keyframe;
}
public ObjectReferenceKeyframe ToObjectReferenceKeyframe()
{
var keyframe = new ObjectReferenceKeyframe();
keyframe.time = time;
keyframe.value = (UnityEngine.Object)value;
return keyframe;
}
}
}