| 78 | #if USE_EDITOR |
| 79 | |
| 80 | void Animation::LoadTimeline(BytesContainer& result) const |
| 81 | { |
| 82 | result.Release(); |
| 83 | if (!IsLoaded()) |
| 84 | return; |
| 85 | MemoryWriteStream stream(4096); |
| 86 | |
| 87 | // Version |
| 88 | stream.WriteInt32(4); |
| 89 | |
| 90 | // Meta |
| 91 | float fps = (float)Data.FramesPerSecond; |
| 92 | const float fpsInv = 1.0f / fps; |
| 93 | stream.Write(fps); |
| 94 | stream.Write((int32)Data.Duration); |
| 95 | int32 tracksCount = Data.Channels.Count() + NestedAnims.Count() + Events.Count(); |
| 96 | for (auto& channel : Data.Channels) |
| 97 | { |
| 98 | tracksCount += |
| 99 | (channel.Position.GetKeyframes().HasItems() ? 1 : 0) + |
| 100 | (channel.Rotation.GetKeyframes().HasItems() ? 1 : 0) + |
| 101 | (channel.Scale.GetKeyframes().HasItems() ? 1 : 0); |
| 102 | } |
| 103 | stream.Write(tracksCount); |
| 104 | |
| 105 | // Tracks |
| 106 | int32 trackIndex = 0; |
| 107 | for (int32 i = 0; i < Data.Channels.Count(); i++) |
| 108 | { |
| 109 | auto& channel = Data.Channels[i]; |
| 110 | const int32 childrenCount = |
| 111 | (channel.Position.GetKeyframes().HasItems() ? 1 : 0) + |
| 112 | (channel.Rotation.GetKeyframes().HasItems() ? 1 : 0) + |
| 113 | (channel.Scale.GetKeyframes().HasItems() ? 1 : 0); |
| 114 | |
| 115 | // Animation Channel track |
| 116 | stream.Write((byte)17); // Track Type |
| 117 | stream.Write((byte)0); // Track Flags |
| 118 | stream.Write(-1); // Parent Index |
| 119 | stream.Write(childrenCount); // Children Count |
| 120 | stream.Write(channel.NodeName, -13); // Name |
| 121 | stream.Write(Color32::White); // Color |
| 122 | const int32 parentIndex = trackIndex++; |
| 123 | |
| 124 | auto& position = channel.Position.GetKeyframes(); |
| 125 | if (position.HasItems()) |
| 126 | { |
| 127 | // Animation Channel Data track (position) |
| 128 | stream.Write((byte)18); // Track Type |
| 129 | stream.Write((byte)0); // Track Flags |
| 130 | stream.Write(parentIndex); // Parent Index |
| 131 | stream.Write(0); // Children Count |
| 132 | stream.Write(String::Format(TEXT("Track_{0}_Position"), i), -13); // Name |
| 133 | stream.Write(Color32::White); // Color |
| 134 | stream.Write((byte)0); // Type |
| 135 | stream.Write(position.Count()); // Keyframes Count |
| 136 | for (auto& k : position) |
| 137 | { |
nothing calls this directly
no test coverage detected