Ejemplo n.º 1
0
        public Animatable(IEnumerable <KeyFrame <T> > keyFrames, int?propertyIndex)
        {
            KeyFrames = keyFrames.ToArray();

            // There must be a least one key frame otherwise this constructor should not have been called.
            InitialValue = KeyFrames[0].Value;

            if (KeyFrames.Count == 1)
            {
                // There's only one key frame so the value never changes. We have
                // saved the value in InitialValue. Might as well ditch the key frames.
                KeyFrames = Array.Empty <KeyFrame <T> >();
            }

            PropertyIndex = propertyIndex;

            Debug.Assert(KeyFrames.All(kf => kf != null), "Precondition");
        }
Ejemplo n.º 2
0
        private void WriteKeyFrames(BinaryWriter writer)
        {
            switch (KeyFrameType)
            {
            case RwKeyFrameType.Uncompressed:
            {
                WriteUncompressedKeyFrames(writer);
            }
            break;

            case RwKeyFrameType.Compressed:
            {
                if (mCachedCompressedKeyframeData != null && KeyFrames.All(x => !x.Dirty))
                {
                    // Sync time in case they were modified
                    for (int i = 0; i < mCachedCompressedKeyframeData.KeyFrames.Count; i++)
                    {
                        mCachedCompressedKeyframeData.KeyFrames[i].Time = KeyFrames[i].Time;
                    }

                    WriteCompressedKeyFrames(writer, mCachedCompressedKeyframeData.KeyFrames, mCachedCompressedKeyframeData.CustomData);
                }
                else
                {
                    CompressKeyFrames(out List <RwCompressedKeyFrame> compressedKeyFrames,
                                      out RwCompressedKeyFrameCustomData customData);

                    WriteCompressedKeyFrames(writer, compressedKeyFrames, customData);
                }
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }