Update read and write streaming api to use the newest format

This commit is contained in:
Wojtek Figat
2024-12-29 23:00:40 +01:00
parent fee0ab74ff
commit 668f3fa68d
29 changed files with 444 additions and 378 deletions

View File

@@ -166,7 +166,7 @@ void CookAssetsStep::CacheData::Load(CookingData& data)
Guid id; Guid id;
file->Read(id); file->Read(id);
String typeName; String typeName;
file->ReadString(&typeName); file->Read(typeName);
DateTime fileModified; DateTime fileModified;
file->Read(fileModified); file->Read(fileModified);
int32 fileDependenciesCount; int32 fileDependenciesCount;
@@ -176,7 +176,7 @@ void CookAssetsStep::CacheData::Load(CookingData& data)
for (int32 j = 0; j < fileDependenciesCount; j++) for (int32 j = 0; j < fileDependenciesCount; j++)
{ {
Pair<String, DateTime>& f = fileDependencies[j]; Pair<String, DateTime>& f = fileDependencies[j];
file->ReadString(&f.First, 10); file->Read(f.First, 10);
file->Read(f.Second); file->Read(f.Second);
} }
@@ -311,9 +311,9 @@ void CookAssetsStep::CacheData::Save(CookingData& data)
{ {
auto& e = i->Value; auto& e = i->Value;
file->Write(e.ID); file->Write(e.ID);
file->WriteString(e.TypeName); file->Write(e.TypeName);
file->Write(e.FileModified); file->Write(e.FileModified);
file->WriteInt32(e.FileDependencies.Count()); file->Write(e.FileDependencies.Count());
for (auto& f : e.FileDependencies) for (auto& f : e.FileDependencies)
{ {
file->Write(f.First, 10); file->Write(f.First, 10);
@@ -1249,7 +1249,7 @@ bool CookAssetsStep::Perform(CookingData& data)
*(int32*)(bytes.Get() + 804) = contentKey; *(int32*)(bytes.Get() + 804) = contentKey;
*(Guid*)(bytes.Get() + 808) = gameSettings->SplashScreen; *(Guid*)(bytes.Get() + 808) = gameSettings->SplashScreen;
Encryption::EncryptBytes(bytes.Get(), bytes.Count()); Encryption::EncryptBytes(bytes.Get(), bytes.Count());
stream->WriteArray(bytes); stream->Write(bytes);
Delete(stream); Delete(stream);
} }

View File

@@ -112,19 +112,19 @@ Asset::LoadResult SceneAnimation::load()
// Load properties // Load properties
int32 version; int32 version;
stream.ReadInt32(&version); stream.Read(version);
switch (version) switch (version)
{ {
case 2: // [Deprecated in 2020 expires on 03.09.2023] case 2: // [Deprecated in 2020 expires on 03.09.2023]
case 3: // [Deprecated on 03.09.2021 expires on 03.09.2023] case 3: // [Deprecated on 03.09.2021 expires on 03.09.2023]
case 4: case 4:
{ {
stream.ReadFloat(&FramesPerSecond); stream.Read(FramesPerSecond);
stream.ReadInt32(&DurationFrames); stream.Read(DurationFrames);
// Load tracks // Load tracks
int32 tracksCount; int32 tracksCount;
stream.ReadInt32(&tracksCount); stream.Read(tracksCount);
Tracks.Resize(tracksCount, false); Tracks.Resize(tracksCount, false);
for (int32 i = 0; i < tracksCount; i++) for (int32 i = 0; i < tracksCount; i++)
{ {
@@ -134,7 +134,7 @@ Asset::LoadResult SceneAnimation::load()
track.Flag = (Track::Flags)stream.ReadByte(); track.Flag = (Track::Flags)stream.ReadByte();
stream.ReadInt32(&track.ParentIndex); stream.ReadInt32(&track.ParentIndex);
stream.ReadInt32(&track.ChildrenCount); stream.ReadInt32(&track.ChildrenCount);
stream.ReadString(&track.Name, -13); stream.Read(track.Name, -13);
stream.Read(track.Color); stream.Read(track.Color);
track.Disabled = (int32)track.Flag & (int32)Track::Flags::Mute || (track.ParentIndex != -1 && Tracks[track.ParentIndex].Disabled); track.Disabled = (int32)track.Flag & (int32)Track::Flags::Mute || (track.ParentIndex != -1 && Tracks[track.ParentIndex].Disabled);
track.TrackStateIndex = -1; track.TrackStateIndex = -1;

View File

@@ -86,15 +86,17 @@ void Animation::LoadTimeline(BytesContainer& result) const
// Meta // Meta
float fps = (float)Data.FramesPerSecond; float fps = (float)Data.FramesPerSecond;
const float fpsInv = 1.0f / fps; const float fpsInv = 1.0f / fps;
stream.WriteFloat(fps); stream.Write(fps);
stream.WriteInt32((int32)Data.Duration); stream.Write((int32)Data.Duration);
int32 tracksCount = Data.Channels.Count() + NestedAnims.Count() + Events.Count(); int32 tracksCount = Data.Channels.Count() + NestedAnims.Count() + Events.Count();
for (auto& channel : Data.Channels) for (auto& channel : Data.Channels)
{
tracksCount += tracksCount +=
(channel.Position.GetKeyframes().HasItems() ? 1 : 0) + (channel.Position.GetKeyframes().HasItems() ? 1 : 0) +
(channel.Rotation.GetKeyframes().HasItems() ? 1 : 0) + (channel.Rotation.GetKeyframes().HasItems() ? 1 : 0) +
(channel.Scale.GetKeyframes().HasItems() ? 1 : 0); (channel.Scale.GetKeyframes().HasItems() ? 1 : 0);
stream.WriteInt32(tracksCount); }
stream.Write(tracksCount);
// Tracks // Tracks
int32 trackIndex = 0; int32 trackIndex = 0;
@@ -107,11 +109,11 @@ void Animation::LoadTimeline(BytesContainer& result) const
(channel.Scale.GetKeyframes().HasItems() ? 1 : 0); (channel.Scale.GetKeyframes().HasItems() ? 1 : 0);
// Animation Channel track // Animation Channel track
stream.WriteByte(17); // Track Type stream.Write((byte)17); // Track Type
stream.WriteByte(0); // Track Flags stream.Write((byte)0); // Track Flags
stream.WriteInt32(-1); // Parent Index stream.Write(-1); // Parent Index
stream.WriteInt32(childrenCount); // Children Count stream.Write(childrenCount); // Children Count
stream.WriteString(channel.NodeName, -13); // Name stream.Write(channel.NodeName, -13); // Name
stream.Write(Color32::White); // Color stream.Write(Color32::White); // Color
const int32 parentIndex = trackIndex++; const int32 parentIndex = trackIndex++;
@@ -119,17 +121,17 @@ void Animation::LoadTimeline(BytesContainer& result) const
if (position.HasItems()) if (position.HasItems())
{ {
// Animation Channel Data track (position) // Animation Channel Data track (position)
stream.WriteByte(18); // Track Type stream.Write((byte)18); // Track Type
stream.WriteByte(0); // Track Flags stream.Write((byte)0); // Track Flags
stream.WriteInt32(parentIndex); // Parent Index stream.Write(parentIndex); // Parent Index
stream.WriteInt32(0); // Children Count stream.Write(0); // Children Count
stream.WriteString(String::Format(TEXT("Track_{0}_Position"), i), -13); // Name stream.Write(String::Format(TEXT("Track_{0}_Position"), i), -13); // Name
stream.Write(Color32::White); // Color stream.Write(Color32::White); // Color
stream.WriteByte(0); // Type stream.Write((byte)0); // Type
stream.WriteInt32(position.Count()); // Keyframes Count stream.Write(position.Count()); // Keyframes Count
for (auto& k : position) for (auto& k : position)
{ {
stream.WriteFloat(k.Time * fpsInv); stream.Write(k.Time * fpsInv);
stream.Write(k.Value); stream.Write(k.Value);
} }
trackIndex++; trackIndex++;
@@ -139,17 +141,17 @@ void Animation::LoadTimeline(BytesContainer& result) const
if (rotation.HasItems()) if (rotation.HasItems())
{ {
// Animation Channel Data track (rotation) // Animation Channel Data track (rotation)
stream.WriteByte(18); // Track Type stream.Write((byte)18); // Track Type
stream.WriteByte(0); // Track Flags stream.Write((byte)0); // Track Flags
stream.WriteInt32(parentIndex); // Parent Index stream.Write(parentIndex); // Parent Index
stream.WriteInt32(0); // Children Count stream.Write(0); // Children Count
stream.WriteString(String::Format(TEXT("Track_{0}_Rotation"), i), -13); // Name stream.Write(String::Format(TEXT("Track_{0}_Rotation"), i), -13); // Name
stream.Write(Color32::White); // Color stream.Write(Color32::White); // Color
stream.WriteByte(1); // Type stream.Write((byte)1); // Type
stream.WriteInt32(rotation.Count()); // Keyframes Count stream.Write(rotation.Count()); // Keyframes Count
for (auto& k : rotation) for (auto& k : rotation)
{ {
stream.WriteFloat(k.Time * fpsInv); stream.Write(k.Time * fpsInv);
stream.Write(k.Value); stream.Write(k.Value);
} }
trackIndex++; trackIndex++;
@@ -159,17 +161,17 @@ void Animation::LoadTimeline(BytesContainer& result) const
if (scale.HasItems()) if (scale.HasItems())
{ {
// Animation Channel Data track (scale) // Animation Channel Data track (scale)
stream.WriteByte(18); // Track Type stream.Write((byte)18); // Track Type
stream.WriteByte(0); // Track Flags stream.Write((byte)0); // Track Flags
stream.WriteInt32(parentIndex); // Parent Index stream.Write(parentIndex); // Parent Index
stream.WriteInt32(0); // Children Count stream.Write(0); // Children Count
stream.WriteString(String::Format(TEXT("Track_{0}_Scale"), i), -13); // Name stream.Write(String::Format(TEXT("Track_{0}_Scale"), i), -13); // Name
stream.Write(Color32::White); // Color stream.Write(Color32::White); // Color
stream.WriteByte(2); // Type stream.Write((byte)2); // Type
stream.WriteInt32(scale.Count()); // Keyframes Count stream.Write(scale.Count()); // Keyframes Count
for (auto& k : scale) for (auto& k : scale)
{ {
stream.WriteFloat(k.Time * fpsInv); stream.Write(k.Time * fpsInv);
stream.Write(k.Value); stream.Write(k.Value);
} }
trackIndex++; trackIndex++;
@@ -186,33 +188,33 @@ void Animation::LoadTimeline(BytesContainer& result) const
Guid id = nestedAnim.Anim.GetID(); Guid id = nestedAnim.Anim.GetID();
// Nested Animation track // Nested Animation track
stream.WriteByte(20); // Track Type stream.Write((byte)20); // Track Type
stream.WriteByte(flags); // Track Flags stream.Write(flags); // Track Flags
stream.WriteInt32(-1); // Parent Index stream.Write(-1); // Parent Index
stream.WriteInt32(0); // Children Count stream.Write(0); // Children Count
stream.WriteString(e.First, -13); // Name stream.Write(e.First, -13); // Name
stream.Write(Color32::White); // Color stream.Write(Color32::White); // Color
stream.Write(id); stream.Write(id);
stream.WriteFloat(nestedAnim.Time); stream.Write(nestedAnim.Time);
stream.WriteFloat(nestedAnim.Duration); stream.Write(nestedAnim.Duration);
stream.WriteFloat(nestedAnim.Speed); stream.Write(nestedAnim.Speed);
stream.WriteFloat(nestedAnim.StartTime); stream.Write(nestedAnim.StartTime);
} }
for (auto& e : Events) for (auto& e : Events)
{ {
// Animation Event track // Animation Event track
stream.WriteByte(19); // Track Type stream.Write((byte)19); // Track Type
stream.WriteByte(0); // Track Flags stream.Write((byte)0); // Track Flags
stream.WriteInt32(-1); // Parent Index stream.Write(-1); // Parent Index
stream.WriteInt32(0); // Children Count stream.Write(0); // Children Count
stream.WriteString(e.First, -13); // Name stream.Write(e.First, -13); // Name
stream.Write(Color32::White); // Color stream.Write(Color32::White); // Color
stream.WriteInt32(e.Second.GetKeyframes().Count()); // Events Count stream.Write(e.Second.GetKeyframes().Count()); // Events Count
for (const auto& k : e.Second.GetKeyframes()) for (const auto& k : e.Second.GetKeyframes())
{ {
stream.WriteFloat(k.Time); stream.Write(k.Time);
stream.WriteFloat(k.Value.Duration); stream.Write(k.Value.Duration);
stream.WriteStringAnsi(k.Value.TypeName, 13); stream.Write(k.Value.TypeName, 13);
stream.WriteJson(k.Value.Instance); stream.WriteJson(k.Value.Instance);
} }
} }
@@ -237,7 +239,7 @@ bool Animation::SaveTimeline(BytesContainer& data)
// Version // Version
int32 version; int32 version;
stream.ReadInt32(&version); stream.Read(version);
switch (version) switch (version)
{ {
case 3: // [Deprecated on 03.09.2021 expires on 03.09.2023] case 3: // [Deprecated on 03.09.2021 expires on 03.09.2023]
@@ -245,13 +247,13 @@ bool Animation::SaveTimeline(BytesContainer& data)
{ {
// Meta // Meta
float fps; float fps;
stream.ReadFloat(&fps); stream.Read(fps);
Data.FramesPerSecond = static_cast<double>(fps); Data.FramesPerSecond = static_cast<double>(fps);
int32 duration; int32 duration;
stream.ReadInt32(&duration); stream.Read(duration);
Data.Duration = static_cast<double>(duration); Data.Duration = static_cast<double>(duration);
int32 tracksCount; int32 tracksCount;
stream.ReadInt32(&tracksCount); stream.Read(tracksCount);
// Tracks // Tracks
Data.Channels.Clear(); Data.Channels.Clear();
@@ -264,10 +266,10 @@ bool Animation::SaveTimeline(BytesContainer& data)
const byte trackType = stream.ReadByte(); const byte trackType = stream.ReadByte();
const byte trackFlags = stream.ReadByte(); const byte trackFlags = stream.ReadByte();
int32 parentIndex, childrenCount; int32 parentIndex, childrenCount;
stream.ReadInt32(&parentIndex); stream.Read(parentIndex);
stream.ReadInt32(&childrenCount); stream.Read(childrenCount);
String name; String name;
stream.ReadString(&name, -13); stream.Read(name, -13);
Color32 color; Color32 color;
stream.Read(color); stream.Read(color);
switch (trackType) switch (trackType)
@@ -286,7 +288,7 @@ bool Animation::SaveTimeline(BytesContainer& data)
// Animation Channel Data track // Animation Channel Data track
const byte type = stream.ReadByte(); const byte type = stream.ReadByte();
int32 keyframesCount; int32 keyframesCount;
stream.ReadInt32(&keyframesCount); stream.Read(keyframesCount);
int32 channelIndex; int32 channelIndex;
if (!animationChannelTrackIndexToChannelIndex.TryGet(parentIndex, channelIndex)) if (!animationChannelTrackIndexToChannelIndex.TryGet(parentIndex, channelIndex))
{ {
@@ -301,7 +303,7 @@ bool Animation::SaveTimeline(BytesContainer& data)
for (int32 i = 0; i < keyframesCount; i++) for (int32 i = 0; i < keyframesCount; i++)
{ {
LinearCurveKeyframe<Float3>& k = channel.Position.GetKeyframes()[i]; LinearCurveKeyframe<Float3>& k = channel.Position.GetKeyframes()[i];
stream.ReadFloat(&k.Time); stream.Read(k.Time);
k.Time *= fps; k.Time *= fps;
stream.Read(k.Value); stream.Read(k.Value);
} }
@@ -311,7 +313,7 @@ bool Animation::SaveTimeline(BytesContainer& data)
for (int32 i = 0; i < keyframesCount; i++) for (int32 i = 0; i < keyframesCount; i++)
{ {
LinearCurveKeyframe<Quaternion>& k = channel.Rotation.GetKeyframes()[i]; LinearCurveKeyframe<Quaternion>& k = channel.Rotation.GetKeyframes()[i];
stream.ReadFloat(&k.Time); stream.Read(k.Time);
k.Time *= fps; k.Time *= fps;
stream.Read(k.Value); stream.Read(k.Value);
} }
@@ -321,7 +323,7 @@ bool Animation::SaveTimeline(BytesContainer& data)
for (int32 i = 0; i < keyframesCount; i++) for (int32 i = 0; i < keyframesCount; i++)
{ {
LinearCurveKeyframe<Float3>& k = channel.Scale.GetKeyframes()[i]; LinearCurveKeyframe<Float3>& k = channel.Scale.GetKeyframes()[i];
stream.ReadFloat(&k.Time); stream.Read(k.Time);
k.Time *= fps; k.Time *= fps;
stream.Read(k.Value); stream.Read(k.Value);
} }
@@ -340,9 +342,9 @@ bool Animation::SaveTimeline(BytesContainer& data)
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++)
{ {
auto& k = eventTrack.Second.GetKeyframes()[i]; auto& k = eventTrack.Second.GetKeyframes()[i];
stream.ReadFloat(&k.Time); stream.Read(k.Time);
stream.ReadFloat(&k.Value.Duration); stream.Read(k.Value.Duration);
stream.ReadStringAnsi(&k.Value.TypeName, 13); stream.Read(k.Value.TypeName, 13);
const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(k.Value.TypeName); const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(k.Value.TypeName);
k.Value.Instance = NewObject<AnimEvent>(typeHandle); k.Value.Instance = NewObject<AnimEvent>(typeHandle);
stream.ReadJson(k.Value.Instance); stream.ReadJson(k.Value.Instance);
@@ -367,10 +369,10 @@ bool Animation::SaveTimeline(BytesContainer& data)
auto& nestedAnim = nestedTrack.Second; auto& nestedAnim = nestedTrack.Second;
Guid id; Guid id;
stream.Read(id); stream.Read(id);
stream.ReadFloat(&nestedAnim.Time); stream.Read(nestedAnim.Time);
stream.ReadFloat(&nestedAnim.Duration); stream.Read(nestedAnim.Duration);
stream.ReadFloat(&nestedAnim.Speed); stream.Read(nestedAnim.Speed);
stream.ReadFloat(&nestedAnim.StartTime); stream.Read(nestedAnim.StartTime);
nestedAnim.Anim = id; nestedAnim.Anim = id;
nestedAnim.Enabled = (trackFlags & (byte)SceneAnimation::Track::Flags::Mute) == 0; nestedAnim.Enabled = (trackFlags & (byte)SceneAnimation::Track::Flags::Mute) == 0;
nestedAnim.Loop = (trackFlags & (byte)SceneAnimation::Track::Flags::Loop) != 0; nestedAnim.Loop = (trackFlags & (byte)SceneAnimation::Track::Flags::Loop) != 0;
@@ -415,18 +417,18 @@ bool Animation::Save(const StringView& path)
MemoryWriteStream stream(4096); MemoryWriteStream stream(4096);
// Info // Info
stream.WriteInt32(103); stream.Write(103);
stream.WriteDouble(Data.Duration); stream.Write(Data.Duration);
stream.WriteDouble(Data.FramesPerSecond); stream.Write(Data.FramesPerSecond);
stream.WriteByte((byte)Data.RootMotionFlags); stream.Write((byte)Data.RootMotionFlags);
stream.WriteString(Data.RootNodeName, 13); stream.Write(Data.RootNodeName, 13);
// Animation channels // Animation channels
stream.WriteInt32(Data.Channels.Count()); stream.WriteInt32(Data.Channels.Count());
for (int32 i = 0; i < Data.Channels.Count(); i++) for (int32 i = 0; i < Data.Channels.Count(); i++)
{ {
auto& anim = Data.Channels[i]; auto& anim = Data.Channels[i];
stream.WriteString(anim.NodeName, 172); stream.Write(anim.NodeName, 172);
Serialization::Serialize(stream, anim.Position); Serialization::Serialize(stream, anim.Position);
Serialization::Serialize(stream, anim.Rotation); Serialization::Serialize(stream, anim.Rotation);
Serialization::Serialize(stream, anim.Scale); Serialization::Serialize(stream, anim.Scale);
@@ -437,13 +439,13 @@ bool Animation::Save(const StringView& path)
for (int32 i = 0; i < Events.Count(); i++) for (int32 i = 0; i < Events.Count(); i++)
{ {
auto& e = Events[i]; auto& e = Events[i];
stream.WriteString(e.First, 172); stream.Write(e.First, 172);
stream.WriteInt32(e.Second.GetKeyframes().Count()); stream.Write(e.Second.GetKeyframes().Count());
for (const auto& k : e.Second.GetKeyframes()) for (const auto& k : e.Second.GetKeyframes())
{ {
stream.WriteFloat(k.Time); stream.Write(k.Time);
stream.WriteFloat(k.Value.Duration); stream.Write(k.Value.Duration);
stream.WriteStringAnsi(k.Value.TypeName, 17); stream.Write(k.Value.TypeName, 17);
stream.WriteJson(k.Value.Instance); stream.WriteJson(k.Value.Instance);
} }
} }
@@ -453,7 +455,7 @@ bool Animation::Save(const StringView& path)
for (int32 i = 0; i < NestedAnims.Count(); i++) for (int32 i = 0; i < NestedAnims.Count(); i++)
{ {
auto& e = NestedAnims[i]; auto& e = NestedAnims[i];
stream.WriteString(e.First, 172); stream.Write(e.First, 172);
auto& nestedAnim = e.Second; auto& nestedAnim = e.Second;
Guid id = nestedAnim.Anim.GetID(); Guid id = nestedAnim.Anim.GetID();
byte flags = 0; byte flags = 0;
@@ -461,12 +463,12 @@ bool Animation::Save(const StringView& path)
flags |= 1; flags |= 1;
if (nestedAnim.Loop) if (nestedAnim.Loop)
flags |= 2; flags |= 2;
stream.WriteByte(flags); stream.Write(flags);
stream.Write(id); stream.Write(id);
stream.WriteFloat(nestedAnim.Time); stream.Write(nestedAnim.Time);
stream.WriteFloat(nestedAnim.Duration); stream.Write(nestedAnim.Duration);
stream.WriteFloat(nestedAnim.Speed); stream.Write(nestedAnim.Speed);
stream.WriteFloat(nestedAnim.StartTime); stream.Write(nestedAnim.StartTime);
} }
// Set data to the chunk asset // Set data to the chunk asset
@@ -563,24 +565,24 @@ Asset::LoadResult Animation::load()
switch (headerVersion) switch (headerVersion)
{ {
case 103: case 103:
stream.ReadInt32(&headerVersion); stream.Read(headerVersion);
stream.ReadDouble(&Data.Duration); stream.Read(Data.Duration);
stream.ReadDouble(&Data.FramesPerSecond); stream.Read(Data.FramesPerSecond);
stream.ReadByte((byte*)&Data.RootMotionFlags); stream.Read((byte&)Data.RootMotionFlags);
stream.ReadString(&Data.RootNodeName, 13); stream.Read(Data.RootNodeName, 13);
break; break;
case 100: case 100:
case 101: case 101:
case 102: case 102:
stream.ReadInt32(&headerVersion); stream.Read(headerVersion);
stream.ReadDouble(&Data.Duration); stream.Read(Data.Duration);
stream.ReadDouble(&Data.FramesPerSecond); stream.Read(Data.FramesPerSecond);
Data.RootMotionFlags = stream.ReadBool() ? AnimationRootMotionFlags::RootPositionXZ : AnimationRootMotionFlags::None; Data.RootMotionFlags = stream.ReadBool() ? AnimationRootMotionFlags::RootPositionXZ : AnimationRootMotionFlags::None;
stream.ReadString(&Data.RootNodeName, 13); stream.Read(Data.RootNodeName, 13);
break; break;
default: default:
stream.ReadDouble(&Data.Duration); stream.Read(Data.Duration);
stream.ReadDouble(&Data.FramesPerSecond); stream.Read(Data.FramesPerSecond);
break; break;
} }
if (Data.Duration < ZeroTolerance || Data.FramesPerSecond < ZeroTolerance) if (Data.Duration < ZeroTolerance || Data.FramesPerSecond < ZeroTolerance)
@@ -597,7 +599,7 @@ Asset::LoadResult Animation::load()
{ {
auto& anim = Data.Channels[i]; auto& anim = Data.Channels[i];
stream.ReadString(&anim.NodeName, 172); stream.Read(anim.NodeName, 172);
bool failed = Serialization::Deserialize(stream, anim.Position); bool failed = Serialization::Deserialize(stream, anim.Position);
failed |= Serialization::Deserialize(stream, anim.Rotation); failed |= Serialization::Deserialize(stream, anim.Rotation);
failed |= Serialization::Deserialize(stream, anim.Scale); failed |= Serialization::Deserialize(stream, anim.Scale);
@@ -613,7 +615,7 @@ Asset::LoadResult Animation::load()
if (headerVersion >= 101) if (headerVersion >= 101)
{ {
int32 eventTracksCount; int32 eventTracksCount;
stream.ReadInt32(&eventTracksCount); stream.Read(eventTracksCount);
Events.Resize(eventTracksCount, false); Events.Resize(eventTracksCount, false);
#if !USE_EDITOR #if !USE_EDITOR
StringAnsi typeName; StringAnsi typeName;
@@ -621,18 +623,18 @@ Asset::LoadResult Animation::load()
for (int32 i = 0; i < eventTracksCount; i++) for (int32 i = 0; i < eventTracksCount; i++)
{ {
auto& e = Events[i]; auto& e = Events[i];
stream.ReadString(&e.First, 172); stream.Read(e.First, 172);
int32 eventsCount; int32 eventsCount;
stream.ReadInt32(&eventsCount); stream.Read(eventsCount);
e.Second.GetKeyframes().Resize(eventsCount); e.Second.GetKeyframes().Resize(eventsCount);
for (auto& k : e.Second.GetKeyframes()) for (auto& k : e.Second.GetKeyframes())
{ {
stream.ReadFloat(&k.Time); stream.Read(k.Time);
stream.ReadFloat(&k.Value.Duration); stream.Read(k.Value.Duration);
#if USE_EDITOR #if USE_EDITOR
StringAnsi& typeName = k.Value.TypeName; StringAnsi& typeName = k.Value.TypeName;
#endif #endif
stream.ReadStringAnsi(&typeName, 17); stream.Read(typeName, 17);
const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(typeName); const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(typeName);
k.Value.Instance = NewObject<AnimEvent>(typeHandle); k.Value.Instance = NewObject<AnimEvent>(typeHandle);
stream.ReadJson(k.Value.Instance); stream.ReadJson(k.Value.Instance);
@@ -656,24 +658,24 @@ Asset::LoadResult Animation::load()
if (headerVersion >= 102) if (headerVersion >= 102)
{ {
int32 nestedAnimationsCount; int32 nestedAnimationsCount;
stream.ReadInt32(&nestedAnimationsCount); stream.Read(nestedAnimationsCount);
NestedAnims.Resize(nestedAnimationsCount, false); NestedAnims.Resize(nestedAnimationsCount, false);
for (int32 i = 0; i < nestedAnimationsCount; i++) for (int32 i = 0; i < nestedAnimationsCount; i++)
{ {
auto& e = NestedAnims[i]; auto& e = NestedAnims[i];
stream.ReadString(&e.First, 172); stream.Read(e.First, 172);
auto& nestedAnim = e.Second; auto& nestedAnim = e.Second;
byte flags; byte flags;
stream.ReadByte(&flags); stream.Read(flags);
nestedAnim.Enabled = flags & 1; nestedAnim.Enabled = flags & 1;
nestedAnim.Loop = flags & 2; nestedAnim.Loop = flags & 2;
Guid id; Guid id;
stream.Read(id); stream.Read(id);
nestedAnim.Anim = id; nestedAnim.Anim = id;
stream.ReadFloat(&nestedAnim.Time); stream.Read(nestedAnim.Time);
stream.ReadFloat(&nestedAnim.Duration); stream.Read(nestedAnim.Duration);
stream.ReadFloat(&nestedAnim.Speed); stream.Read(nestedAnim.Speed);
stream.ReadFloat(&nestedAnim.StartTime); stream.Read(nestedAnim.StartTime);
} }
} }

View File

@@ -29,7 +29,7 @@ Asset::LoadResult SkeletonMask::load()
_maskedNodes.Resize(maskedNodesCount); _maskedNodes.Resize(maskedNodesCount);
for (auto& e : _maskedNodes) for (auto& e : _maskedNodes)
{ {
stream.ReadString(&e, -13); stream.Read(e, -13);
} }
Skeleton = skeletonId; Skeleton = skeletonId;
@@ -87,7 +87,7 @@ bool SkeletonMask::Save(const StringView& path)
stream.WriteInt32(_maskedNodes.Count()); stream.WriteInt32(_maskedNodes.Count());
for (auto& e : _maskedNodes) for (auto& e : _maskedNodes)
{ {
stream.WriteString(e, -13); stream.Write(e, -13);
} }
// Save // Save

View File

@@ -433,7 +433,7 @@ void VisualScriptExecutor::ProcessGroupFunction(Box* boxBase, Node* node, Value&
if (version == 4) if (version == 4)
{ {
signature.IsStatic = stream.ReadBool(); signature.IsStatic = stream.ReadBool();
stream.ReadVariantType(&signature.ReturnType); stream.Read(signature.ReturnType);
int32 signatureParamsCount; int32 signatureParamsCount;
stream.ReadInt32(&signatureParamsCount); stream.ReadInt32(&signatureParamsCount);
signature.Params.Resize(signatureParamsCount); signature.Params.Resize(signatureParamsCount);
@@ -443,7 +443,7 @@ void VisualScriptExecutor::ProcessGroupFunction(Box* boxBase, Node* node, Value&
int32 parameterNameLength; int32 parameterNameLength;
stream.ReadInt32(&parameterNameLength); stream.ReadInt32(&parameterNameLength);
stream.SetPosition(stream.GetPosition() + parameterNameLength * sizeof(Char)); stream.SetPosition(stream.GetPosition() + parameterNameLength * sizeof(Char));
stream.ReadVariantType(&param.Type); stream.Read(param.Type);
param.IsOut = stream.ReadBool(); param.IsOut = stream.ReadBool();
} }
} }
@@ -1317,13 +1317,13 @@ Asset::LoadResult VisualScript::load()
return LoadResult::MissingDataChunk; return LoadResult::MissingDataChunk;
MemoryReadStream metadataStream(metadataChunk->Get(), metadataChunk->Size()); MemoryReadStream metadataStream(metadataChunk->Get(), metadataChunk->Size());
int32 version; int32 version;
metadataStream.ReadInt32(&version); metadataStream.Read(version);
switch (version) switch (version)
{ {
case 1: case 1:
{ {
metadataStream.ReadString(&Meta.BaseTypename, 31); metadataStream.Read(Meta.BaseTypename, 31);
metadataStream.ReadInt32((int32*)&Meta.Flags); metadataStream.Read((int32&)Meta.Flags);
break; break;
} }
default: default:
@@ -1376,10 +1376,10 @@ Asset::LoadResult VisualScript::load()
{ {
case 1: case 1:
{ {
signatureStream.ReadStringAnsi(&method.Name, 71); signatureStream.Read(method.Name, 71);
method.MethodFlags = (MethodFlags)signatureStream.ReadByte(); method.MethodFlags = (MethodFlags)signatureStream.ReadByte();
method.Signature.IsStatic = ((byte)method.MethodFlags & (byte)MethodFlags::Static) != 0; method.Signature.IsStatic = ((byte)method.MethodFlags & (byte)MethodFlags::Static) != 0;
signatureStream.ReadVariantType(&method.Signature.ReturnType); signatureStream.Read(method.Signature.ReturnType);
int32 parametersCount; int32 parametersCount;
signatureStream.ReadInt32(&parametersCount); signatureStream.ReadInt32(&parametersCount);
method.Signature.Params.Resize(parametersCount); method.Signature.Params.Resize(parametersCount);
@@ -1387,8 +1387,8 @@ Asset::LoadResult VisualScript::load()
for (int32 i = 0; i < parametersCount; i++) for (int32 i = 0; i < parametersCount; i++)
{ {
auto& param = method.Signature.Params[i]; auto& param = method.Signature.Params[i];
signatureStream.ReadStringAnsi(&method.ParamNames[i], 13); signatureStream.Read(method.ParamNames[i], 13);
signatureStream.ReadVariantType(&param.Type); signatureStream.Read(param.Type);
param.IsOut = signatureStream.ReadByte() != 0; param.IsOut = signatureStream.ReadByte() != 0;
bool hasDefaultValue = signatureStream.ReadByte() != 0; bool hasDefaultValue = signatureStream.ReadByte() != 0;
} }
@@ -1699,9 +1699,9 @@ ScriptingObject* VisualScriptingBinaryModule::VisualScriptObjectSpawn(const Scri
{ {
// Special case for C# object property in Visual Script so duplicate the object instead of cloning the reference to it // Special case for C# object property in Visual Script so duplicate the object instead of cloning the reference to it
MemoryWriteStream writeStream; MemoryWriteStream writeStream;
writeStream.WriteVariant(param); writeStream.Write(param);
MemoryReadStream readStream(writeStream.GetHandle(), writeStream.GetPosition()); MemoryReadStream readStream(writeStream.GetHandle(), writeStream.GetPosition());
readStream.ReadVariant(&param); readStream.Read(param);
} }
} }
@@ -2227,9 +2227,9 @@ bool VisualScript::SaveSurface(const BytesContainer& data, const Metadata& meta)
// Set metadata // Set metadata
MemoryWriteStream metaStream(512); MemoryWriteStream metaStream(512);
{ {
metaStream.WriteInt32(1); metaStream.Write(1);
metaStream.WriteString(meta.BaseTypename, 31); metaStream.Write(meta.BaseTypename, 31);
metaStream.WriteInt32((int32)meta.Flags); metaStream.Write((int32)meta.Flags);
} }
GetOrCreateChunk(1)->Data.Copy(metaStream.GetHandle(), metaStream.GetPosition()); GetOrCreateChunk(1)->Data.Copy(metaStream.GetHandle(), metaStream.GetPosition());

View File

@@ -65,7 +65,7 @@ public:
/// <summary> /// <summary>
/// Visual Script flag types. /// Visual Script flag types.
/// </summary> /// </summary>
API_ENUM(Attributes="Flags") enum class Flags API_ENUM(Attributes="Flags") enum class Flags : int32
{ {
/// <summary> /// <summary>
/// No flags. /// No flags.

View File

@@ -43,7 +43,7 @@ void AssetsCache::Init()
// Load version // Load version
int32 version; int32 version;
stream->ReadInt32(&version); stream->Read(version);
if (version != FLAXENGINE_VERSION_BUILD) if (version != FLAXENGINE_VERSION_BUILD)
{ {
LOG(Warning, "Corrupted or not supported Asset Cache file. Version: {0}", version); LOG(Warning, "Corrupted or not supported Asset Cache file. Version: {0}", version);
@@ -52,12 +52,12 @@ void AssetsCache::Init()
// Load paths // Load paths
String enginePath, projectPath; String enginePath, projectPath;
stream->ReadString(&enginePath, -410); stream->Read(enginePath, -410);
stream->ReadString(&projectPath, -410); stream->Read(projectPath, -410);
// Flags // Flags
AssetsCacheFlags flags; AssetsCacheFlags flags;
stream->ReadInt32((int32*)&flags); stream->Read((int32&)flags);
// Check if other workspace instance used this cache // Check if other workspace instance used this cache
if (EnumHasNoneFlags(flags, AssetsCacheFlags::RelativePaths) && enginePath != Globals::StartupFolder) if (EnumHasNoneFlags(flags, AssetsCacheFlags::RelativePaths) && enginePath != Globals::StartupFolder)
@@ -75,7 +75,7 @@ void AssetsCache::Init()
_isDirty = false; _isDirty = false;
// Load elements count // Load elements count
stream->ReadInt32(&count); stream->Read(count);
_registry.Clear(); _registry.Clear();
_registry.EnsureCapacity(count); _registry.EnsureCapacity(count);
@@ -84,8 +84,8 @@ void AssetsCache::Init()
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++)
{ {
stream->Read(e.Info.ID); stream->Read(e.Info.ID);
stream->ReadString(&e.Info.TypeName, i - 13); stream->Read(e.Info.TypeName, i - 13);
stream->ReadString(&e.Info.Path, i); stream->Read(e.Info.Path, i);
#if ENABLE_ASSETS_DISCOVERY #if ENABLE_ASSETS_DISCOVERY
stream->Read(e.FileModified); stream->Read(e.FileModified);
#else #else
@@ -115,7 +115,7 @@ void AssetsCache::Init()
Guid id; Guid id;
stream->Read(id); stream->Read(id);
String mappedPath; String mappedPath;
stream->ReadString(&mappedPath, i + 73); stream->Read(mappedPath, i + 73);
if (EnumHasAnyFlags(flags, AssetsCacheFlags::RelativePaths) && mappedPath.HasChars()) if (EnumHasAnyFlags(flags, AssetsCacheFlags::RelativePaths) && mappedPath.HasChars())
{ {
@@ -177,17 +177,17 @@ bool AssetsCache::Save(const StringView& path, const Registry& entries, const Pa
return true; return true;
// Version // Version
stream->WriteInt32(FLAXENGINE_VERSION_BUILD); stream->Write((int32)FLAXENGINE_VERSION_BUILD);
// Paths // Paths
stream->WriteString(Globals::StartupFolder, -410); stream->Write(Globals::StartupFolder, -410);
stream->WriteString(Globals::ProjectFolder, -410); stream->Write(Globals::ProjectFolder, -410);
// Flags // Flags
stream->WriteInt32((int32)flags); stream->Write((int32)flags);
// Items count // Items count
stream->WriteInt32(entries.Count()); stream->Write(entries.Count());
// Data // Data
int32 index = 0; int32 index = 0;
@@ -195,12 +195,12 @@ bool AssetsCache::Save(const StringView& path, const Registry& entries, const Pa
{ {
auto& e = i->Value; auto& e = i->Value;
stream->Write(e.Info.ID); stream->Write(e.Info.ID);
stream->WriteString(e.Info.TypeName, index - 13); stream->Write(e.Info.TypeName, index - 13);
stream->WriteString(e.Info.Path, index); stream->Write(e.Info.Path, index);
#if ENABLE_ASSETS_DISCOVERY #if ENABLE_ASSETS_DISCOVERY
stream->Write(e.FileModified); stream->Write(e.FileModified);
#else #else
stream->WriteInt64(0); stream->Write((int64)0);
#endif #endif
index++; index++;
} }
@@ -211,7 +211,7 @@ bool AssetsCache::Save(const StringView& path, const Registry& entries, const Pa
for (auto i = pathsMapping.Begin(); i.IsNotEnd(); ++i) for (auto i = pathsMapping.Begin(); i.IsNotEnd(); ++i)
{ {
stream->Write(i->Value); stream->Write(i->Value);
stream->WriteString(i->Key, index + 73); stream->Write(i->Key, index + 73);
index++; index++;
} }

View File

@@ -19,7 +19,7 @@ class FlaxStorage;
/// <summary> /// <summary>
/// Assets cache flags. /// Assets cache flags.
/// </summary> /// </summary>
enum class AssetsCacheFlags enum class AssetsCacheFlags : int32
{ {
/// <summary> /// <summary>
/// The none. /// The none.

View File

@@ -544,8 +544,8 @@ bool FlaxStorage::Load()
DateTime tmpDate; DateTime tmpDate;
String strTmp; String strTmp;
stream->Read(tmpDate); stream->Read(tmpDate);
stream->ReadString(&strTmp, -76); stream->Read(strTmp, -76);
stream->ReadString(&strTmp, 1301); stream->Read(strTmp, 1301);
} }
// Check char // Check char
@@ -974,9 +974,9 @@ bool FlaxStorage::Create(WriteStream* stream, const AssetInitData* data, int32 d
stream->WriteUint32(header.SerializedVersion); stream->WriteUint32(header.SerializedVersion);
// Chunks mapping // Chunks mapping
for (int32 chunkIndex = 0; chunkIndex < ARRAY_COUNT(header.Header.Chunks); chunkIndex++) for (FlaxChunk* chunk : header.Header.Chunks)
{ {
const int32 index = chunks.Find(header.Header.Chunks[chunkIndex]); const int32 index = chunks.Find(chunk);
stream->WriteInt32(index); stream->WriteInt32(index);
} }
@@ -1250,8 +1250,8 @@ bool FlaxStorage::LoadAssetHeader(const Entry& e, AssetInitData& data)
DateTime importDate; DateTime importDate;
String importPath, importUsername; String importPath, importUsername;
stream->Read(importDate); stream->Read(importDate);
stream->ReadString(&importPath, -76); stream->Read(importPath, -76);
stream->ReadString(&importUsername, 1301); stream->Read(importUsername, 1301);
#if USE_EDITOR #if USE_EDITOR
// Convert old metadata into the new format // Convert old metadata into the new format

View File

@@ -24,20 +24,20 @@ public:
MemoryWriteStream stream(256); MemoryWriteStream stream(256);
{ {
// Info // Info
stream.WriteInt32(102); stream.Write(102);
stream.WriteDouble(5 * 60.0); stream.Write(5 * 60.0);
stream.WriteDouble(60.0); stream.Write(60.0);
stream.WriteBool(false); stream.Write(false);
stream.WriteString(StringView::Empty, 13); stream.Write(StringView::Empty, 13);
// Animation channels // Animation channels
stream.WriteInt32(0); stream.Write(0);
// Animation events // Animation events
stream.WriteInt32(0); stream.Write(0);
// Nested animations // Nested animations
stream.WriteInt32(0); stream.Write(0);
} }
// Copy to asset chunk // Copy to asset chunk

View File

@@ -41,9 +41,9 @@ public:
return CreateAssetResult::CannotAllocateChunk; return CreateAssetResult::CannotAllocateChunk;
{ {
MemoryWriteStream stream(256); MemoryWriteStream stream(256);
stream.WriteInt32(1); stream.Write(1);
stream.WriteString(*baseTypename, 31); stream.Write(*baseTypename, 31);
stream.WriteInt32((int32)VisualScript::Flags::None); stream.Write((int32)VisualScript::Flags::None);
context.Data.Header.Chunks[1]->Data.Copy(stream.GetHandle(), stream.GetPosition()); context.Data.Header.Chunks[1]->Data.Copy(stream.GetHandle(), stream.GetPosition());
} }

View File

@@ -43,17 +43,17 @@ bool ImportTexture::TryGetImportOptions(const StringView& path, Options& options
{ {
MemoryReadStream stream(chunk15->Data.Get(), chunk15->Data.Length()); MemoryReadStream stream(chunk15->Data.Get(), chunk15->Data.Length());
int32 tilesVersion, tilesCount; int32 tilesVersion, tilesCount;
stream.ReadInt32(&tilesVersion); stream.Read(tilesVersion);
if (tilesVersion == 1) if (tilesVersion == 1)
{ {
options.Sprites.Clear(); options.Sprites.Clear();
stream.ReadInt32(&tilesCount); stream.Read(tilesCount);
for (int32 i = 0; i < tilesCount; i++) for (int32 i = 0; i < tilesCount; i++)
{ {
// Load sprite // Load sprite
Sprite t; Sprite t;
stream.Read(t.Area); stream.Read(t.Area);
stream.ReadString(&t.Name, 49); stream.Read(t.Name, 49);
options.Sprites.Add(t); options.Sprites.Add(t);
} }
} }
@@ -168,13 +168,13 @@ CreateAssetResult ImportTexture::Create(CreateAssetContext& context, const Textu
if (options.IsAtlas) if (options.IsAtlas)
{ {
MemoryWriteStream stream(256); MemoryWriteStream stream(256);
stream.WriteInt32(1); // Version stream.Write(1); // Version
stream.WriteInt32(options.Sprites.Count()); // Amount of tiles stream.Write(options.Sprites.Count()); // Amount of tiles
for (int32 i = 0; i < options.Sprites.Count(); i++) for (int32 i = 0; i < options.Sprites.Count(); i++)
{ {
auto& sprite = options.Sprites[i]; auto& sprite = options.Sprites[i];
stream.Write(sprite.Area); stream.Write(sprite.Area);
stream.WriteString(sprite.Name, 49); stream.Write(sprite.Name, 49);
} }
if (context.AllocateChunk(15)) if (context.AllocateChunk(15))
return CreateAssetResult::CannotAllocateChunk; return CreateAssetResult::CannotAllocateChunk;
@@ -307,13 +307,13 @@ CreateAssetResult ImportTexture::Create(CreateAssetContext& context, const Textu
if (options.IsAtlas) if (options.IsAtlas)
{ {
MemoryWriteStream stream(256); MemoryWriteStream stream(256);
stream.WriteInt32(1); // Version stream.Write(1); // Version
stream.WriteInt32(options.Sprites.Count()); // Amount of tiles stream.Write(options.Sprites.Count()); // Amount of tiles
for (int32 i = 0; i < options.Sprites.Count(); i++) for (int32 i = 0; i < options.Sprites.Count(); i++)
{ {
auto& sprite = options.Sprites[i]; auto& sprite = options.Sprites[i];
stream.Write(sprite.Area); stream.Write(sprite.Area);
stream.WriteString(sprite.Name, 49); stream.Write(sprite.Name, 49);
} }
if (context.AllocateChunk(15)) if (context.AllocateChunk(15))
return CreateAssetResult::CannotAllocateChunk; return CreateAssetResult::CannotAllocateChunk;

View File

@@ -14,22 +14,21 @@
class GameplayGlobalsUpgrader : public BinaryAssetUpgrader class GameplayGlobalsUpgrader : public BinaryAssetUpgrader
{ {
public: public:
GameplayGlobalsUpgrader() GameplayGlobalsUpgrader()
{ {
static const Upgrader upgraders[] = const Upgrader upgraders[] =
{ {
{ 1, 2, &Upgrade_1_To_2 }, { 1, 2, &Upgrade_1_To_2 }, // [Deprecated on 31.07.2020, expires on 31.07.2022]
}; };
setup(upgraders, ARRAY_COUNT(upgraders)); setup(upgraders, ARRAY_COUNT(upgraders));
} }
private: private:
static bool Upgrade_1_To_2(AssetMigrationContext& context) static bool Upgrade_1_To_2(AssetMigrationContext& context)
{ {
// [Deprecated on 31.07.2020, expires on 31.07.2022]
PRAGMA_DISABLE_DEPRECATION_WARNINGS
ASSERT(context.Input.SerializedVersion == 1 && context.Output.SerializedVersion == 2); ASSERT(context.Input.SerializedVersion == 1 && context.Output.SerializedVersion == 2);
if (context.AllocateChunk(0)) if (context.AllocateChunk(0))
return true; return true;
auto& data = context.Input.Header.Chunks[0]->Data; auto& data = context.Input.Header.Chunks[0]->Data;
@@ -41,13 +40,14 @@ private:
String name; String name;
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++)
{ {
stream.ReadString(&name, 71); stream.Read(name, 71);
CommonValue commonValue; CommonValue commonValue;
stream.ReadCommonValue(&commonValue); stream.ReadCommonValue(&commonValue);
Variant variant(commonValue); Variant variant(commonValue);
output.WriteVariant(variant); output.WriteVariant(variant);
} }
context.Output.Header.Chunks[0]->Data.Copy(output.GetHandle(), output.GetPosition()); context.Output.Header.Chunks[0]->Data.Copy(output.GetHandle(), output.GetPosition());
PRAGMA_ENABLE_DEPRECATION_WARNINGS
return false; return false;
} }
@@ -170,11 +170,11 @@ bool GameplayGlobals::Save(const StringView& path)
// Save to bytes // Save to bytes
MemoryWriteStream stream(1024); MemoryWriteStream stream(1024);
stream.WriteInt32(Variables.Count()); stream.Write(Variables.Count());
for (auto& e : Variables) for (auto& e : Variables)
{ {
stream.WriteString(e.Key, 71); stream.Write(e.Key, 71);
stream.WriteVariant(e.Value.DefaultValue); stream.Write(e.Value.DefaultValue);
} }
// Set chunk data // Set chunk data
@@ -226,14 +226,14 @@ Asset::LoadResult GameplayGlobals::load()
// Load all variables // Load all variables
int32 count; int32 count;
stream.ReadInt32(&count); stream.Read(count);
Variables.EnsureCapacity(count); Variables.EnsureCapacity(count);
String name; String name;
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++)
{ {
stream.ReadString(&name, 71); stream.Read(name, 71);
auto& e = Variables[name]; auto& e = Variables[name];
stream.ReadVariant(&e.DefaultValue); stream.Read(e.DefaultValue);
e.Value = e.DefaultValue; e.Value = e.DefaultValue;
} }
if (stream.HasError()) if (stream.HasError())

View File

@@ -812,7 +812,7 @@ bool MaterialParams::Load(ReadStream* stream)
stream->Read(param->_paramId); stream->Read(param->_paramId);
param->_isPublic = stream->ReadBool(); param->_isPublic = stream->ReadBool();
param->_override = stream->ReadBool(); param->_override = stream->ReadBool();
stream->ReadString(&param->_name, 10421); stream->Read(param->_name, 10421);
param->_registerIndex = stream->ReadByte(); param->_registerIndex = stream->ReadByte();
stream->ReadUint16(&param->_offset); stream->ReadUint16(&param->_offset);
@@ -826,7 +826,7 @@ bool MaterialParams::Load(ReadStream* stream)
case MaterialParameterType::SceneTexture: case MaterialParameterType::SceneTexture:
case MaterialParameterType::ChannelMask: case MaterialParameterType::ChannelMask:
case MaterialParameterType::TextureGroupSampler: case MaterialParameterType::TextureGroupSampler:
stream->ReadInt32(&param->_asInteger); stream->Read(param->_asInteger);
break; break;
case MaterialParameterType::Float: case MaterialParameterType::Float:
stream->ReadFloat(&param->_asFloat); stream->ReadFloat(&param->_asFloat);
@@ -904,7 +904,7 @@ void MaterialParams::Save(WriteStream* stream)
stream->Write(param->_paramId); stream->Write(param->_paramId);
stream->WriteBool(param->_isPublic); stream->WriteBool(param->_isPublic);
stream->WriteBool(param->_override); stream->WriteBool(param->_override);
stream->WriteString(param->_name, 10421); stream->Write(param->_name, 10421);
stream->WriteByte(param->_registerIndex); stream->WriteByte(param->_registerIndex);
stream->WriteUint16(param->_offset); stream->WriteUint16(param->_offset);
@@ -980,7 +980,7 @@ void MaterialParams::Save(WriteStream* stream, const Array<SerializedMaterialPar
stream->Write(param.ID); stream->Write(param.ID);
stream->WriteBool(param.IsPublic); stream->WriteBool(param.IsPublic);
stream->WriteBool(param.Override); stream->WriteBool(param.Override);
stream->WriteString(param.Name, 10421); stream->Write(param.Name, 10421);
stream->WriteByte(param.RegisterIndex); stream->WriteByte(param.RegisterIndex);
stream->WriteUint16(param.Offset); stream->WriteUint16(param.Offset);

View File

@@ -136,7 +136,7 @@ bool IsValidShaderCache(DataContainer<byte>& shaderCache, Array<String>& include
for (int32 i = 0; i < includesCount; i++) for (int32 i = 0; i < includesCount; i++)
{ {
String& include = includes.AddOne(); String& include = includes.AddOne();
stream.ReadString(&include, 11); stream.Read(include, 11);
include = ShadersCompilation::ResolveShaderPath(include); include = ShadersCompilation::ResolveShaderPath(include);
DateTime lastEditTime; DateTime lastEditTime;
stream.Read(lastEditTime); stream.Read(lastEditTime);

View File

@@ -65,7 +65,7 @@ bool GPUShader::Create(MemoryReadStream& stream)
ASSERT(Math::IsInRange(permutationsCount, 1, SHADER_PERMUTATIONS_MAX_COUNT)); ASSERT(Math::IsInRange(permutationsCount, 1, SHADER_PERMUTATIONS_MAX_COUNT));
// Load shader name // Load shader name
stream.ReadStringAnsi(&initializer.Name, 11); stream.Read(initializer.Name, 11);
ASSERT(initializer.Name.HasChars()); ASSERT(initializer.Name.HasChars());
// Load shader flags // Load shader flags

View File

@@ -1639,7 +1639,7 @@ bool Actor::ToBytes(const Array<Actor*>& actors, MemoryWriteStream& output)
output.WriteInt32(FLAXENGINE_VERSION_BUILD); output.WriteInt32(FLAXENGINE_VERSION_BUILD);
// Serialized objects ids (for references mapping) // Serialized objects ids (for references mapping)
output.WriteArray(ids); output.Write(ids);
// Objects data // Objects data
rapidjson_flax::StringBuffer buffer; rapidjson_flax::StringBuffer buffer;
@@ -1694,7 +1694,7 @@ bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeM
// Serialized objects ids (for references mapping) // Serialized objects ids (for references mapping)
Array<Guid> ids; Array<Guid> ids;
stream.ReadArray(&ids); stream.Read(ids);
int32 objectsCount = ids.Count(); int32 objectsCount = ids.Count();
if (objectsCount < 0) if (objectsCount < 0)
return true; return true;
@@ -1866,7 +1866,7 @@ Array<Guid> Actor::TryGetSerializedObjectsIds(const Span<byte>& data)
if (engineBuild <= FLAXENGINE_VERSION_BUILD && engineBuild >= 6165) if (engineBuild <= FLAXENGINE_VERSION_BUILD && engineBuild >= 6165)
{ {
// Serialized objects ids (for references mapping) // Serialized objects ids (for references mapping)
stream.ReadArray(&result); stream.Read(result);
} }
} }

View File

@@ -152,7 +152,7 @@ void NetworkStream::Read(Quaternion& data)
NetworkQuaternion::Read(this, data); NetworkQuaternion::Read(this, data);
} }
void NetworkStream::Read(Transform& data) void NetworkStream::Read(Transform& data, bool useDouble)
{ {
struct NonQuantized struct NonQuantized
{ {
@@ -181,7 +181,7 @@ void NetworkStream::Write(const Quaternion& data)
NetworkQuaternion::Write(this, data); NetworkQuaternion::Write(this, data);
} }
void NetworkStream::Write(const Transform& data) void NetworkStream::Write(const Transform& data, bool useDouble)
{ {
struct NonQuantized struct NonQuantized
{ {

View File

@@ -73,13 +73,13 @@ public:
void Read(INetworkSerializable& obj); void Read(INetworkSerializable& obj);
void Read(INetworkSerializable* obj); void Read(INetworkSerializable* obj);
void Read(Quaternion& data); void Read(Quaternion& data);
void Read(Transform& data); void Read(Transform& data, bool useDouble = false);
using WriteStream::Write; using WriteStream::Write;
void Write(INetworkSerializable& obj); void Write(INetworkSerializable& obj);
void Write(INetworkSerializable* obj); void Write(INetworkSerializable* obj);
void Write(const Quaternion& data); void Write(const Quaternion& data);
void Write(const Transform& data); void Write(const Transform& data, bool useDouble = false);
public: public:
// [Stream] // [Stream]

View File

@@ -74,7 +74,7 @@ BytesContainer ParticleSystem::LoadTimeline()
stream.WriteByte((byte)track.Flag); stream.WriteByte((byte)track.Flag);
stream.WriteInt32(track.ParentIndex); stream.WriteInt32(track.ParentIndex);
stream.WriteInt32(track.ChildrenCount); stream.WriteInt32(track.ChildrenCount);
stream.WriteString(track.Name, -13); stream.Write(track.Name, -13);
stream.Write(track.Color); stream.Write(track.Color);
Guid id; Guid id;
@@ -102,7 +102,7 @@ BytesContainer ParticleSystem::LoadTimeline()
{ {
stream.WriteInt32(i->Key.First); stream.WriteInt32(i->Key.First);
stream.Write(i->Key.Second); stream.Write(i->Key.Second);
stream.WriteVariant(i->Value); stream.Write(i->Value);
} }
} }
} }
@@ -212,7 +212,7 @@ Asset::LoadResult ParticleSystem::load()
MemoryReadStream stream(chunk0->Data.Get(), chunk0->Data.Length()); MemoryReadStream stream(chunk0->Data.Get(), chunk0->Data.Length());
int32 version; int32 version;
stream.ReadInt32(&version); stream.Read(version);
#if USE_EDITOR #if USE_EDITOR
// Skip unused parameters // Skip unused parameters
#define SKIP_UNUSED_PARAM_OVERRIDE() if (key.First < 0 || key.First >= Emitters.Count() || Emitters[key.First] == nullptr || Emitters[key.First]->Graph.GetParameter(key.Second) == nullptr) continue #define SKIP_UNUSED_PARAM_OVERRIDE() if (key.First < 0 || key.First >= Emitters.Count() || Emitters[key.First] == nullptr || Emitters[key.First]->Graph.GetParameter(key.Second) == nullptr) continue
@@ -394,7 +394,7 @@ Asset::LoadResult ParticleSystem::load()
track.Flag = (Track::Flags)stream.ReadByte(); track.Flag = (Track::Flags)stream.ReadByte();
stream.ReadInt32(&track.ParentIndex); stream.ReadInt32(&track.ParentIndex);
stream.ReadInt32(&track.ChildrenCount); stream.ReadInt32(&track.ChildrenCount);
stream.ReadString(&track.Name, -13); stream.Read(track.Name, -13);
track.Disabled = (int32)track.Flag & (int32)Track::Flags::Mute || (track.ParentIndex != -1 && Tracks[track.ParentIndex].Disabled); track.Disabled = (int32)track.Flag & (int32)Track::Flags::Mute || (track.ParentIndex != -1 && Tracks[track.ParentIndex].Disabled);
stream.Read(track.Color); stream.Read(track.Color);
@@ -422,19 +422,22 @@ Asset::LoadResult ParticleSystem::load()
Emitters[i]->WaitForLoaded(); Emitters[i]->WaitForLoaded();
} }
if (version <= 3)
{
// [Deprecated on 03.09.2021 expires on 03.09.2023]
}
else
{
// Load parameters overrides // Load parameters overrides
int32 overridesCount = 0; int32 overridesCount = 0;
if (stream.CanRead())
stream.ReadInt32(&overridesCount); stream.ReadInt32(&overridesCount);
if (overridesCount != 0)
{
EmitterParameterOverrideKey key; EmitterParameterOverrideKey key;
Variant value; Variant value;
for (int32 i = 0; i < overridesCount; i++) for (int32 i = 0; i < overridesCount; i++)
{ {
stream.ReadInt32(&key.First); stream.ReadInt32(&key.First);
stream.Read(key.Second); stream.Read(key.Second);
stream.ReadVariant(&value); stream.Read(value);
SKIP_UNUSED_PARAM_OVERRIDE(); SKIP_UNUSED_PARAM_OVERRIDE();
EmittersParametersOverrides[key] = value; EmittersParametersOverrides[key] = value;
} }

View File

@@ -108,12 +108,12 @@ bool SpriteAtlas::SaveSprites()
// Write sprites data // Write sprites data
MemoryWriteStream stream(1024); MemoryWriteStream stream(1024);
stream.WriteInt32(1); // Version stream.Write(1); // Version
stream.WriteInt32(Sprites.Count()); // Sprites Count stream.Write(Sprites.Count()); // Sprites Count
for (Sprite& t : Sprites) for (Sprite& t : Sprites)
{ {
stream.Write(t.Area); stream.Write(t.Area);
stream.WriteString(t.Name, 49); stream.Write(t.Name, 49);
} }
// Link sprites data (unlink after safe) // Link sprites data (unlink after safe)
@@ -148,7 +148,7 @@ bool SpriteAtlas::LoadSprites(ReadStream& stream)
Sprites.Clear(); Sprites.Clear();
int32 tilesVersion, tilesCount; int32 tilesVersion, tilesCount;
stream.ReadInt32(&tilesVersion); stream.Read(tilesVersion);
if (tilesVersion != 1) if (tilesVersion != 1)
{ {
#if USE_EDITOR #if USE_EDITOR
@@ -158,12 +158,12 @@ bool SpriteAtlas::LoadSprites(ReadStream& stream)
LOG(Warning, "Invalid tiles version."); LOG(Warning, "Invalid tiles version.");
return true; return true;
} }
stream.ReadInt32(&tilesCount); stream.Read(tilesCount);
Sprites.Resize(tilesCount); Sprites.Resize(tilesCount);
for (Sprite& t : Sprites) for (Sprite& t : Sprites)
{ {
stream.Read(t.Area); stream.Read(t.Area);
stream.ReadString(&t.Name, 49); stream.Read(t.Name, 49);
} }
#if USE_EDITOR #if USE_EDITOR

View File

@@ -167,9 +167,9 @@ public:
} }
/// <summary> /// <summary>
/// Read data array /// Reads array.
/// </summary> /// </summary>
/// <param name="data">Array to read</param> /// <param name="data">Array to read.</param>
template<typename T, typename AllocationType = HeapAllocation> template<typename T, typename AllocationType = HeapAllocation>
void Read(Array<T, AllocationType>& data) void Read(Array<T, AllocationType>& data)
{ {
@@ -189,9 +189,9 @@ public:
} }
/// <summary> /// <summary>
/// Read data dictionary /// Reads dictionary.
/// </summary> /// </summary>
/// <param name="data">Dictionary to read</param> /// <param name="data">Dictionary to read.</param>
template<typename KeyType, typename ValueType, typename AllocationType = HeapAllocation> template<typename KeyType, typename ValueType, typename AllocationType = HeapAllocation>
void Read(Dictionary<KeyType, ValueType, AllocationType>& data) void Read(Dictionary<KeyType, ValueType, AllocationType>& data)
{ {
@@ -214,34 +214,41 @@ public:
/// <param name="obj">The object to deserialize.</param> /// <param name="obj">The object to deserialize.</param>
void ReadJson(ISerializable* obj); void ReadJson(ISerializable* obj);
// Deserialization of math types with float or double depending on the context (must match serialization)
// Set useDouble=true to explicitly use 64-bit precision for serialized data
void Read(BoundingBox& box, bool useDouble = false);
void Read(BoundingSphere& sphere, bool useDouble = false);
void Read(Transform& transform, bool useDouble = false);
void Read(Ray& ray, bool useDouble = false);
public: public:
// Reads StringAnsi from the stream // Reads StringAnsi from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void ReadStringAnsi(StringAnsi* data); DEPRECATED("Use Read method") void ReadStringAnsi(StringAnsi* data);
// Reads StringAnsi from the stream with a key // Reads StringAnsi from the stream with a key
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void ReadStringAnsi(StringAnsi* data, int8 lock); DEPRECATED("Use Read method") void ReadStringAnsi(StringAnsi* data, int8 lock);
// Reads String from the stream // Reads String from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void ReadString(String* data); DEPRECATED("Use Read method") void ReadString(String* data);
// Reads String from the stream // Reads String from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void ReadString(String* data, int16 lock); DEPRECATED("Use Read method") void ReadString(String* data, int16 lock);
// Reads CommonValue from the stream // Reads CommonValue from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void ReadCommonValue(CommonValue* data); DEPRECATED("Use Read method") void ReadCommonValue(CommonValue* data);
// Reads VariantType from the stream // Reads VariantType from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void ReadVariantType(VariantType* data); DEPRECATED("Use Read method") void ReadVariantType(VariantType* data);
// Reads Variant from the stream // Reads Variant from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void ReadVariant(Variant* data); DEPRECATED("Use Read method") void ReadVariant(Variant* data);
/// <summary> /// <summary>
/// Read data array /// Read data array
@@ -249,18 +256,21 @@ public:
/// </summary> /// </summary>
/// <param name="data">Array to read</param> /// <param name="data">Array to read</param>
template<typename T, typename AllocationType = HeapAllocation> template<typename T, typename AllocationType = HeapAllocation>
void ReadArray(Array<T, AllocationType>* data) DEPRECATED("Use Read method") void ReadArray(Array<T, AllocationType>* data)
{ {
Read(*data); Read(*data);
} }
public:
// Deserialization of math types with float or double depending on the context (must match serialization) // Deserialization of math types with float or double depending on the context (must match serialization)
// Set useDouble=true to explicitly use 64-bit precision for serialized data // Set useDouble=true to explicitly use 64-bit precision for serialized data
void ReadBoundingBox(BoundingBox* box, bool useDouble = false); // [Deprecated in v1.10]
void ReadBoundingSphere(BoundingSphere* sphere, bool useDouble = false); DEPRECATED("Use Read method") void ReadBoundingBox(BoundingBox* box, bool useDouble = false);
void ReadTransform(Transform* transform, bool useDouble = false); // [Deprecated in v1.10]
void ReadRay(Ray* ray, bool useDouble = false); DEPRECATED("Use Read method") void ReadBoundingSphere(BoundingSphere* sphere, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Read method") void ReadTransform(Transform* transform, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Read method") void ReadRay(Ray* ray, bool useDouble = false);
public: public:
// [Stream] // [Stream]

View File

@@ -167,14 +167,14 @@ void ReadStream::Read(CommonValue& data)
case CommonType::String: case CommonType::String:
{ {
String v; String v;
ReadString(&v, 953); Read(v, 953);
data.Set(v); data.Set(v);
} }
break; break;
case CommonType::Box: case CommonType::Box:
{ {
BoundingBox v; BoundingBox v;
ReadBoundingBox(&v); Read(v);
data.Set(v); data.Set(v);
} }
break; break;
@@ -188,14 +188,14 @@ void ReadStream::Read(CommonValue& data)
case CommonType::Transform: case CommonType::Transform:
{ {
Transform v; Transform v;
ReadTransform(&v); Read(v);
data.Set(v); data.Set(v);
} }
break; break;
case CommonType::Sphere: case CommonType::Sphere:
{ {
BoundingSphere v; BoundingSphere v;
ReadBoundingSphere(&v); Read(v);
data.Set(v); data.Set(v);
} }
break; break;
@@ -208,7 +208,7 @@ void ReadStream::Read(CommonValue& data)
case CommonType::Ray: case CommonType::Ray:
{ {
Ray v; Ray v;
ReadRay(&v); Read(v);
data.Set(v); data.Set(v);
} }
break; break;
@@ -277,7 +277,7 @@ void ReadStream::Read(VariantType& data)
void ReadStream::Read(Variant& data) void ReadStream::Read(Variant& data)
{ {
VariantType type; VariantType type;
ReadVariantType(&type); Read(type);
data.SetType(MoveTemp(type)); data.SetType(MoveTemp(type));
switch (data.Type.Type) switch (data.Type.Type)
{ {
@@ -360,7 +360,7 @@ void ReadStream::Read(Variant& data)
{ {
// Json // Json
StringAnsi json; StringAnsi json;
ReadStringAnsi(&json, -71); Read(json, -71);
#if USE_CSHARP #if USE_CSHARP
MCore::Thread::Attach(); MCore::Thread::Attach();
MClass* klass = MUtils::GetClass(data.Type); MClass* klass = MUtils::GetClass(data.Type);
@@ -430,22 +430,22 @@ void ReadStream::Read(Variant& data)
ReadBytes(&data.AsData, sizeof(Guid)); ReadBytes(&data.AsData, sizeof(Guid));
break; break;
case VariantType::BoundingBox: case VariantType::BoundingBox:
ReadBoundingBox(&data.AsBoundingBox()); Read(data.AsBoundingBox());
break; break;
case VariantType::BoundingSphere: case VariantType::BoundingSphere:
ReadBoundingSphere(&data.AsBoundingSphere()); Read(data.AsBoundingSphere());
break; break;
case VariantType::Quaternion: case VariantType::Quaternion:
ReadBytes(&data.AsData, sizeof(Quaternion)); ReadBytes(&data.AsData, sizeof(Quaternion));
break; break;
case VariantType::Transform: case VariantType::Transform:
ReadTransform(&data.AsTransform()); Read(data.AsTransform());
break; break;
case VariantType::Rectangle: case VariantType::Rectangle:
ReadBytes(&data.AsData, sizeof(Rectangle)); ReadBytes(&data.AsData, sizeof(Rectangle));
break; break;
case VariantType::Ray: case VariantType::Ray:
ReadRay(&data.AsRay()); Read(data.AsRay());
break; break;
case VariantType::Matrix: case VariantType::Matrix:
ReadBytes(data.AsBlob.Data, sizeof(Matrix)); ReadBytes(data.AsBlob.Data, sizeof(Matrix));
@@ -453,25 +453,25 @@ void ReadStream::Read(Variant& data)
case VariantType::Array: case VariantType::Array:
{ {
int32 count; int32 count;
ReadInt32(&count); Read(count);
auto& array = *(Array<Variant>*)data.AsData; auto& array = *(Array<Variant>*)data.AsData;
array.Resize(count); array.Resize(count);
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++)
ReadVariant(&array[i]); Read(array[i]);
break; break;
} }
case VariantType::Dictionary: case VariantType::Dictionary:
{ {
int32 count; int32 count;
ReadInt32(&count); Read(count);
auto& dictionary = *data.AsDictionary; auto& dictionary = *data.AsDictionary;
dictionary.Clear(); dictionary.Clear();
dictionary.EnsureCapacity(count); dictionary.EnsureCapacity(count);
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++)
{ {
Variant key; Variant key;
ReadVariant(&key); Read(key);
ReadVariant(&dictionary[MoveTemp(key)]); Read(dictionary[MoveTemp(key)]);
} }
break; break;
} }
@@ -562,18 +562,18 @@ void ReadStream::ReadVariant(Variant* data)
Read(*data); Read(*data);
} }
void ReadStream::ReadBoundingBox(BoundingBox* box, bool useDouble) void ReadStream::Read(BoundingBox& box, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Read(box); ReadBytes(&box, sizeof(BoundingBox));
else else
{ {
Float3 min, max; Float3 min, max;
Read(min); Read(min);
Read(max); Read(max);
box->Minimum = min; box.Minimum = min;
box->Maximum = max; box.Maximum = max;
} }
#else #else
if (useDouble) if (useDouble)
@@ -581,27 +581,27 @@ void ReadStream::ReadBoundingBox(BoundingBox* box, bool useDouble)
Double3 min, max; Double3 min, max;
Read(min); Read(min);
Read(max); Read(max);
box->Minimum = min; box.Minimum = min;
box->Maximum = max; box.Maximum = max;
} }
else else
Read(*box); ReadBytes(&box, sizeof(BoundingBox));
#endif #endif
} }
void ReadStream::ReadBoundingSphere(BoundingSphere* sphere, bool useDouble) void ReadStream::Read(BoundingSphere& sphere, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Read(*sphere); ReadBytes(&sphere, sizeof(BoundingSphere));
else else
{ {
Float3 center; Float3 center;
float radius; float radius;
Read(center); Read(center);
Read(radius); Read(radius);
sphere->Center = center; sphere.Center = center;
sphere->Radius = radius; sphere.Radius = radius;
} }
#else #else
if (useDouble) if (useDouble)
@@ -610,53 +610,53 @@ void ReadStream::ReadBoundingSphere(BoundingSphere* sphere, bool useDouble)
double radius; double radius;
Read(center); Read(center);
Read(radius); Read(radius);
sphere->Center = center; sphere.Center = center;
sphere->Radius = (float)radius; sphere.Radius = (float)radius;
} }
else else
Read(*sphere); ReadBytes(&sphere, sizeof(BoundingSphere));
#endif #endif
} }
void ReadStream::ReadTransform(Transform* transform, bool useDouble) void ReadStream::Read(Transform& transform, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Read(*transform); ReadBytes(&transform, sizeof(Transform));
else else
{ {
Float3 translation; Float3 translation;
Read(translation); Read(translation);
Read(transform->Orientation); Read(transform.Orientation);
Read(transform->Scale); Read(transform.Scale);
transform->Translation = translation; transform.Translation = translation;
} }
#else #else
if (useDouble) if (useDouble)
{ {
Double3 translation; Double3 translation;
Read(translation); Read(translation);
Read(transform->Orientation); Read(transform.Orientation);
Read(transform->Scale); Read(transform.Scale);
transform->Translation = translation; transform.Translation = translation;
} }
else else
Read(*transform); ReadBytes(&transform, sizeof(Transform));
#endif #endif
} }
void ReadStream::ReadRay(Ray* ray, bool useDouble) void ReadStream::Read(Ray& ray, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Read(*ray); ReadBytes(&ray, sizeof(Ray));
else else
{ {
Float3 position, direction; Float3 position, direction;
Read(position); Read(position);
Read(direction); Read(direction);
ray->Position = position; ray.Position = position;
ray->Direction = direction; ray.Direction = direction;
} }
#else #else
if (useDouble) if (useDouble)
@@ -664,14 +664,34 @@ void ReadStream::ReadRay(Ray* ray, bool useDouble)
Double3 position, direction; Double3 position, direction;
Read(position); Read(position);
Read(direction); Read(direction);
ray->Position = position; ray.Position = position;
ray->Direction = direction; ray.Direction = direction;
} }
else else
Read(*ray); ReadBytes(&ray, sizeof(Ray));
#endif #endif
} }
void ReadStream::ReadBoundingBox(BoundingBox* box, bool useDouble)
{
Read(*box);
}
void ReadStream::ReadBoundingSphere(BoundingSphere* sphere, bool useDouble)
{
Read(*sphere);
}
void ReadStream::ReadTransform(Transform* transform, bool useDouble)
{
Read(*transform);
}
void ReadStream::ReadRay(Ray* ray, bool useDouble)
{
Read(*ray);
}
void WriteStream::WriteText(const StringView& text) void WriteStream::WriteText(const StringView& text)
{ {
WriteBytes(text.Get(), sizeof(Char) * text.Length()); WriteBytes(text.Get(), sizeof(Char) * text.Length());
@@ -722,13 +742,13 @@ void WriteStream::Write(const CommonValue& data)
switch (data.Type) switch (data.Type)
{ {
case CommonType::Bool: case CommonType::Bool:
WriteBool(data.AsBool); Write(data.AsBool);
break; break;
case CommonType::Integer: case CommonType::Integer:
WriteInt32(data.AsInteger); Write(data.AsInteger);
break; break;
case CommonType::Float: case CommonType::Float:
WriteFloat(data.AsFloat); Write(data.AsFloat);
break; break;
case CommonType::Vector2: case CommonType::Vector2:
Write(data.AsVector2); Write(data.AsVector2);
@@ -746,25 +766,25 @@ void WriteStream::Write(const CommonValue& data)
Write(data.AsGuid); Write(data.AsGuid);
break; break;
case CommonType::String: case CommonType::String:
WriteString(data.AsString, 953); Write(data.AsString, 953);
break; break;
case CommonType::Box: case CommonType::Box:
WriteBoundingBox(data.AsBox); Write(data.AsBox);
break; break;
case CommonType::Rotation: case CommonType::Rotation:
Write(data.AsRotation); Write(data.AsRotation);
break; break;
case CommonType::Transform: case CommonType::Transform:
WriteTransform(data.AsTransform); Write(data.AsTransform);
break; break;
case CommonType::Sphere: case CommonType::Sphere:
WriteBoundingSphere(data.AsSphere); Write(data.AsSphere);
break; break;
case CommonType::Rectangle: case CommonType::Rectangle:
Write(data.AsRectangle); Write(data.AsRectangle);
break; break;
case CommonType::Ray: case CommonType::Ray:
WriteRay(data.AsRay); Write(data.AsRay);
break; break;
case CommonType::Matrix: case CommonType::Matrix:
Write(data.AsMatrix); Write(data.AsMatrix);
@@ -782,12 +802,12 @@ void WriteStream::Write(const VariantType& data)
{ {
WriteByte((byte)data.Type); WriteByte((byte)data.Type);
WriteInt32(MAX_int32); WriteInt32(MAX_int32);
WriteStringAnsi(StringAnsiView(data.TypeName), 77); Write(StringAnsiView(data.TypeName), 77);
} }
void WriteStream::Write(const Variant& data) void WriteStream::Write(const Variant& data)
{ {
WriteVariantType(data.Type); Write(data.Type);
Guid id; Guid id;
switch (data.Type.Type) switch (data.Type.Type)
{ {
@@ -826,7 +846,7 @@ void WriteStream::Write(const Variant& data)
WriteUint64((uint64)(uintptr)data.AsPointer); WriteUint64((uint64)(uintptr)data.AsPointer);
break; break;
case VariantType::String: case VariantType::String:
WriteString((StringView)data, -14); Write((StringView)data, -14);
break; break;
case VariantType::Object: case VariantType::Object:
id = data.AsObject ? data.AsObject->GetID() : Guid::Empty; id = data.AsObject ? data.AsObject->GetID() : Guid::Empty;
@@ -837,13 +857,13 @@ void WriteStream::Write(const Variant& data)
WriteBytes(data.AsBlob.Data, data.AsBlob.Length); WriteBytes(data.AsBlob.Data, data.AsBlob.Length);
break; break;
case VariantType::BoundingBox: case VariantType::BoundingBox:
WriteBoundingBox(data.AsBoundingBox()); Write(data.AsBoundingBox());
break; break;
case VariantType::Transform: case VariantType::Transform:
WriteTransform(data.AsTransform()); Write(data.AsTransform());
break; break;
case VariantType::Ray: case VariantType::Ray:
WriteRay(data.AsRay()); Write(data.AsRay());
break; break;
case VariantType::Matrix: case VariantType::Matrix:
WriteBytes(data.AsBlob.Data, sizeof(Matrix)); WriteBytes(data.AsBlob.Data, sizeof(Matrix));
@@ -883,24 +903,24 @@ void WriteStream::Write(const Variant& data)
WriteBytes(data.AsData, sizeof(Rectangle)); WriteBytes(data.AsData, sizeof(Rectangle));
break; break;
case VariantType::BoundingSphere: case VariantType::BoundingSphere:
WriteBoundingSphere(data.AsBoundingSphere()); Write(data.AsBoundingSphere());
break; break;
case VariantType::Array: case VariantType::Array:
id.A = ((Array<Variant>*)data.AsData)->Count(); id.A = ((Array<Variant>*)data.AsData)->Count();
WriteInt32(id.A); WriteInt32(id.A);
for (uint32 i = 0; i < id.A; i++) for (uint32 i = 0; i < id.A; i++)
WriteVariant(((Array<Variant>*)data.AsData)->At(i)); Write(((Array<Variant>*)data.AsData)->At(i));
break; break;
case VariantType::Dictionary: case VariantType::Dictionary:
WriteInt32(data.AsDictionary->Count()); WriteInt32(data.AsDictionary->Count());
for (auto i = data.AsDictionary->Begin(); i.IsNotEnd(); ++i) for (auto i = data.AsDictionary->Begin(); i.IsNotEnd(); ++i)
{ {
WriteVariant(i->Key); Write(i->Key);
WriteVariant(i->Value); Write(i->Value);
} }
break; break;
case VariantType::Typename: case VariantType::Typename:
WriteStringAnsi((StringAnsiView)data, -14); Write((StringAnsiView)data, -14);
break; break;
case VariantType::ManagedObject: case VariantType::ManagedObject:
case VariantType::Structure: case VariantType::Structure:
@@ -918,7 +938,7 @@ void WriteStream::Write(const Variant& data)
CompactJsonWriter writerObj(json); CompactJsonWriter writerObj(json);
MCore::Thread::Attach(); MCore::Thread::Attach();
ManagedSerialization::Serialize(writerObj, obj); ManagedSerialization::Serialize(writerObj, obj);
WriteStringAnsi(StringAnsiView(json.GetString(), (int32)json.GetSize()), -71); Write(StringAnsiView(json.GetString(), (int32)json.GetSize()), -71);
} }
else else
#endif #endif
@@ -992,11 +1012,11 @@ void WriteStream::WriteVariant(const Variant& data)
Write(data); Write(data);
} }
void WriteStream::WriteBoundingBox(const BoundingBox& box, bool useDouble) void WriteStream::Write(const BoundingBox& box, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Write(box); WriteBytes(&box, sizeof(BoundingBox));
else else
{ {
Float3 min = box.Minimum, max = box.Maximum; Float3 min = box.Minimum, max = box.Maximum;
@@ -1011,15 +1031,15 @@ void WriteStream::WriteBoundingBox(const BoundingBox& box, bool useDouble)
Write(max); Write(max);
} }
else else
Write(box); WriteBytes(&box, sizeof(BoundingBox));
#endif #endif
} }
void WriteStream::WriteBoundingSphere(const BoundingSphere& sphere, bool useDouble) void WriteStream::Write(const BoundingSphere& sphere, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Write(sphere); WriteBytes(&sphere, sizeof(BoundingSphere));
else else
{ {
Float3 center = sphere.Center; Float3 center = sphere.Center;
@@ -1036,15 +1056,15 @@ void WriteStream::WriteBoundingSphere(const BoundingSphere& sphere, bool useDoub
Write(radius); Write(radius);
} }
else else
Write(sphere); WriteBytes(&sphere, sizeof(BoundingSphere));
#endif #endif
} }
void WriteStream::WriteTransform(const Transform& transform, bool useDouble) void WriteStream::Write(const Transform& transform, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Write(transform); WriteBytes(&transform, sizeof(Transform));
else else
{ {
Float3 translation = transform.Translation; Float3 translation = transform.Translation;
@@ -1061,15 +1081,15 @@ void WriteStream::WriteTransform(const Transform& transform, bool useDouble)
Write(transform.Scale); Write(transform.Scale);
} }
else else
Write(transform); WriteBytes(&transform, sizeof(Transform));
#endif #endif
} }
void WriteStream::WriteRay(const Ray& ray, bool useDouble) void WriteStream::Write(const Ray& ray, bool useDouble)
{ {
#if USE_LARGE_WORLDS #if USE_LARGE_WORLDS
if (useDouble) if (useDouble)
Write(ray); WriteBytes(&ray, sizeof(Ray));
else else
{ {
Float3 position = ray.Position, direction = ray.Direction; Float3 position = ray.Position, direction = ray.Direction;
@@ -1084,10 +1104,30 @@ void WriteStream::WriteRay(const Ray& ray, bool useDouble)
Write(direction); Write(direction);
} }
else else
Write(ray); WriteBytes(&ray, sizeof(Ray));
#endif #endif
} }
void WriteStream::WriteBoundingBox(const BoundingBox& box, bool useDouble)
{
Write(box, useDouble);
}
void WriteStream::WriteBoundingSphere(const BoundingSphere& sphere, bool useDouble)
{
Write(sphere, useDouble);
}
void WriteStream::WriteTransform(const Transform& transform, bool useDouble)
{
Write(transform, useDouble);
}
void WriteStream::WriteRay(const Ray& ray, bool useDouble)
{
Write(ray, useDouble);
}
Array<byte> JsonSerializer::SaveToBytes(ISerializable* obj) Array<byte> JsonSerializer::SaveToBytes(ISerializable* obj)
{ {
Array<byte> result; Array<byte> result;

View File

@@ -178,6 +178,23 @@ public:
Write(v.Get()); Write(v.Get());
} }
template<typename T>
void Write(const Span<T>& data)
{
const int32 size = data.Length();
WriteInt32(size);
if (size > 0)
{
if (TIsPODType<T>::Value && !TIsPointer<T>::Value)
WriteBytes(data.Get(), size * sizeof(T));
else
{
for (int32 i = 0; i < size; i++)
Write(data[i]);
}
}
}
template<typename T, typename AllocationType = HeapAllocation> template<typename T, typename AllocationType = HeapAllocation>
void Write(const Array<T, AllocationType>& data) void Write(const Array<T, AllocationType>& data)
{ {
@@ -216,42 +233,49 @@ public:
void WriteJson(ISerializable* obj, const void* otherObj = nullptr); void WriteJson(ISerializable* obj, const void* otherObj = nullptr);
void WriteJson(const StringAnsiView& json); void WriteJson(const StringAnsiView& json);
// Serialization of math types with float or double depending on the context (must match deserialization)
// Set useDouble=true to explicitly use 64-bit precision for serialized data
void Write(const BoundingBox& box, bool useDouble = false);
void Write(const BoundingSphere& sphere, bool useDouble = false);
void Write(const Transform& transform, bool useDouble = false);
void Write(const Ray& ray, bool useDouble = false);
public: public:
// Writes String to the stream // Writes String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write // @param data Data to write
void WriteString(const StringView& data); DEPRECATED("Use Write method") void WriteString(const StringView& data);
// Writes String to the stream // Writes String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write // @param data Data to write
// @param lock Characters pass in the stream // @param lock Characters pass in the stream
void WriteString(const StringView& data, int16 lock); DEPRECATED("Use Write method") void WriteString(const StringView& data, int16 lock);
// Writes Ansi String to the stream // Writes Ansi String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
void WriteStringAnsi(const StringAnsiView& data); DEPRECATED("Use Write method") void WriteStringAnsi(const StringAnsiView& data);
// Writes Ansi String to the stream // Writes Ansi String to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write // @param data Data to write
// @param lock Characters pass in the stream // @param lock Characters pass in the stream
void WriteStringAnsi(const StringAnsiView& data, int8 lock); DEPRECATED("Use Write method") void WriteStringAnsi(const StringAnsiView& data, int8 lock);
// Writes CommonValue to the stream // Writes CommonValue to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write // @param data Data to write
void WriteCommonValue(const CommonValue& data); DEPRECATED("Use Write method") void WriteCommonValue(const CommonValue& data);
// Writes VariantType to the stream // Writes VariantType to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write // @param data Data to write
void WriteVariantType(const VariantType& data); DEPRECATED("Use Write method") void WriteVariantType(const VariantType& data);
// Writes Variant to the stream // Writes Variant to the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024] /// [Deprecated on 11.10.2022, expires on 11.10.2024]
// @param data Data to write // @param data Data to write
void WriteVariant(const Variant& data); DEPRECATED("Use Write method") void WriteVariant(const Variant& data);
/// <summary> /// <summary>
/// Write data array /// Write data array
@@ -259,18 +283,21 @@ public:
/// </summary> /// </summary>
/// <param name="data">Array to write</param> /// <param name="data">Array to write</param>
template<typename T, typename AllocationType = HeapAllocation> template<typename T, typename AllocationType = HeapAllocation>
FORCE_INLINE void WriteArray(const Array<T, AllocationType>& data) DEPRECATED("Use Write method") FORCE_INLINE void WriteArray(const Array<T, AllocationType>& data)
{ {
Write(data); Write(data);
} }
public:
// Serialization of math types with float or double depending on the context (must match deserialization) // Serialization of math types with float or double depending on the context (must match deserialization)
// Set useDouble=true to explicitly use 64-bit precision for serialized data // Set useDouble=true to explicitly use 64-bit precision for serialized data
void WriteBoundingBox(const BoundingBox& box, bool useDouble = false); // [Deprecated in v1.10]
void WriteBoundingSphere(const BoundingSphere& sphere, bool useDouble = false); DEPRECATED("Use Write method") void WriteBoundingBox(const BoundingBox& box, bool useDouble = false);
void WriteTransform(const Transform& transform, bool useDouble = false); // [Deprecated in v1.10]
void WriteRay(const Ray& ray, bool useDouble = false); DEPRECATED("Use Write method") void WriteBoundingSphere(const BoundingSphere& sphere, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Write method") void WriteTransform(const Transform& transform, bool useDouble = false);
// [Deprecated in v1.10]
DEPRECATED("Use Write method") void WriteRay(const Ray& ray, bool useDouble = false);
public: public:
// [Stream] // [Stream]

View File

@@ -67,11 +67,11 @@ bool ShaderCompiler::Compile(ShaderCompilationContext* context)
return true; return true;
// [Output] Constant Buffers // [Output] Constant Buffers
output->WriteByte((byte)_constantBuffers.Count()); output->Write((byte)_constantBuffers.Count());
for (const ShaderResourceBuffer& cb : _constantBuffers) for (const ShaderResourceBuffer& cb : _constantBuffers)
{ {
output->WriteByte(cb.Slot); output->Write((byte)cb.Slot);
output->WriteUint32(cb.Size); output->Write((uint32)cb.Size);
} }
// Additional Data Start // Additional Data Start
@@ -82,7 +82,7 @@ bool ShaderCompiler::Compile(ShaderCompilationContext* context)
for (auto& include : context->Includes) for (auto& include : context->Includes)
{ {
String compactPath = ShadersCompilation::CompactShaderPath(include.Item); String compactPath = ShadersCompilation::CompactShaderPath(include.Item);
output->WriteString(compactPath, 11); output->Write(compactPath, 11);
const auto date = FileSystem::GetFileLastEditTime(include.Item); const auto date = FileSystem::GetFileLastEditTime(include.Item);
output->Write(date); output->Write(date);
} }
@@ -261,19 +261,10 @@ bool ShaderCompiler::OnCompileEnd()
bool ShaderCompiler::WriteShaderFunctionBegin(ShaderCompilationContext* context, ShaderFunctionMeta& meta) bool ShaderCompiler::WriteShaderFunctionBegin(ShaderCompilationContext* context, ShaderFunctionMeta& meta)
{ {
auto output = context->Output; auto output = context->Output;
output->Write((byte)meta.GetStage());
// [Output] Type output->Write((byte)meta.Permutations.Count());
output->WriteByte(static_cast<byte>(meta.GetStage())); output->Write(meta.Name, 11);
output->Write((uint32)meta.Flags);
// [Output] Permutations count
output->WriteByte(meta.Permutations.Count());
// [Output] Shader function name
output->WriteStringAnsi(meta.Name, 11);
// [Output] Shader flags
output->WriteUint32((uint32)meta.Flags);
return false; return false;
} }
@@ -281,28 +272,19 @@ bool ShaderCompiler::WriteShaderFunctionPermutation(ShaderCompilationContext* co
{ {
auto output = context->Output; auto output = context->Output;
// [Output] Write compiled shader cache output->Write((uint32)(cacheSize + headerSize));
output->WriteUint32(cacheSize + headerSize);
output->WriteBytes(header, headerSize); output->WriteBytes(header, headerSize);
output->WriteBytes(cache, cacheSize); output->WriteBytes(cache, cacheSize);
// [Output] Shader bindings meta
output->Write(bindings); output->Write(bindings);
return false; return false;
} }
bool ShaderCompiler::WriteShaderFunctionPermutation(ShaderCompilationContext* context, ShaderFunctionMeta& meta, int32 permutationIndex, const ShaderBindings& bindings, const void* cache, int32 cacheSize) bool ShaderCompiler::WriteShaderFunctionPermutation(ShaderCompilationContext* context, ShaderFunctionMeta& meta, int32 permutationIndex, const ShaderBindings& bindings, const void* cache, int32 cacheSize)
{ {
auto output = context->Output; auto output = context->Output;
output->Write((uint32)cacheSize);
// [Output] Write compiled shader cache
output->WriteUint32(cacheSize);
output->WriteBytes(cache, cacheSize); output->WriteBytes(cache, cacheSize);
// [Output] Shader bindings meta
output->Write(bindings); output->Write(bindings);
return false; return false;
} }

View File

@@ -402,7 +402,7 @@ void ShadersCompilation::ExtractShaderIncludes(byte* shaderCache, int32 shaderCa
for (int32 i = 0; i < includesCount; i++) for (int32 i = 0; i < includesCount; i++)
{ {
String& include = includes.AddOne(); String& include = includes.AddOne();
stream.ReadString(&include, 11); stream.Read(include, 11);
include = ShadersCompilation::ResolveShaderPath(include); include = ShadersCompilation::ResolveShaderPath(include);
DateTime lastEditTime; DateTime lastEditTime;
stream.Read(lastEditTime); stream.Read(lastEditTime);

View File

@@ -101,11 +101,11 @@ public:
for (int32 i = 0; i < Parameters.Count(); i++) for (int32 i = 0; i < Parameters.Count(); i++)
{ {
const Parameter* param = &Parameters[i]; const Parameter* param = &Parameters[i];
stream->WriteVariantType(param->Type); stream->Write(param->Type);
stream->Write(param->Identifier); stream->Write(param->Identifier);
stream->WriteString(param->Name, 97); stream->Write(param->Name, 97);
stream->WriteBool(param->IsPublic); stream->WriteBool(param->IsPublic);
stream->WriteVariant(param->Value); stream->Write(param->Value);
if (param->Meta.Save(stream, saveMeta)) if (param->Meta.Save(stream, saveMeta))
return true; return true;
} }
@@ -119,7 +119,7 @@ public:
// Values // Values
stream->WriteInt32(node->Values.Count()); stream->WriteInt32(node->Values.Count());
for (int32 j = 0; j < node->Values.Count(); j++) for (int32 j = 0; j < node->Values.Count(); j++)
stream->WriteVariant(node->Values[j]); stream->Write(node->Values[j]);
// Boxes // Boxes
node->GetBoxes(boxes); node->GetBoxes(boxes);
@@ -128,7 +128,7 @@ public:
{ {
const Box* box = boxes[j]; const Box* box = boxes[j];
stream->WriteByte(box->ID); stream->WriteByte(box->ID);
stream->WriteVariantType(box->Type); stream->Write(box->Type);
stream->WriteUint16(box->Connections.Count()); stream->WriteUint16(box->Connections.Count());
for (int32 k = 0; k < box->Connections.Count(); k++) for (int32 k = 0; k < box->Connections.Count(); k++)
{ {
@@ -222,7 +222,7 @@ public:
// Properties // Properties
auto type = stream->ReadByte(); auto type = stream->ReadByte();
stream->Read(param->Identifier); stream->Read(param->Identifier);
stream->ReadString(&param->Name, 97); stream->Read(param->Name, 97);
param->IsPublic = stream->ReadBool(); param->IsPublic = stream->ReadBool();
bool isStatic = stream->ReadBool(); bool isStatic = stream->ReadBool();
bool isUIVisible = stream->ReadBool(); bool isUIVisible = stream->ReadBool();
@@ -358,11 +358,11 @@ public:
for (int32 i = 0; i < parametersCount; i++) for (int32 i = 0; i < parametersCount; i++)
{ {
auto param = &Parameters[i]; auto param = &Parameters[i];
stream->ReadVariantType(&param->Type); stream->Read(param->Type);
stream->Read(param->Identifier); stream->Read(param->Identifier);
stream->ReadString(&param->Name, 97); stream->Read(param->Name, 97);
param->IsPublic = stream->ReadBool(); param->IsPublic = stream->ReadBool();
stream->ReadVariant(&param->Value); stream->Read(param->Value);
if (param->Meta.Load(stream, loadMeta)) if (param->Meta.Load(stream, loadMeta))
return true; return true;
if (onParamCreated(param)) if (onParamCreated(param))
@@ -379,7 +379,7 @@ public:
stream->ReadInt32(&valuesCnt); stream->ReadInt32(&valuesCnt);
node->Values.Resize(valuesCnt); node->Values.Resize(valuesCnt);
for (int32 j = 0; j < valuesCnt; j++) for (int32 j = 0; j < valuesCnt; j++)
stream->ReadVariant(&node->Values[j]); stream->Read(node->Values[j]);
// Boxes // Boxes
uint16 boxesCount; uint16 boxesCount;
@@ -392,7 +392,7 @@ public:
Box* box = &node->Boxes[boxID]; Box* box = &node->Boxes[boxID];
box->Parent = node; box->Parent = node;
box->ID = boxID; box->ID = boxID;
stream->ReadVariantType(&box->Type); stream->Read(box->Type);
uint16 connectionsCount; uint16 connectionsCount;
stream->ReadUint16(&connectionsCount); stream->ReadUint16(&connectionsCount);
box->Connections.Resize(connectionsCount); box->Connections.Resize(connectionsCount);

View File

@@ -62,6 +62,7 @@ enum class GraphConnectionType_Deprecated : uint32
#include "Engine/Core/Types/CommonValue.h" #include "Engine/Core/Types/CommonValue.h"
#include "Engine/Level/Actor.h" #include "Engine/Level/Actor.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
FLAXENGINE_API void ReadOldGraphParamValue_Deprecated(byte graphParamType, ReadStream* stream, GraphParameter* param) FLAXENGINE_API void ReadOldGraphParamValue_Deprecated(byte graphParamType, ReadStream* stream, GraphParameter* param)
{ {
// [Deprecated on 31.07.2020, expires on 31.07.2022] // [Deprecated on 31.07.2020, expires on 31.07.2022]
@@ -290,6 +291,7 @@ FLAXENGINE_API StringView GetGraphFunctionTypeName_Deprecated(const Variant& v)
} }
return StringView::Empty; return StringView::Empty;
} }
PRAGMA_ENABLE_DEPRECATION_WARNINGS
void GraphUtilities::ApplySomeMathHere(Variant& v, Variant& a, MathOp1 op) void GraphUtilities::ApplySomeMathHere(Variant& v, Variant& a, MathOp1 op)
{ {

View File

@@ -625,9 +625,9 @@ void VisjectExecutor::ProcessGroupPacking(Box* box, Node* node, Value& value)
{ {
box = &node->Boxes[boxId]; box = &node->Boxes[boxId];
String fieldName; String fieldName;
stream.ReadString(&fieldName, 11); stream.Read(fieldName, 11);
VariantType fieldType; VariantType fieldType;
stream.ReadVariantType(&fieldType); stream.Read(fieldType);
if (box && box->HasConnection()) if (box && box->HasConnection())
{ {
StringAsANSI<40> fieldNameAnsi(*fieldName, fieldName.Length()); StringAsANSI<40> fieldNameAnsi(*fieldName, fieldName.Length());
@@ -666,9 +666,9 @@ void VisjectExecutor::ProcessGroupPacking(Box* box, Node* node, Value& value)
{ {
box = &node->Boxes[boxId]; box = &node->Boxes[boxId];
String fieldName; String fieldName;
stream.ReadString(&fieldName, 11); stream.Read(fieldName, 11);
VariantType fieldType; VariantType fieldType;
stream.ReadVariantType(&fieldType); stream.Read(fieldType);
if (box && box->HasConnection()) if (box && box->HasConnection())
{ {
const Variant fieldValue = eatBox(node, box->FirstConnection()); const Variant fieldValue = eatBox(node, box->FirstConnection());
@@ -720,9 +720,9 @@ void VisjectExecutor::ProcessGroupPacking(Box* box, Node* node, Value& value)
for (int32 boxId = 1; boxId < node->Boxes.Count(); boxId++) for (int32 boxId = 1; boxId < node->Boxes.Count(); boxId++)
{ {
String fieldName; String fieldName;
stream.ReadString(&fieldName, 11); stream.Read(fieldName, 11);
VariantType fieldType; VariantType fieldType;
stream.ReadVariantType(&fieldType); stream.Read(fieldType);
if (box->ID == boxId) if (box->ID == boxId)
{ {
StringAsANSI<40> fieldNameAnsi(*fieldName, fieldName.Length()); StringAsANSI<40> fieldNameAnsi(*fieldName, fieldName.Length());
@@ -768,9 +768,9 @@ void VisjectExecutor::ProcessGroupPacking(Box* box, Node* node, Value& value)
for (int32 boxId = 1; boxId < node->Boxes.Count(); boxId++) for (int32 boxId = 1; boxId < node->Boxes.Count(); boxId++)
{ {
String fieldName; String fieldName;
stream.ReadString(&fieldName, 11); stream.Read(fieldName, 11);
VariantType fieldType; VariantType fieldType;
stream.ReadVariantType(&fieldType); stream.Read(fieldType);
if (box->ID == boxId) if (box->ID == boxId)
{ {
type.Struct.GetField(structureValue.AsBlob.Data, fieldName, value); type.Struct.GetField(structureValue.AsBlob.Data, fieldName, value);