override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
TransformConstraint constraint = skeleton.transformConstraints.Items[transformConstraintIndex];
float[] frames = this.frames;
if (time < frames[0]) {
if (setupPose) {
var data = constraint.data;
constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix;
}
return;
}
float rotate, translate, scale, shear;
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
int i = frames.Length;
rotate = frames[i + PREV_ROTATE];
translate = frames[i + PREV_TRANSLATE];
scale = frames[i + PREV_SCALE];
shear = frames[i + PREV_SHEAR];
} else {
// Interpolate between the previous frame and the current frame.
int frame = Animation.BinarySearch(frames, time, ENTRIES);
rotate = frames[frame + PREV_ROTATE];
translate = frames[frame + PREV_TRANSLATE];
scale = frames[frame + PREV_SCALE];
shear = frames[frame + PREV_SHEAR];
float frameTime = frames[frame];
float percent = GetCurvePercent(frame / ENTRIES - 1,
1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime));
rotate += (frames[frame + ROTATE] - rotate) * percent;
translate += (frames[frame + TRANSLATE] - translate) * percent;
scale += (frames[frame + SCALE] - scale) * percent;
shear += (frames[frame + SHEAR] - shear) * percent;
}
if (setupPose) {
TransformConstraintData data = constraint.data;
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha;
} else {
constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
constraint.translateMix += (translate - constraint.translateMix) * alpha;
constraint.scaleMix += (scale - constraint.scaleMix) * alpha;
constraint.shearMix += (shear - constraint.shearMix) * alpha;
}
}
}