Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into 4.1
  • Loading branch information
badlogic committed Apr 12, 2023
2 parents 14219fa + 476fb15 commit 6ec6c4c
Showing 1 changed file with 37 additions and 43 deletions.
Expand Up @@ -848,7 +848,7 @@ public struct Pair {

keys.Add(new Keyframe(0, rotation, 0, 0));

int listIndex = 1;
int listIndex = 0;

float r = rotation;

Expand All @@ -865,7 +865,7 @@ public struct Pair {
animation.Apply(skeleton, 0, currentTime, true, null, 1f, MixBlend.Setup, MixDirection.In);
skeleton.UpdateWorldTransform();

int pIndex = listIndex - 1;
int pIndex = listIndex;

Keyframe pk = keys[pIndex];

Expand Down Expand Up @@ -919,16 +919,16 @@ public struct Pair {
xKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] + boneData.X, 0, 0));
yKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[2] + boneData.Y, 0, 0));

int listIndex = 1;
int frameIndex = 1;
int listIndex = 0;
int frameIndex = 0;
int f = TranslateTimeline.ENTRIES;
float[] frames = timeline.Frames;
skeleton.SetToSetupPose();
float lastTime = 0;
while (currentTime < endTime) {
int pIndex = listIndex - 1;
int pIndex = listIndex;

float curveType = timeline.GetCurveType(frameIndex - 1);
float curveType = timeline.GetCurveType(frameIndex);
if (curveType == 0) {
//linear
Keyframe px = xKeys[pIndex];
Expand Down Expand Up @@ -999,8 +999,8 @@ public struct Pair {

timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In);

px = xKeys[listIndex - 1];
py = yKeys[listIndex - 1];
px = xKeys[listIndex];
py = yKeys[listIndex];

float xOut = (bone.X - px.value) / (currentTime - px.time);
float yOut = (bone.Y - py.value) / (currentTime - py.time);
Expand All @@ -1011,8 +1011,8 @@ public struct Pair {
xKeys.Add(new Keyframe(currentTime, bone.X, xOut, 0));
yKeys.Add(new Keyframe(currentTime, bone.Y, yOut, 0));

xKeys[listIndex - 1] = px;
yKeys[listIndex - 1] = py;
xKeys[listIndex] = px;
yKeys[listIndex] = py;

listIndex++;
lastTime = currentTime;
Expand Down Expand Up @@ -1055,16 +1055,16 @@ public struct Pair {
List<Keyframe> keys = new List<Keyframe>();
keys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] + boneDataOffset, 0, 0));

int listIndex = 1;
int frameIndex = 1;
int listIndex = 0;
int frameIndex = 0;
int f = TranslateXTimeline.ENTRIES;
float[] frames = timeline.Frames;
skeleton.SetToSetupPose();
float lastTime = 0;
while (currentTime < endTime) {
int pIndex = listIndex - 1;
int pIndex = listIndex;

float curveType = timeline.GetCurveType(frameIndex - 1);
float curveType = timeline.GetCurveType(frameIndex);
if (curveType == 0) {
//linear
Keyframe p = keys[pIndex];
Expand Down Expand Up @@ -1112,13 +1112,13 @@ public struct Pair {

timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In);

p = keys[listIndex - 1];
p = keys[listIndex];
float boneOffset = isXTimeline ? bone.X : bone.Y;
float valueOut = (boneOffset - p.value) / (currentTime - p.time);
p.outTangent = valueOut;
keys.Add(new Keyframe(currentTime, boneOffset, valueOut, 0));

keys[listIndex - 1] = p;
keys[listIndex] = p;

listIndex++;
lastTime = currentTime;
Expand Down Expand Up @@ -1155,15 +1155,15 @@ public struct Pair {
xKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] * boneData.ScaleX, 0, 0));
yKeys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[2] * boneData.ScaleY, 0, 0));

int listIndex = 1;
int frameIndex = 1;
int listIndex = 0;
int frameIndex = 0;
int f = ScaleTimeline.ENTRIES;
float[] frames = timeline.Frames;
skeleton.SetToSetupPose();
float lastTime = 0;
while (currentTime < endTime) {
int pIndex = listIndex - 1;
float curveType = timeline.GetCurveType(frameIndex - 1);
int pIndex = listIndex;
float curveType = timeline.GetCurveType(frameIndex);
if (curveType == 0) {
//linear
Keyframe px = xKeys[pIndex];
Expand Down Expand Up @@ -1234,8 +1234,8 @@ public struct Pair {

timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In);

px = xKeys[listIndex - 1];
py = yKeys[listIndex - 1];
px = xKeys[listIndex];
py = yKeys[listIndex];

float xOut = (bone.ScaleX - px.value) / (currentTime - px.time);
float yOut = (bone.ScaleY - py.value) / (currentTime - py.time);
Expand All @@ -1246,8 +1246,8 @@ public struct Pair {
xKeys.Add(new Keyframe(currentTime, bone.ScaleX, xOut, 0));
yKeys.Add(new Keyframe(currentTime, bone.ScaleY, yOut, 0));

xKeys[listIndex - 1] = px;
yKeys[listIndex - 1] = py;
xKeys[listIndex] = px;
yKeys[listIndex] = py;

listIndex++;
lastTime = currentTime;
Expand Down Expand Up @@ -1286,15 +1286,15 @@ public struct Pair {
List<Keyframe> keys = new List<Keyframe>();
keys.Add(new Keyframe(timeline.Frames[0], timeline.Frames[1] * boneDataOffset, 0, 0));

int listIndex = 1;
int frameIndex = 1;
int listIndex = 0;
int frameIndex = 0;
int f = ScaleXTimeline.ENTRIES;
float[] frames = timeline.Frames;
skeleton.SetToSetupPose();
float lastTime = 0;
while (currentTime < endTime) {
int pIndex = listIndex - 1;
float curveType = timeline.GetCurveType(frameIndex - 1);
int pIndex = listIndex;
float curveType = timeline.GetCurveType(frameIndex);
if (curveType == 0) {
//linear
Keyframe p = keys[pIndex];
Expand Down Expand Up @@ -1340,14 +1340,14 @@ public struct Pair {

timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In);

p = keys[listIndex - 1];
p = keys[listIndex];

float boneScale = isXTimeline ? bone.ScaleX : bone.ScaleY;
float valueOut = (boneScale - p.value) / (currentTime - p.time);
p.outTangent = valueOut;
keys.Add(new Keyframe(currentTime, boneScale, valueOut, 0));

keys[listIndex - 1] = p;
keys[listIndex] = p;

listIndex++;
lastTime = currentTime;
Expand Down Expand Up @@ -1382,16 +1382,16 @@ public struct Pair {

keys.Add(new Keyframe(timeline.Frames[0], rotation, 0, 0));

int listIndex = 1;
int frameIndex = 1;
int listIndex = 0;
int frameIndex = 0;
int f = 2;
float[] frames = timeline.Frames;
skeleton.SetToSetupPose();
float lastTime = 0;
float angle = rotation;
while (currentTime < endTime) {
int pIndex = listIndex - 1;
float curveType = timeline.GetCurveType(frameIndex - 1);
int pIndex = listIndex;
float curveType = timeline.GetCurveType(frameIndex);

if (curveType == 0) {
//linear
Expand Down Expand Up @@ -1464,7 +1464,7 @@ public struct Pair {

timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In);
skeleton.UpdateWorldTransform();
pk = keys[listIndex - 1];
pk = keys[listIndex];

rotation = bone.Rotation;
angle += Mathf.DeltaAngle(angle, rotation);
Expand All @@ -1476,7 +1476,7 @@ public struct Pair {

keys.Add(new Keyframe(currentTime, r, rOut, 0));

keys[listIndex - 1] = pk;
keys[listIndex] = pk;

listIndex++;
lastTime = currentTime;
Expand Down Expand Up @@ -1582,10 +1582,7 @@ public struct Pair {
}
}

float currentTime = timeline.Frames[0];
float endTime = frames[frames.Length - 1];
int f = 0;
while (currentTime < endTime) {
for (int f = 0, frameCount = frames.Length; f < frameCount; ++f) {
float time = frames[f];

int frameIndex = Search(frames, time);
Expand All @@ -1602,9 +1599,6 @@ public struct Pair {
}
}
}

currentTime = time;
f += 1;
}

foreach (KeyValuePair<string, AnimationCurve> pair in curveTable) {
Expand Down

0 comments on commit 6ec6c4c

Please sign in to comment.