Refactor raw data ReadSttream and WriteStream to have easier to use API with more features
This commit is contained in:
@@ -323,7 +323,7 @@ bool AnimGraphBase::onNodeLoaded(Node* n)
|
|||||||
|
|
||||||
int32 ruleSize;
|
int32 ruleSize;
|
||||||
stream.ReadInt32(&ruleSize);
|
stream.ReadInt32(&ruleSize);
|
||||||
const auto ruleBytes = (byte*)stream.Read(ruleSize);
|
const auto ruleBytes = (byte*)stream.Move(ruleSize);
|
||||||
|
|
||||||
if (static_cast<int32>(transition.Flags & AnimGraphStateTransition::FlagTypes::Enabled) == 0)
|
if (static_cast<int32>(transition.Flags & AnimGraphStateTransition::FlagTypes::Enabled) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
break;
|
break;
|
||||||
case Track::Types::PostProcessMaterial:
|
case Track::Types::PostProcessMaterial:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<PostProcessMaterialTrack::Data>();
|
const auto trackData = stream.Move<PostProcessMaterialTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
track.Asset = Content::LoadAsync<MaterialBase>(trackData->AssetID);
|
track.Asset = Content::LoadAsync<MaterialBase>(trackData->AssetID);
|
||||||
const auto trackRuntime = _runtimeData.Move<PostProcessMaterialTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<PostProcessMaterialTrack::Runtime>();
|
||||||
@@ -157,12 +157,12 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
{
|
{
|
||||||
// [Deprecated on 03.09.2021 expires on 03.09.2023]
|
// [Deprecated on 03.09.2021 expires on 03.09.2023]
|
||||||
trackRuntime->Count = 1;
|
trackRuntime->Count = 1;
|
||||||
trackRuntime->Media = stream.Read<Media>();
|
trackRuntime->Media = stream.Move<Media>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream.ReadInt32(&trackRuntime->Count);
|
stream.ReadInt32(&trackRuntime->Count);
|
||||||
trackRuntime->Media = stream.Read<Media>(trackRuntime->Count);
|
trackRuntime->Media = stream.Move<Media>(trackRuntime->Count);
|
||||||
}
|
}
|
||||||
if (trackData->AssetID.IsValid() && !track.Asset)
|
if (trackData->AssetID.IsValid() && !track.Asset)
|
||||||
{
|
{
|
||||||
@@ -173,7 +173,7 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
}
|
}
|
||||||
case Track::Types::NestedSceneAnimation:
|
case Track::Types::NestedSceneAnimation:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<NestedSceneAnimationTrack::Data>();
|
const auto trackData = stream.Move<NestedSceneAnimationTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
track.Asset = Content::LoadAsync<SceneAnimation>(trackData->AssetID);
|
track.Asset = Content::LoadAsync<SceneAnimation>(trackData->AssetID);
|
||||||
const auto trackRuntime = _runtimeData.Move<NestedSceneAnimationTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<NestedSceneAnimationTrack::Runtime>();
|
||||||
@@ -189,7 +189,7 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
}
|
}
|
||||||
case Track::Types::ScreenFade:
|
case Track::Types::ScreenFade:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<ScreenFadeTrack::Data>();
|
const auto trackData = stream.Move<ScreenFadeTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
if (trackData->GradientStopsCount < 0)
|
if (trackData->GradientStopsCount < 0)
|
||||||
{
|
{
|
||||||
@@ -198,12 +198,12 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
}
|
}
|
||||||
const auto trackRuntime = _runtimeData.Move<ScreenFadeTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<ScreenFadeTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
trackRuntime->GradientStops = stream.Read<ScreenFadeTrack::GradientStop>(trackData->GradientStopsCount);
|
trackRuntime->GradientStops = stream.Move<ScreenFadeTrack::GradientStop>(trackData->GradientStopsCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Track::Types::Audio:
|
case Track::Types::Audio:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<AudioTrack::Data>();
|
const auto trackData = stream.Move<AudioTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
track.Asset = Content::LoadAsync<AudioClip>(trackData->AssetID);
|
track.Asset = Content::LoadAsync<AudioClip>(trackData->AssetID);
|
||||||
const auto trackRuntime = _runtimeData.Move<AudioTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<AudioTrack::Runtime>();
|
||||||
@@ -222,18 +222,18 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream.ReadInt32(&trackRuntime->Count);
|
stream.ReadInt32(&trackRuntime->Count);
|
||||||
trackRuntime->Media = stream.Read<AudioTrack::Media>(trackRuntime->Count);
|
trackRuntime->Media = stream.Move<AudioTrack::Media>(trackRuntime->Count);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Track::Types::AudioVolume:
|
case Track::Types::AudioVolume:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<AudioVolumeTrack::Data>();
|
const auto trackData = stream.Move<AudioVolumeTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = _runtimeData.Move<AudioVolumeTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<AudioVolumeTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
||||||
trackRuntime->Keyframes = stream.Read<BezierCurveKeyframe<float>>(trackData->KeyframesCount);
|
trackRuntime->Keyframes = stream.Move<BezierCurveKeyframe<float>>(trackData->KeyframesCount);
|
||||||
if (track.ParentIndex != -1)
|
if (track.ParentIndex != -1)
|
||||||
{
|
{
|
||||||
if (Tracks[track.ParentIndex].Type == Track::Types::Audio)
|
if (Tracks[track.ParentIndex].Type == Track::Types::Audio)
|
||||||
@@ -250,7 +250,7 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
}
|
}
|
||||||
case Track::Types::Actor:
|
case Track::Types::Actor:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<ActorTrack::Data>();
|
const auto trackData = stream.Move<ActorTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = _runtimeData.Move<ActorTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<ActorTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
@@ -259,7 +259,7 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
}
|
}
|
||||||
case Track::Types::Script:
|
case Track::Types::Script:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<ScriptTrack::Data>();
|
const auto trackData = stream.Move<ScriptTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = _runtimeData.Move<ScriptTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<ScriptTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
@@ -274,33 +274,33 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
case Track::Types::KeyframesProperty:
|
case Track::Types::KeyframesProperty:
|
||||||
case Track::Types::ObjectReferenceProperty:
|
case Track::Types::ObjectReferenceProperty:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<KeyframesPropertyTrack::Data>();
|
const auto trackData = stream.Move<KeyframesPropertyTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = _runtimeData.Move<KeyframesPropertyTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<KeyframesPropertyTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
track.TrackStateIndex = TrackStatesCount++;
|
track.TrackStateIndex = TrackStatesCount++;
|
||||||
trackRuntime->PropertyName = stream.Read<char>(trackData->PropertyNameLength + 1);
|
trackRuntime->PropertyName = stream.Move<char>(trackData->PropertyNameLength + 1);
|
||||||
trackRuntime->PropertyTypeName = stream.Read<char>(trackData->PropertyTypeNameLength + 1);
|
trackRuntime->PropertyTypeName = stream.Move<char>(trackData->PropertyTypeNameLength + 1);
|
||||||
const int32 keyframesDataSize = trackData->KeyframesCount * (sizeof(float) + trackData->ValueSize);
|
const int32 keyframesDataSize = trackData->KeyframesCount * (sizeof(float) + trackData->ValueSize);
|
||||||
trackRuntime->ValueSize = trackData->ValueSize;
|
trackRuntime->ValueSize = trackData->ValueSize;
|
||||||
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
||||||
trackRuntime->Keyframes = stream.Read(keyframesDataSize);
|
trackRuntime->Keyframes = stream.Move(keyframesDataSize);
|
||||||
needsParent = true;
|
needsParent = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Track::Types::CurveProperty:
|
case Track::Types::CurveProperty:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<CurvePropertyTrack::Data>();
|
const auto trackData = stream.Move<CurvePropertyTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = _runtimeData.Move<CurvePropertyTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<CurvePropertyTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
track.TrackStateIndex = TrackStatesCount++;
|
track.TrackStateIndex = TrackStatesCount++;
|
||||||
trackRuntime->PropertyName = stream.Read<char>(trackData->PropertyNameLength + 1);
|
trackRuntime->PropertyName = stream.Move<char>(trackData->PropertyNameLength + 1);
|
||||||
trackRuntime->PropertyTypeName = stream.Read<char>(trackData->PropertyTypeNameLength + 1);
|
trackRuntime->PropertyTypeName = stream.Move<char>(trackData->PropertyTypeNameLength + 1);
|
||||||
const int32 keyframesDataSize = trackData->KeyframesCount * (sizeof(float) + trackData->ValueSize * 3);
|
const int32 keyframesDataSize = trackData->KeyframesCount * (sizeof(float) + trackData->ValueSize * 3);
|
||||||
trackRuntime->ValueSize = trackData->ValueSize;
|
trackRuntime->ValueSize = trackData->ValueSize;
|
||||||
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
||||||
trackRuntime->Keyframes = stream.Read(keyframesDataSize);
|
trackRuntime->Keyframes = stream.Move(keyframesDataSize);
|
||||||
trackRuntime->DataType = CurvePropertyTrack::DataTypes::Unknown;
|
trackRuntime->DataType = CurvePropertyTrack::DataTypes::Unknown;
|
||||||
trackRuntime->ValueType = CurvePropertyTrack::DataTypes::Unknown;
|
trackRuntime->ValueType = CurvePropertyTrack::DataTypes::Unknown;
|
||||||
if (StringUtils::Compare(trackRuntime->PropertyTypeName, "System.Single") == 0)
|
if (StringUtils::Compare(trackRuntime->PropertyTypeName, "System.Single") == 0)
|
||||||
@@ -367,13 +367,13 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
}
|
}
|
||||||
case Track::Types::StringProperty:
|
case Track::Types::StringProperty:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<StringPropertyTrack::Data>();
|
const auto trackData = stream.Move<StringPropertyTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = (StringPropertyTrack::Runtime*)_runtimeData.Move(sizeof(StringPropertyTrack::Runtime) + sizeof(void*) * 2 * trackData->KeyframesCount);
|
const auto trackRuntime = (StringPropertyTrack::Runtime*)_runtimeData.Move(sizeof(StringPropertyTrack::Runtime) + sizeof(void*) * 2 * trackData->KeyframesCount);
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
track.TrackStateIndex = TrackStatesCount++;
|
track.TrackStateIndex = TrackStatesCount++;
|
||||||
trackRuntime->PropertyName = stream.Read<char>(trackData->PropertyNameLength + 1);
|
trackRuntime->PropertyName = stream.Move<char>(trackData->PropertyNameLength + 1);
|
||||||
trackRuntime->PropertyTypeName = stream.Read<char>(trackData->PropertyTypeNameLength + 1);
|
trackRuntime->PropertyTypeName = stream.Move<char>(trackData->PropertyTypeNameLength + 1);
|
||||||
trackRuntime->ValueSize = trackData->ValueSize;
|
trackRuntime->ValueSize = trackData->ValueSize;
|
||||||
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
trackRuntime->KeyframesCount = trackData->KeyframesCount;
|
||||||
const auto keyframesTimes = (float*)((byte*)trackRuntime + sizeof(StringPropertyTrack::Runtime));
|
const auto keyframesTimes = (float*)((byte*)trackRuntime + sizeof(StringPropertyTrack::Runtime));
|
||||||
@@ -383,7 +383,7 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
{
|
{
|
||||||
stream.ReadFloat(&keyframesTimes[j]);
|
stream.ReadFloat(&keyframesTimes[j]);
|
||||||
stream.ReadInt32(&keyframesLengths[j]);
|
stream.ReadInt32(&keyframesLengths[j]);
|
||||||
keyframesValues[j] = stream.Read<Char>(keyframesLengths[j]);
|
keyframesValues[j] = stream.Move<Char>(keyframesLengths[j]);
|
||||||
}
|
}
|
||||||
needsParent = true;
|
needsParent = true;
|
||||||
break;
|
break;
|
||||||
@@ -391,13 +391,13 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
case Track::Types::StructProperty:
|
case Track::Types::StructProperty:
|
||||||
case Track::Types::ObjectProperty:
|
case Track::Types::ObjectProperty:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<StructPropertyTrack::Data>();
|
const auto trackData = stream.Move<StructPropertyTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = _runtimeData.Move<StructPropertyTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<StructPropertyTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
track.TrackStateIndex = TrackStatesCount++;
|
track.TrackStateIndex = TrackStatesCount++;
|
||||||
trackRuntime->PropertyName = stream.Read<char>(trackData->PropertyNameLength + 1);
|
trackRuntime->PropertyName = stream.Move<char>(trackData->PropertyNameLength + 1);
|
||||||
trackRuntime->PropertyTypeName = stream.Read<char>(trackData->PropertyTypeNameLength + 1);
|
trackRuntime->PropertyTypeName = stream.Move<char>(trackData->PropertyTypeNameLength + 1);
|
||||||
trackRuntime->ValueSize = trackData->ValueSize;
|
trackRuntime->ValueSize = trackData->ValueSize;
|
||||||
needsParent = true;
|
needsParent = true;
|
||||||
break;
|
break;
|
||||||
@@ -411,22 +411,22 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
stream.ReadInt32(&trackRuntime->EventParamsCount);
|
stream.ReadInt32(&trackRuntime->EventParamsCount);
|
||||||
stream.ReadInt32(&trackRuntime->EventsCount);
|
stream.ReadInt32(&trackRuntime->EventsCount);
|
||||||
stream.ReadInt32(&tmp);
|
stream.ReadInt32(&tmp);
|
||||||
trackRuntime->EventName = stream.Read<char>(tmp + 1);
|
trackRuntime->EventName = stream.Move<char>(tmp + 1);
|
||||||
trackRuntime->EventParamsSize = 0;
|
trackRuntime->EventParamsSize = 0;
|
||||||
for (int j = 0; j < trackRuntime->EventParamsCount; j++)
|
for (int j = 0; j < trackRuntime->EventParamsCount; j++)
|
||||||
{
|
{
|
||||||
stream.ReadInt32(&trackRuntime->EventParamSizes[j]);
|
stream.ReadInt32(&trackRuntime->EventParamSizes[j]);
|
||||||
trackRuntime->EventParamsSize += trackRuntime->EventParamSizes[j];
|
trackRuntime->EventParamsSize += trackRuntime->EventParamSizes[j];
|
||||||
stream.ReadInt32(&tmp);
|
stream.ReadInt32(&tmp);
|
||||||
trackRuntime->EventParamTypes[j] = stream.Read<char>(tmp + 1);
|
trackRuntime->EventParamTypes[j] = stream.Move<char>(tmp + 1);
|
||||||
}
|
}
|
||||||
trackRuntime->DataBegin = stream.Read<byte>(trackRuntime->EventsCount * (sizeof(float) + trackRuntime->EventParamsSize));
|
trackRuntime->DataBegin = stream.Move<byte>(trackRuntime->EventsCount * (sizeof(float) + trackRuntime->EventParamsSize));
|
||||||
needsParent = true;
|
needsParent = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Track::Types::CameraCut:
|
case Track::Types::CameraCut:
|
||||||
{
|
{
|
||||||
const auto trackData = stream.Read<CameraCutTrack::Data>();
|
const auto trackData = stream.Move<CameraCutTrack::Data>();
|
||||||
track.Data = trackData;
|
track.Data = trackData;
|
||||||
const auto trackRuntime = _runtimeData.Move<CameraCutTrack::Runtime>();
|
const auto trackRuntime = _runtimeData.Move<CameraCutTrack::Runtime>();
|
||||||
track.RuntimeData = trackRuntime;
|
track.RuntimeData = trackRuntime;
|
||||||
@@ -435,12 +435,12 @@ Asset::LoadResult SceneAnimation::load()
|
|||||||
{
|
{
|
||||||
// [Deprecated on 03.09.2021 expires on 03.09.2023]
|
// [Deprecated on 03.09.2021 expires on 03.09.2023]
|
||||||
trackRuntime->Count = 1;
|
trackRuntime->Count = 1;
|
||||||
trackRuntime->Media = stream.Read<Media>();
|
trackRuntime->Media = stream.Move<Media>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream.ReadInt32(&trackRuntime->Count);
|
stream.ReadInt32(&trackRuntime->Count);
|
||||||
trackRuntime->Media = stream.Read<Media>(trackRuntime->Count);
|
trackRuntime->Media = stream.Move<Media>(trackRuntime->Count);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -981,7 +981,7 @@ Asset::LoadResult Model::load()
|
|||||||
{
|
{
|
||||||
ModelSDFMip mipData;
|
ModelSDFMip mipData;
|
||||||
sdfStream.Read(&mipData);
|
sdfStream.Read(&mipData);
|
||||||
void* mipBytes = sdfStream.Read(mipData.SlicePitch);
|
void* mipBytes = sdfStream.Move(mipData.SlicePitch);
|
||||||
auto task = ::New<StreamModelSDFTask>(this, SDF.Texture, Span<byte>((byte*)mipBytes, mipData.SlicePitch), mipData.MipIndex, mipData.RowPitch, mipData.SlicePitch);
|
auto task = ::New<StreamModelSDFTask>(this, SDF.Texture, Span<byte>((byte*)mipBytes, mipData.SlicePitch), mipData.MipIndex, mipData.RowPitch, mipData.SlicePitch);
|
||||||
task->Start();
|
task->Start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,20 +239,20 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType18>(vertices);
|
auto vb0 = stream.Move<VB0ElementType18>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType18>(vertices);
|
auto vb1 = stream.Move<VB1ElementType18>(vertices);
|
||||||
bool hasColors = stream.ReadBool();
|
bool hasColors = stream.ReadBool();
|
||||||
VB2ElementType18* vb2 = nullptr;
|
VB2ElementType18* vb2 = nullptr;
|
||||||
if (hasColors)
|
if (hasColors)
|
||||||
{
|
{
|
||||||
vb2 = stream.Read<VB2ElementType18>(vertices);
|
vb2 = stream.Move<VB2ElementType18>(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Allocate mesh
|
// Allocate mesh
|
||||||
lod.Meshes[meshIndex] = New<MeshData>();
|
lod.Meshes[meshIndex] = New<MeshData>();
|
||||||
@@ -356,14 +356,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType18>(vertices);
|
auto vb0 = stream.Move<VB0ElementType18>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType18>(vertices);
|
auto vb1 = stream.Move<VB1ElementType18>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Allocate mesh
|
// Allocate mesh
|
||||||
lod.Meshes[meshIndex] = New<MeshData>();
|
lod.Meshes[meshIndex] = New<MeshData>();
|
||||||
@@ -484,14 +484,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType18>(vertices);
|
auto vb0 = stream.Move<VB0ElementType18>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType18>(vertices);
|
auto vb1 = stream.Move<VB1ElementType18>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[lodIndex].Meshes[i];
|
auto& mesh = *data->LODs[lodIndex].Meshes[i];
|
||||||
@@ -567,14 +567,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType18>(vertices);
|
auto vb0 = stream.Move<VB0ElementType18>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType18>(vertices);
|
auto vb1 = stream.Move<VB1ElementType18>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[0].Meshes[i];
|
auto& mesh = *data->LODs[0].Meshes[i];
|
||||||
@@ -642,14 +642,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType18>(vertices);
|
auto vb0 = stream.Move<VB0ElementType18>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType18>(vertices);
|
auto vb1 = stream.Move<VB1ElementType18>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[0].Meshes[i];
|
auto& mesh = *data->LODs[0].Meshes[i];
|
||||||
@@ -718,14 +718,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType18>(vertices);
|
auto vb0 = stream.Move<VB0ElementType18>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType18>(vertices);
|
auto vb1 = stream.Move<VB1ElementType18>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[0].Meshes[i];
|
auto& mesh = *data->LODs[0].Meshes[i];
|
||||||
@@ -798,14 +798,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType18>(vertices);
|
auto vb0 = stream.Move<VB0ElementType18>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType18>(vertices);
|
auto vb1 = stream.Move<VB1ElementType18>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[0].Meshes[i];
|
auto& mesh = *data->LODs[0].Meshes[i];
|
||||||
@@ -879,14 +879,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType15>(vertices);
|
auto vb0 = stream.Move<VB0ElementType15>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType15>(vertices);
|
auto vb1 = stream.Move<VB1ElementType15>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[0].Meshes[i];
|
auto& mesh = *data->LODs[0].Meshes[i];
|
||||||
@@ -960,14 +960,14 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffers
|
// Vertex buffers
|
||||||
auto vb0 = stream.Read<VB0ElementType15>(vertices);
|
auto vb0 = stream.Move<VB0ElementType15>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType15>(vertices);
|
auto vb1 = stream.Move<VB1ElementType15>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[0].Meshes[i];
|
auto& mesh = *data->LODs[0].Meshes[i];
|
||||||
@@ -1042,13 +1042,13 @@ private:
|
|||||||
return Asset::LoadResult::InvalidData;
|
return Asset::LoadResult::InvalidData;
|
||||||
|
|
||||||
// Vertex buffer
|
// Vertex buffer
|
||||||
auto vb = stream.Read<ModelVertex15>(vertices);
|
auto vb = stream.Move<ModelVertex15>(vertices);
|
||||||
|
|
||||||
// Index Buffer
|
// Index Buffer
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Copy data
|
// Copy data
|
||||||
auto& mesh = *data->LODs[0].Meshes[i];
|
auto& mesh = *data->LODs[0].Meshes[i];
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ private:
|
|||||||
const uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
const uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
if (vertices == 0 || triangles == 0)
|
if (vertices == 0 || triangles == 0)
|
||||||
return true;
|
return true;
|
||||||
const auto vb0 = stream.Read<VB0SkinnedElementType1>(vertices);
|
const auto vb0 = stream.Move<VB0SkinnedElementType1>(vertices);
|
||||||
const auto ib = stream.Read<byte>(indicesCount * ibStride);
|
const auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Write back
|
// Write back
|
||||||
output.WriteUint32(vertices);
|
output.WriteUint32(vertices);
|
||||||
@@ -403,9 +403,9 @@ private:
|
|||||||
const uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
const uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
if (vertices == 0 || triangles == 0)
|
if (vertices == 0 || triangles == 0)
|
||||||
return true;
|
return true;
|
||||||
const auto vb0 = stream.Read<VB0SkinnedElementType>(vertices);
|
const auto vb0 = stream.Move<VB0SkinnedElementType>(vertices);
|
||||||
output.Write<VB0SkinnedElementType>(vb0, vertices);
|
output.Write<VB0SkinnedElementType>(vb0, vertices);
|
||||||
const auto ib = stream.Read<byte>(indicesCount * ibStride);
|
const auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
output.Write<byte>(ib, indicesCount * ibStride);
|
output.Write<byte>(ib, indicesCount * ibStride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,15 +53,15 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context)
|
|||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
if (vertices == 0 || triangles == 0)
|
if (vertices == 0 || triangles == 0)
|
||||||
return ExportAssetResult::Error;
|
return ExportAssetResult::Error;
|
||||||
auto vb0 = stream.Read<VB0ElementType>(vertices);
|
auto vb0 = stream.Move<VB0ElementType>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType>(vertices);
|
auto vb1 = stream.Move<VB1ElementType>(vertices);
|
||||||
bool hasColors = stream.ReadBool();
|
bool hasColors = stream.ReadBool();
|
||||||
VB2ElementType18* vb2 = nullptr;
|
VB2ElementType18* vb2 = nullptr;
|
||||||
if (hasColors)
|
if (hasColors)
|
||||||
{
|
{
|
||||||
vb2 = stream.Read<VB2ElementType18>(vertices);
|
vb2 = stream.Move<VB2ElementType18>(vertices);
|
||||||
}
|
}
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
output->WriteText(StringAnsi::Format("# Mesh {0}\n", meshIndex));
|
output->WriteText(StringAnsi::Format("# Mesh {0}\n", meshIndex));
|
||||||
|
|
||||||
@@ -165,8 +165,8 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context
|
|||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
if (vertices == 0 || triangles == 0)
|
if (vertices == 0 || triangles == 0)
|
||||||
return ExportAssetResult::Error;
|
return ExportAssetResult::Error;
|
||||||
auto vb0 = stream.Read<VB0SkinnedElementType>(vertices);
|
auto vb0 = stream.Move<VB0SkinnedElementType>(vertices);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
output->WriteText(StringAnsi::Format("# Mesh {0}\n", meshIndex));
|
output->WriteText(StringAnsi::Format("# Mesh {0}\n", meshIndex));
|
||||||
|
|
||||||
|
|||||||
@@ -578,15 +578,15 @@ bool Mesh::DownloadDataCPU(MeshBufferType type, BytesContainer& result, int32& c
|
|||||||
LOG(Error, "Invalid mesh data.");
|
LOG(Error, "Invalid mesh data.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto vb0 = stream.Read<VB0ElementType>(vertices);
|
auto vb0 = stream.Move<VB0ElementType>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType>(vertices);
|
auto vb1 = stream.Move<VB1ElementType>(vertices);
|
||||||
bool hasColors = stream.ReadBool();
|
bool hasColors = stream.ReadBool();
|
||||||
VB2ElementType18* vb2 = nullptr;
|
VB2ElementType18* vb2 = nullptr;
|
||||||
if (hasColors)
|
if (hasColors)
|
||||||
{
|
{
|
||||||
vb2 = stream.Read<VB2ElementType18>(vertices);
|
vb2 = stream.Move<VB2ElementType18>(vertices);
|
||||||
}
|
}
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
if (i != _index)
|
if (i != _index)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ bool ModelLOD::Load(MemoryReadStream& stream)
|
|||||||
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
if (vertices == 0 || triangles == 0)
|
if (vertices == 0 || triangles == 0)
|
||||||
return true;
|
return true;
|
||||||
auto vb0 = stream.Read<VB0ElementType>(vertices);
|
auto vb0 = stream.Move<VB0ElementType>(vertices);
|
||||||
auto vb1 = stream.Read<VB1ElementType>(vertices);
|
auto vb1 = stream.Move<VB1ElementType>(vertices);
|
||||||
bool hasColors = stream.ReadBool();
|
bool hasColors = stream.ReadBool();
|
||||||
VB2ElementType18* vb2 = nullptr;
|
VB2ElementType18* vb2 = nullptr;
|
||||||
if (hasColors)
|
if (hasColors)
|
||||||
{
|
{
|
||||||
vb2 = stream.Read<VB2ElementType18>(vertices);
|
vb2 = stream.Move<VB2ElementType18>(vertices);
|
||||||
}
|
}
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Setup GPU resources
|
// Setup GPU resources
|
||||||
if (Meshes[i].Load(vertices, triangles, vb0, vb1, vb2, ib, use16BitIndexBuffer))
|
if (Meshes[i].Load(vertices, triangles, vb0, vb1, vb2, ib, use16BitIndexBuffer))
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ bool SkinnedMesh::DownloadDataCPU(MeshBufferType type, BytesContainer& result, i
|
|||||||
stream.ReadUint32(&maxVertexIndex);
|
stream.ReadUint32(&maxVertexIndex);
|
||||||
uint32 blendShapeVertices;
|
uint32 blendShapeVertices;
|
||||||
stream.ReadUint32(&blendShapeVertices);
|
stream.ReadUint32(&blendShapeVertices);
|
||||||
auto blendShapeVerticesData = stream.Read<byte>(blendShapeVertices * sizeof(BlendShapeVertex));
|
auto blendShapeVerticesData = stream.Move<byte>(blendShapeVertices * sizeof(BlendShapeVertex));
|
||||||
}
|
}
|
||||||
uint32 indicesCount = triangles * 3;
|
uint32 indicesCount = triangles * 3;
|
||||||
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
bool use16BitIndexBuffer = indicesCount <= MAX_uint16;
|
||||||
@@ -299,8 +299,8 @@ bool SkinnedMesh::DownloadDataCPU(MeshBufferType type, BytesContainer& result, i
|
|||||||
LOG(Error, "Invalid mesh data.");
|
LOG(Error, "Invalid mesh data.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto vb0 = stream.Read<VB0SkinnedElementType>(vertices);
|
auto vb0 = stream.Move<VB0SkinnedElementType>(vertices);
|
||||||
auto ib = stream.Read<byte>(indicesCount * ibStride);
|
auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
if (i != _index)
|
if (i != _index)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ bool SkinnedModelLOD::Load(MemoryReadStream& stream)
|
|||||||
const uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
const uint32 ibStride = use16BitIndexBuffer ? sizeof(uint16) : sizeof(uint32);
|
||||||
if (vertices == 0 || triangles == 0)
|
if (vertices == 0 || triangles == 0)
|
||||||
return true;
|
return true;
|
||||||
const auto vb0 = stream.Read<VB0SkinnedElementType>(vertices);
|
const auto vb0 = stream.Move<VB0SkinnedElementType>(vertices);
|
||||||
const auto ib = stream.Read<byte>(indicesCount * ibStride);
|
const auto ib = stream.Move<byte>(indicesCount * ibStride);
|
||||||
|
|
||||||
// Setup GPU resources
|
// Setup GPU resources
|
||||||
if (mesh.Load(vertices, triangles, vb0, ib, use16BitIndexBuffer))
|
if (mesh.Load(vertices, triangles, vb0, ib, use16BitIndexBuffer))
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ bool GPUShader::Create(MemoryReadStream& stream)
|
|||||||
LOG(Warning, "Invalid shader cache size.");
|
LOG(Warning, "Invalid shader cache size.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
byte* cache = stream.Read<byte>(cacheSize);
|
byte* cache = stream.Move<byte>(cacheSize);
|
||||||
|
|
||||||
// Read bindings
|
// Read bindings
|
||||||
stream.ReadBytes(&initializer.Bindings, sizeof(ShaderBindings));
|
stream.ReadBytes(&initializer.Bindings, sizeof(ShaderBindings));
|
||||||
|
|||||||
@@ -1568,7 +1568,7 @@ bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeM
|
|||||||
int32 bufferSize;
|
int32 bufferSize;
|
||||||
stream.ReadInt32(&bufferSize);
|
stream.ReadInt32(&bufferSize);
|
||||||
const char* buffer = (const char*)stream.GetPositionHandle();
|
const char* buffer = (const char*)stream.GetPositionHandle();
|
||||||
stream.Read(bufferSize);
|
stream.Move(bufferSize);
|
||||||
|
|
||||||
// Order in parent
|
// Order in parent
|
||||||
int32 orderInParent;
|
int32 orderInParent;
|
||||||
@@ -1612,7 +1612,7 @@ bool Actor::FromBytes(const Span<byte>& data, Array<Actor*>& output, ISerializeM
|
|||||||
int32 bufferSize;
|
int32 bufferSize;
|
||||||
stream.ReadInt32(&bufferSize);
|
stream.ReadInt32(&bufferSize);
|
||||||
const char* buffer = (const char*)stream.GetPositionHandle();
|
const char* buffer = (const char*)stream.GetPositionHandle();
|
||||||
stream.Read(bufferSize);
|
stream.Move(bufferSize);
|
||||||
|
|
||||||
// Order in parent
|
// Order in parent
|
||||||
int32 orderInParent;
|
int32 orderInParent;
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ bool SceneCSGData::TryGetSurfaceData(const Guid& brushId, int32 brushSurfaceInde
|
|||||||
// Invalid data
|
// Invalid data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
stream.Read(trianglesCount * sizeof(Float3) * 3);
|
stream.Move(trianglesCount * sizeof(Float3) * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read surface data
|
// Read surface data
|
||||||
@@ -138,7 +138,7 @@ bool SceneCSGData::TryGetSurfaceData(const Guid& brushId, int32 brushSurfaceInde
|
|||||||
}
|
}
|
||||||
outData.Triangles.Clear();
|
outData.Triangles.Clear();
|
||||||
outData.Triangles.Resize(trianglesCount);
|
outData.Triangles.Resize(trianglesCount);
|
||||||
Float3* src = stream.Read<Float3>(trianglesCount * 3);
|
Float3* src = stream.Move<Float3>(trianglesCount * 3);
|
||||||
Vector3* dst = (Vector3*)outData.Triangles.Get();
|
Vector3* dst = (Vector3*)outData.Triangles.Get();
|
||||||
for (int32 i = 0; i < trianglesCount * 3; i++)
|
for (int32 i = 0; i < trianglesCount * 3; i++)
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ bool NavMeshData::Load(BytesContainer& data, bool copyData)
|
|||||||
MemoryReadStream stream(data.Get(), data.Length());
|
MemoryReadStream stream(data.Get(), data.Length());
|
||||||
|
|
||||||
// Read header
|
// Read header
|
||||||
const auto header = stream.Read<NavMeshDataHeader>(1);
|
const auto header = stream.Move<NavMeshDataHeader>(1);
|
||||||
if (header->Version != 1)
|
if (header->Version != 1)
|
||||||
{
|
{
|
||||||
LOG(Warning, "Invalid valid navmesh data version {0}.", header->Version);
|
LOG(Warning, "Invalid valid navmesh data version {0}.", header->Version);
|
||||||
@@ -70,7 +70,7 @@ bool NavMeshData::Load(BytesContainer& data, bool copyData)
|
|||||||
auto& tile = Tiles[tileIndex];
|
auto& tile = Tiles[tileIndex];
|
||||||
|
|
||||||
// Read tile header
|
// Read tile header
|
||||||
const auto tileHeader = stream.Read<NavMeshTileDataHeader>(1);
|
const auto tileHeader = stream.Move<NavMeshTileDataHeader>(1);
|
||||||
if (tileHeader->DataSize <= 0)
|
if (tileHeader->DataSize <= 0)
|
||||||
{
|
{
|
||||||
LOG(Warning, "Invalid navmesh tile data.");
|
LOG(Warning, "Invalid navmesh tile data.");
|
||||||
@@ -81,7 +81,7 @@ bool NavMeshData::Load(BytesContainer& data, bool copyData)
|
|||||||
tile.Layer = tileHeader->Layer;
|
tile.Layer = tileHeader->Layer;
|
||||||
|
|
||||||
// Read tile data
|
// Read tile data
|
||||||
const auto tileData = stream.Read<byte>(tileHeader->DataSize);
|
const auto tileData = stream.Move<byte>(tileHeader->DataSize);
|
||||||
if (copyData)
|
if (copyData)
|
||||||
{
|
{
|
||||||
tile.Data.Copy(tileData, tileHeader->DataSize);
|
tile.Data.Copy(tileData, tileHeader->DataSize);
|
||||||
|
|||||||
@@ -69,15 +69,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using ReadStream::Read;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads bytes without copying the data.
|
/// Skips the data from the target buffer without reading from it. Moves the read pointer in the buffer forward.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bytes">The amount of bytes to read.</param>
|
/// <param name="bytes">The amount of bytes to read.</param>
|
||||||
/// <returns>The pointer to the data in memory.</returns>
|
/// <returns>The pointer to the data in memory.</returns>
|
||||||
void* Read(uint32 bytes)
|
void* Move(uint32 bytes)
|
||||||
{
|
{
|
||||||
ASSERT(GetLength() - GetPosition() >= bytes);
|
ASSERT(GetLength() - GetPosition() >= bytes);
|
||||||
const auto result = (void*)_position;
|
const auto result = (void*)_position;
|
||||||
@@ -86,24 +83,24 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads given data type from the stream.
|
/// Skips the data from the target buffer without reading from it. Moves the read pointer in the buffer forward.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The pointer to the data in memory.</returns>
|
/// <returns>The pointer to the data in memory.</returns>
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FORCE_INLINE T* Read()
|
FORCE_INLINE T* Move()
|
||||||
{
|
{
|
||||||
return static_cast<T*>(Read(sizeof(T)));
|
return static_cast<T*>(Move(sizeof(T)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads array of given data type from the stream.
|
/// Skips the data from the target buffer without reading from it. Moves the read pointer in the buffer forward.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="count">The amount of items to read.</param>
|
/// <param name="count">The amount of items to read.</param>
|
||||||
/// <returns>The pointer to the data in memory.</returns>
|
/// <returns>The pointer to the data in memory.</returns>
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FORCE_INLINE T* Read(uint32 count)
|
FORCE_INLINE T* Move(uint32 count)
|
||||||
{
|
{
|
||||||
return static_cast<T*>(Read(sizeof(T) * count));
|
return static_cast<T*>(Move(sizeof(T) * count));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -145,49 +145,62 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Reads StringAnsi from the stream
|
void Read(String& data);
|
||||||
// @param data Data to read
|
void Read(String& data, int16 lock);
|
||||||
void ReadStringAnsi(StringAnsi* data);
|
void Read(StringAnsi& data);
|
||||||
|
void Read(StringAnsi& data, int8 lock);
|
||||||
|
void Read(CommonValue& data);
|
||||||
|
void Read(VariantType& data);
|
||||||
|
void Read(Variant& data);
|
||||||
|
|
||||||
// Reads StringAnsi from the stream with a key
|
template<typename T>
|
||||||
// @param data Data to read
|
FORCE_INLINE typename TEnableIf<TIsPODType<T>::Value>::Type Read(T& data)
|
||||||
void ReadStringAnsi(StringAnsi* data, int8 lock);
|
{
|
||||||
|
ReadBytes((void*)&data, sizeof(T));
|
||||||
// Reads String from the stream
|
}
|
||||||
// @param data Data to read
|
|
||||||
void ReadString(String* data);
|
|
||||||
|
|
||||||
// Reads String from the stream
|
|
||||||
// @param data Data to read
|
|
||||||
// @param lock Characters pass in the stream
|
|
||||||
void ReadString(String* data, int16 lock);
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Reads CommonValue from the stream
|
|
||||||
// @param data Data to read
|
|
||||||
void ReadCommonValue(CommonValue* data);
|
|
||||||
|
|
||||||
// Reads VariantType from the stream
|
|
||||||
// @param data Data to read
|
|
||||||
void ReadVariantType(VariantType* data);
|
|
||||||
|
|
||||||
// Reads Variant from the stream
|
|
||||||
// @param data Data to read
|
|
||||||
void ReadVariant(Variant* data);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read data array
|
/// Read data 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 ReadArray(Array<T, AllocationType>* data)
|
void Read(Array<T, AllocationType>& data)
|
||||||
{
|
{
|
||||||
static_assert(TIsPODType<T>::Value, "Only POD types are valid for ReadArray.");
|
|
||||||
int32 size;
|
int32 size;
|
||||||
ReadInt32(&size);
|
ReadInt32(&size);
|
||||||
data->Resize(size, false);
|
data.Resize(size, false);
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
ReadBytes(data->Get(), size * sizeof(T));
|
{
|
||||||
|
if (TIsPODType<T>::Value)
|
||||||
|
ReadBytes(data.Get(), size * sizeof(T));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < size; i++)
|
||||||
|
Read(data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read data dictionary
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Dictionary to read</param>
|
||||||
|
template<typename KeyType, typename ValueType, typename AllocationType = HeapAllocation>
|
||||||
|
void Read(Dictionary<KeyType, ValueType, AllocationType>& data)
|
||||||
|
{
|
||||||
|
int32 count;
|
||||||
|
ReadInt32(&count);
|
||||||
|
data.Clear();
|
||||||
|
data.EnsureCapacity(count);
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
KeyType key;
|
||||||
|
Read(key);
|
||||||
|
Read(data[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -197,6 +210,54 @@ 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);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Reads StringAnsi from the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to read
|
||||||
|
void ReadStringAnsi(StringAnsi* data);
|
||||||
|
|
||||||
|
// Reads StringAnsi from the stream with a key
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to read
|
||||||
|
void ReadStringAnsi(StringAnsi* data, int8 lock);
|
||||||
|
|
||||||
|
// Reads String from the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to read
|
||||||
|
void ReadString(String* data);
|
||||||
|
|
||||||
|
// Reads String from the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to read
|
||||||
|
// @param lock Characters pass in the stream
|
||||||
|
void ReadString(String* data, int16 lock);
|
||||||
|
|
||||||
|
// Reads CommonValue from the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to read
|
||||||
|
void ReadCommonValue(CommonValue* data);
|
||||||
|
|
||||||
|
// Reads VariantType from the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to read
|
||||||
|
void ReadVariantType(VariantType* data);
|
||||||
|
|
||||||
|
// Reads Variant from the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to read
|
||||||
|
void ReadVariant(Variant* data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read data array
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Array to read</param>
|
||||||
|
template<typename T, typename AllocationType = HeapAllocation>
|
||||||
|
void ReadArray(Array<T, AllocationType>* data)
|
||||||
|
{
|
||||||
|
Read(*data);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
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
|
||||||
|
|||||||
@@ -19,40 +19,40 @@
|
|||||||
#include "Engine/Scripting/ManagedCLR/MCore.h"
|
#include "Engine/Scripting/ManagedCLR/MCore.h"
|
||||||
#include "Engine/Scripting/ManagedCLR/MUtils.h"
|
#include "Engine/Scripting/ManagedCLR/MUtils.h"
|
||||||
|
|
||||||
void ReadStream::ReadStringAnsi(StringAnsi* data)
|
void ReadStream::Read(StringAnsi& data)
|
||||||
{
|
{
|
||||||
int32 length;
|
int32 length;
|
||||||
ReadInt32(&length);
|
ReadInt32(&length);
|
||||||
if (length < 0 || length > STREAM_MAX_STRING_LENGTH)
|
if (length < 0 || length > STREAM_MAX_STRING_LENGTH)
|
||||||
{
|
{
|
||||||
_hasError = true;
|
_hasError = true;
|
||||||
*data = "";
|
data = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ReserveSpace(length);
|
data.ReserveSpace(length);
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return;
|
return;
|
||||||
char* ptr = data->Get();
|
char* ptr = data.Get();
|
||||||
ASSERT(ptr != nullptr);
|
ASSERT(ptr != nullptr);
|
||||||
Read(ptr, length);
|
Read(ptr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadStream::ReadStringAnsi(StringAnsi* data, int8 lock)
|
void ReadStream::Read(StringAnsi& data, int8 lock)
|
||||||
{
|
{
|
||||||
int32 length;
|
int32 length;
|
||||||
ReadInt32(&length);
|
ReadInt32(&length);
|
||||||
if (length < 0 || length > STREAM_MAX_STRING_LENGTH)
|
if (length < 0 || length > STREAM_MAX_STRING_LENGTH)
|
||||||
{
|
{
|
||||||
_hasError = true;
|
_hasError = true;
|
||||||
*data = "";
|
data = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ReserveSpace(length);
|
data.ReserveSpace(length);
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return;
|
return;
|
||||||
char* ptr = data->Get();
|
char* ptr = data.Get();
|
||||||
ASSERT(ptr != nullptr);
|
ASSERT(ptr != nullptr);
|
||||||
Read(ptr, length);
|
Read(ptr, length);
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ void ReadStream::ReadStringAnsi(StringAnsi* data, int8 lock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadStream::ReadString(String* data)
|
void ReadStream::Read(String& data)
|
||||||
{
|
{
|
||||||
int32 length;
|
int32 length;
|
||||||
ReadInt32(&length);
|
ReadInt32(&length);
|
||||||
@@ -71,17 +71,17 @@ void ReadStream::ReadString(String* data)
|
|||||||
{
|
{
|
||||||
if (length != 0)
|
if (length != 0)
|
||||||
_hasError = true;
|
_hasError = true;
|
||||||
data->Clear();
|
data.Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ReserveSpace(length);
|
data.ReserveSpace(length);
|
||||||
Char* ptr = data->Get();
|
Char* ptr = data.Get();
|
||||||
ASSERT(ptr != nullptr);
|
ASSERT(ptr != nullptr);
|
||||||
Read(ptr, length);
|
Read(ptr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadStream::ReadString(String* data, int16 lock)
|
void ReadStream::Read(String& data, int16 lock)
|
||||||
{
|
{
|
||||||
int32 length;
|
int32 length;
|
||||||
ReadInt32(&length);
|
ReadInt32(&length);
|
||||||
@@ -89,12 +89,12 @@ void ReadStream::ReadString(String* data, int16 lock)
|
|||||||
{
|
{
|
||||||
if (length != 0)
|
if (length != 0)
|
||||||
_hasError = true;
|
_hasError = true;
|
||||||
data->Clear();
|
data.Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ReserveSpace(length);
|
data.ReserveSpace(length);
|
||||||
Char* ptr = data->Get();
|
Char* ptr = data.Get();
|
||||||
ASSERT(ptr != nullptr);
|
ASSERT(ptr != nullptr);
|
||||||
Read(ptr, length);
|
Read(ptr, length);
|
||||||
|
|
||||||
@@ -105,127 +105,127 @@ void ReadStream::ReadString(String* data, int16 lock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadStream::ReadCommonValue(CommonValue* data)
|
void ReadStream::Read(CommonValue& data)
|
||||||
{
|
{
|
||||||
byte type;
|
byte type;
|
||||||
ReadByte(&type);
|
ReadByte(&type);
|
||||||
switch (static_cast<CommonType>(type))
|
switch (static_cast<CommonType>(type))
|
||||||
{
|
{
|
||||||
case CommonType::Bool:
|
case CommonType::Bool:
|
||||||
data->Set(ReadBool());
|
data.Set(ReadBool());
|
||||||
break;
|
break;
|
||||||
case CommonType::Integer:
|
case CommonType::Integer:
|
||||||
{
|
{
|
||||||
int32 v;
|
int32 v;
|
||||||
ReadInt32(&v);
|
ReadInt32(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Float:
|
case CommonType::Float:
|
||||||
{
|
{
|
||||||
float v;
|
float v;
|
||||||
ReadFloat(&v);
|
ReadFloat(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Vector2:
|
case CommonType::Vector2:
|
||||||
{
|
{
|
||||||
Float2 v;
|
Float2 v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Vector3:
|
case CommonType::Vector3:
|
||||||
{
|
{
|
||||||
Float3 v;
|
Float3 v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Vector4:
|
case CommonType::Vector4:
|
||||||
{
|
{
|
||||||
Float4 v;
|
Float4 v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Color:
|
case CommonType::Color:
|
||||||
{
|
{
|
||||||
Color v;
|
Color v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Guid:
|
case CommonType::Guid:
|
||||||
{
|
{
|
||||||
Guid v;
|
Guid v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::String:
|
case CommonType::String:
|
||||||
{
|
{
|
||||||
String v;
|
String v;
|
||||||
ReadString(&v, 953);
|
ReadString(&v, 953);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Box:
|
case CommonType::Box:
|
||||||
{
|
{
|
||||||
BoundingBox v;
|
BoundingBox v;
|
||||||
ReadBoundingBox(&v);
|
ReadBoundingBox(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Rotation:
|
case CommonType::Rotation:
|
||||||
{
|
{
|
||||||
Quaternion v;
|
Quaternion v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Transform:
|
case CommonType::Transform:
|
||||||
{
|
{
|
||||||
Transform v;
|
Transform v;
|
||||||
ReadTransform(&v);
|
ReadTransform(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Sphere:
|
case CommonType::Sphere:
|
||||||
{
|
{
|
||||||
BoundingSphere v;
|
BoundingSphere v;
|
||||||
ReadBoundingSphere(&v);
|
ReadBoundingSphere(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Rectangle:
|
case CommonType::Rectangle:
|
||||||
{
|
{
|
||||||
Rectangle v;
|
Rectangle v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
case CommonType::Ray:
|
case CommonType::Ray:
|
||||||
{
|
{
|
||||||
Ray v;
|
Ray v;
|
||||||
ReadRay(&v);
|
ReadRay(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Matrix:
|
case CommonType::Matrix:
|
||||||
{
|
{
|
||||||
Matrix v;
|
Matrix v;
|
||||||
Read(&v);
|
Read(&v);
|
||||||
data->Set(v);
|
data.Set(v);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommonType::Blob:
|
case CommonType::Blob:
|
||||||
{
|
{
|
||||||
int32 length;
|
int32 length;
|
||||||
Read(&length);
|
Read(&length);
|
||||||
data->SetBlob(length);
|
data.SetBlob(length);
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
ReadBytes(data->AsBlob.Data, length);
|
ReadBytes(data.AsBlob.Data, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -233,9 +233,9 @@ void ReadStream::ReadCommonValue(CommonValue* data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadStream::ReadVariantType(VariantType* data)
|
void ReadStream::Read(VariantType& data)
|
||||||
{
|
{
|
||||||
*data = VariantType((VariantType::Types)ReadByte());
|
data = VariantType((VariantType::Types)ReadByte());
|
||||||
int32 typeNameLength;
|
int32 typeNameLength;
|
||||||
ReadInt32(&typeNameLength);
|
ReadInt32(&typeNameLength);
|
||||||
if (typeNameLength == MAX_int32)
|
if (typeNameLength == MAX_int32)
|
||||||
@@ -243,8 +243,8 @@ void ReadStream::ReadVariantType(VariantType* data)
|
|||||||
ReadInt32(&typeNameLength);
|
ReadInt32(&typeNameLength);
|
||||||
if (typeNameLength == 0)
|
if (typeNameLength == 0)
|
||||||
return;
|
return;
|
||||||
data->TypeName = static_cast<char*>(Allocator::Allocate(typeNameLength + 1));
|
data.TypeName = static_cast<char*>(Allocator::Allocate(typeNameLength + 1));
|
||||||
char* ptr = data->TypeName;
|
char* ptr = data.TypeName;
|
||||||
Read(ptr, typeNameLength);
|
Read(ptr, typeNameLength);
|
||||||
for (int32 i = 0; i < typeNameLength; i++)
|
for (int32 i = 0; i < typeNameLength; i++)
|
||||||
{
|
{
|
||||||
@@ -267,55 +267,55 @@ void ReadStream::ReadVariantType(VariantType* data)
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
data->TypeName = static_cast<char*>(Allocator::Allocate(typeNameLength + 1));
|
data.TypeName = static_cast<char*>(Allocator::Allocate(typeNameLength + 1));
|
||||||
StringUtils::ConvertUTF162ANSI(chars.Get(), data->TypeName, typeNameLength);
|
StringUtils::ConvertUTF162ANSI(chars.Get(), data.TypeName, typeNameLength);
|
||||||
data->TypeName[typeNameLength] = 0;
|
data.TypeName[typeNameLength] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadStream::ReadVariant(Variant* data)
|
void ReadStream::Read(Variant& data)
|
||||||
{
|
{
|
||||||
VariantType type;
|
VariantType type;
|
||||||
ReadVariantType(&type);
|
ReadVariantType(&type);
|
||||||
data->SetType(MoveTemp(type));
|
data.SetType(MoveTemp(type));
|
||||||
switch (data->Type.Type)
|
switch (data.Type.Type)
|
||||||
{
|
{
|
||||||
case VariantType::Null:
|
case VariantType::Null:
|
||||||
case VariantType::Void:
|
case VariantType::Void:
|
||||||
break;
|
break;
|
||||||
case VariantType::Bool:
|
case VariantType::Bool:
|
||||||
data->AsBool = ReadBool();
|
data.AsBool = ReadBool();
|
||||||
break;
|
break;
|
||||||
case VariantType::Int16:
|
case VariantType::Int16:
|
||||||
ReadInt16(&data->AsInt16);
|
ReadInt16(&data.AsInt16);
|
||||||
break;
|
break;
|
||||||
case VariantType::Uint16:
|
case VariantType::Uint16:
|
||||||
ReadUint16(&data->AsUint16);
|
ReadUint16(&data.AsUint16);
|
||||||
break;
|
break;
|
||||||
case VariantType::Int:
|
case VariantType::Int:
|
||||||
ReadInt32(&data->AsInt);
|
ReadInt32(&data.AsInt);
|
||||||
break;
|
break;
|
||||||
case VariantType::Uint:
|
case VariantType::Uint:
|
||||||
ReadUint32(&data->AsUint);
|
ReadUint32(&data.AsUint);
|
||||||
break;
|
break;
|
||||||
case VariantType::Int64:
|
case VariantType::Int64:
|
||||||
ReadInt64(&data->AsInt64);
|
ReadInt64(&data.AsInt64);
|
||||||
break;
|
break;
|
||||||
case VariantType::Uint64:
|
case VariantType::Uint64:
|
||||||
case VariantType::Enum:
|
case VariantType::Enum:
|
||||||
ReadUint64(&data->AsUint64);
|
ReadUint64(&data.AsUint64);
|
||||||
break;
|
break;
|
||||||
case VariantType::Float:
|
case VariantType::Float:
|
||||||
ReadFloat(&data->AsFloat);
|
ReadFloat(&data.AsFloat);
|
||||||
break;
|
break;
|
||||||
case VariantType::Double:
|
case VariantType::Double:
|
||||||
ReadDouble(&data->AsDouble);
|
ReadDouble(&data.AsDouble);
|
||||||
break;
|
break;
|
||||||
case VariantType::Pointer:
|
case VariantType::Pointer:
|
||||||
{
|
{
|
||||||
uint64 asUint64;
|
uint64 asUint64;
|
||||||
ReadUint64(&asUint64);
|
ReadUint64(&asUint64);
|
||||||
data->AsPointer = (void*)(uintptr)asUint64;
|
data.AsPointer = (void*)(uintptr)asUint64;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VariantType::String:
|
case VariantType::String:
|
||||||
@@ -324,13 +324,13 @@ void ReadStream::ReadVariant(Variant* data)
|
|||||||
ReadInt32(&length);
|
ReadInt32(&length);
|
||||||
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
||||||
const int32 dataLength = length * sizeof(Char) + 2;
|
const int32 dataLength = length * sizeof(Char) + 2;
|
||||||
if (data->AsBlob.Length != dataLength)
|
if (data.AsBlob.Length != dataLength)
|
||||||
{
|
{
|
||||||
Allocator::Free(data->AsBlob.Data);
|
Allocator::Free(data.AsBlob.Data);
|
||||||
data->AsBlob.Data = dataLength > 0 ? Allocator::Allocate(dataLength) : nullptr;
|
data.AsBlob.Data = dataLength > 0 ? Allocator::Allocate(dataLength) : nullptr;
|
||||||
data->AsBlob.Length = dataLength;
|
data.AsBlob.Length = dataLength;
|
||||||
}
|
}
|
||||||
Char* ptr = (Char*)data->AsBlob.Data;
|
Char* ptr = (Char*)data.AsBlob.Data;
|
||||||
Read(ptr, length);
|
Read(ptr, length);
|
||||||
for (int32 i = 0; i < length; i++)
|
for (int32 i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
@@ -344,7 +344,7 @@ void ReadStream::ReadVariant(Variant* data)
|
|||||||
{
|
{
|
||||||
Guid id;
|
Guid id;
|
||||||
Read(&id);
|
Read(&id);
|
||||||
data->SetObject(FindObject(id, ScriptingObject::GetStaticClass()));
|
data.SetObject(FindObject(id, ScriptingObject::GetStaticClass()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VariantType::ManagedObject:
|
case VariantType::ManagedObject:
|
||||||
@@ -362,30 +362,30 @@ void ReadStream::ReadVariant(Variant* data)
|
|||||||
ReadStringAnsi(&json, -71);
|
ReadStringAnsi(&json, -71);
|
||||||
#if USE_MONO
|
#if USE_MONO
|
||||||
MCore::AttachThread();
|
MCore::AttachThread();
|
||||||
MonoClass* klass = MUtils::GetClass(data->Type);
|
MonoClass* klass = MUtils::GetClass(data.Type);
|
||||||
if (!klass)
|
if (!klass)
|
||||||
{
|
{
|
||||||
LOG(Error, "Invalid variant type {0}", data->Type);
|
LOG(Error, "Invalid variant type {0}", data.Type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MonoObject* obj = mono_object_new(mono_domain_get(), klass);
|
MonoObject* obj = mono_object_new(mono_domain_get(), klass);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
LOG(Error, "Failed to managed instance of the variant type {0}", data->Type);
|
LOG(Error, "Failed to managed instance of the variant type {0}", data.Type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mono_class_is_valuetype(klass))
|
if (!mono_class_is_valuetype(klass))
|
||||||
mono_runtime_object_init(obj);
|
mono_runtime_object_init(obj);
|
||||||
ManagedSerialization::Deserialize(json, obj);
|
ManagedSerialization::Deserialize(json, obj);
|
||||||
if (data->Type.Type == VariantType::ManagedObject)
|
if (data.Type.Type == VariantType::ManagedObject)
|
||||||
data->SetManagedObject(obj);
|
data.SetManagedObject(obj);
|
||||||
else
|
else
|
||||||
*data = MUtils::UnboxVariant(obj);
|
data = MUtils::UnboxVariant(obj);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG(Error, "Invalid Variant {0) format {1}", data->Type.ToString(), format);
|
LOG(Error, "Invalid Variant {0) format {1}", data.Type.ToString(), format);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -393,67 +393,67 @@ void ReadStream::ReadVariant(Variant* data)
|
|||||||
{
|
{
|
||||||
int32 length;
|
int32 length;
|
||||||
ReadInt32(&length);
|
ReadInt32(&length);
|
||||||
data->SetBlob(length);
|
data.SetBlob(length);
|
||||||
ReadBytes(data->AsBlob.Data, length);
|
ReadBytes(data.AsBlob.Data, length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VariantType::Asset:
|
case VariantType::Asset:
|
||||||
{
|
{
|
||||||
Guid id;
|
Guid id;
|
||||||
Read(&id);
|
Read(&id);
|
||||||
data->SetAsset(LoadAsset(id, Asset::TypeInitializer));
|
data.SetAsset(LoadAsset(id, Asset::TypeInitializer));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VariantType::Float2:
|
case VariantType::Float2:
|
||||||
ReadBytes(&data->AsData, sizeof(Float2));
|
ReadBytes(&data.AsData, sizeof(Float2));
|
||||||
break;
|
break;
|
||||||
case VariantType::Float3:
|
case VariantType::Float3:
|
||||||
ReadBytes(&data->AsData, sizeof(Float3));
|
ReadBytes(&data.AsData, sizeof(Float3));
|
||||||
break;
|
break;
|
||||||
case VariantType::Float4:
|
case VariantType::Float4:
|
||||||
ReadBytes(&data->AsData, sizeof(Float4));
|
ReadBytes(&data.AsData, sizeof(Float4));
|
||||||
break;
|
break;
|
||||||
case VariantType::Double2:
|
case VariantType::Double2:
|
||||||
ReadBytes(&data->AsData, sizeof(Double2));
|
ReadBytes(&data.AsData, sizeof(Double2));
|
||||||
break;
|
break;
|
||||||
case VariantType::Double3:
|
case VariantType::Double3:
|
||||||
ReadBytes(&data->AsData, sizeof(Double3));
|
ReadBytes(&data.AsData, sizeof(Double3));
|
||||||
break;
|
break;
|
||||||
case VariantType::Double4:
|
case VariantType::Double4:
|
||||||
ReadBytes(data->AsBlob.Data, sizeof(Double4));
|
ReadBytes(data.AsBlob.Data, sizeof(Double4));
|
||||||
break;
|
break;
|
||||||
case VariantType::Color:
|
case VariantType::Color:
|
||||||
ReadBytes(&data->AsData, sizeof(Color));
|
ReadBytes(&data.AsData, sizeof(Color));
|
||||||
break;
|
break;
|
||||||
case VariantType::Guid:
|
case VariantType::Guid:
|
||||||
ReadBytes(&data->AsData, sizeof(Guid));
|
ReadBytes(&data.AsData, sizeof(Guid));
|
||||||
break;
|
break;
|
||||||
case VariantType::BoundingBox:
|
case VariantType::BoundingBox:
|
||||||
ReadBoundingBox(&data->AsBoundingBox());
|
ReadBoundingBox(&data.AsBoundingBox());
|
||||||
break;
|
break;
|
||||||
case VariantType::BoundingSphere:
|
case VariantType::BoundingSphere:
|
||||||
ReadBoundingSphere(&data->AsBoundingSphere());
|
ReadBoundingSphere(&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((Transform*)&data->AsData);
|
ReadTransform((Transform*)&data.AsData);
|
||||||
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());
|
ReadRay(&data.AsRay());
|
||||||
break;
|
break;
|
||||||
case VariantType::Matrix:
|
case VariantType::Matrix:
|
||||||
ReadBytes(data->AsBlob.Data, sizeof(Matrix));
|
ReadBytes(data.AsBlob.Data, sizeof(Matrix));
|
||||||
break;
|
break;
|
||||||
case VariantType::Array:
|
case VariantType::Array:
|
||||||
{
|
{
|
||||||
int32 count;
|
int32 count;
|
||||||
ReadInt32(&count);
|
ReadInt32(&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]);
|
ReadVariant(&array[i]);
|
||||||
@@ -463,7 +463,7 @@ void ReadStream::ReadVariant(Variant* data)
|
|||||||
{
|
{
|
||||||
int32 count;
|
int32 count;
|
||||||
ReadInt32(&count);
|
ReadInt32(&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++)
|
||||||
@@ -480,13 +480,13 @@ void ReadStream::ReadVariant(Variant* data)
|
|||||||
ReadInt32(&length);
|
ReadInt32(&length);
|
||||||
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
||||||
const int32 dataLength = length + 1;
|
const int32 dataLength = length + 1;
|
||||||
if (data->AsBlob.Length != dataLength)
|
if (data.AsBlob.Length != dataLength)
|
||||||
{
|
{
|
||||||
Allocator::Free(data->AsBlob.Data);
|
Allocator::Free(data.AsBlob.Data);
|
||||||
data->AsBlob.Data = dataLength > 0 ? Allocator::Allocate(dataLength) : nullptr;
|
data.AsBlob.Data = dataLength > 0 ? Allocator::Allocate(dataLength) : nullptr;
|
||||||
data->AsBlob.Length = dataLength;
|
data.AsBlob.Length = dataLength;
|
||||||
}
|
}
|
||||||
char* ptr = (char*)data->AsBlob.Data;
|
char* ptr = (char*)data.AsBlob.Data;
|
||||||
Read(ptr, length);
|
Read(ptr, length);
|
||||||
for (int32 i = 0; i < length; i++)
|
for (int32 i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
@@ -510,7 +510,7 @@ void ReadStream::ReadJson(ISerializable* obj)
|
|||||||
{
|
{
|
||||||
if (const auto memoryStream = dynamic_cast<MemoryReadStream*>(this))
|
if (const auto memoryStream = dynamic_cast<MemoryReadStream*>(this))
|
||||||
{
|
{
|
||||||
JsonSerializer::LoadFromBytes(obj, Span<byte>((byte*)memoryStream->Read(size), size), engineBuild);
|
JsonSerializer::LoadFromBytes(obj, Span<byte>((byte*)memoryStream->Move(size), size), engineBuild);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -524,6 +524,41 @@ void ReadStream::ReadJson(ISerializable* obj)
|
|||||||
SetPosition(GetPosition() + size);
|
SetPosition(GetPosition() + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReadStream::ReadStringAnsi(StringAnsi* data)
|
||||||
|
{
|
||||||
|
Read(*data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadStream::ReadStringAnsi(StringAnsi* data, int8 lock)
|
||||||
|
{
|
||||||
|
Read(*data, lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadStream::ReadString(String* data)
|
||||||
|
{
|
||||||
|
Read(*data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadStream::ReadString(String* data, int16 lock)
|
||||||
|
{
|
||||||
|
Read(*data, lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadStream::ReadCommonValue(CommonValue* data)
|
||||||
|
{
|
||||||
|
Read(*data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadStream::ReadVariantType(VariantType* data)
|
||||||
|
{
|
||||||
|
Read(*data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadStream::ReadVariant(Variant* data)
|
||||||
|
{
|
||||||
|
Read(*data);
|
||||||
|
}
|
||||||
|
|
||||||
void ReadStream::ReadBoundingBox(BoundingBox* box, bool useDouble)
|
void ReadStream::ReadBoundingBox(BoundingBox* box, bool useDouble)
|
||||||
{
|
{
|
||||||
#if USE_LARGE_WORLDS
|
#if USE_LARGE_WORLDS
|
||||||
@@ -644,7 +679,7 @@ void WriteStream::WriteText(const StringAnsiView& text)
|
|||||||
WriteBytes(text.Get(), sizeof(char) * text.Length());
|
WriteBytes(text.Get(), sizeof(char) * text.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteStream::WriteString(const StringView& data)
|
void WriteStream::Write(const StringView& data)
|
||||||
{
|
{
|
||||||
const int32 length = data.Length();
|
const int32 length = data.Length();
|
||||||
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
||||||
@@ -652,7 +687,7 @@ void WriteStream::WriteString(const StringView& data)
|
|||||||
Write(*data, length);
|
Write(*data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteStream::WriteString(const StringView& data, int16 lock)
|
void WriteStream::Write(const StringView& data, int16 lock)
|
||||||
{
|
{
|
||||||
ASSERT(data.Length() < STREAM_MAX_STRING_LENGTH);
|
ASSERT(data.Length() < STREAM_MAX_STRING_LENGTH);
|
||||||
WriteInt32(data.Length());
|
WriteInt32(data.Length());
|
||||||
@@ -660,7 +695,7 @@ void WriteStream::WriteString(const StringView& data, int16 lock)
|
|||||||
WriteUint16((uint16)((uint16)data[i] ^ lock));
|
WriteUint16((uint16)((uint16)data[i] ^ lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteStream::WriteStringAnsi(const StringAnsiView& data)
|
void WriteStream::Write(const StringAnsiView& data)
|
||||||
{
|
{
|
||||||
const int32 length = data.Length();
|
const int32 length = data.Length();
|
||||||
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
||||||
@@ -668,7 +703,7 @@ void WriteStream::WriteStringAnsi(const StringAnsiView& data)
|
|||||||
Write(data.Get(), length);
|
Write(data.Get(), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteStream::WriteStringAnsi(const StringAnsiView& data, int8 lock)
|
void WriteStream::Write(const StringAnsiView& data, int8 lock)
|
||||||
{
|
{
|
||||||
const int32 length = data.Length();
|
const int32 length = data.Length();
|
||||||
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
ASSERT(length < STREAM_MAX_STRING_LENGTH);
|
||||||
@@ -677,7 +712,7 @@ void WriteStream::WriteStringAnsi(const StringAnsiView& data, int8 lock)
|
|||||||
WriteUint8((uint8)((uint8)data[i] ^ lock));
|
WriteUint8((uint8)((uint8)data[i] ^ lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteStream::WriteCommonValue(const CommonValue& data)
|
void WriteStream::Write(const CommonValue& data)
|
||||||
{
|
{
|
||||||
WriteByte(static_cast<byte>(data.Type));
|
WriteByte(static_cast<byte>(data.Type));
|
||||||
switch (data.Type)
|
switch (data.Type)
|
||||||
@@ -739,14 +774,14 @@ void WriteStream::WriteCommonValue(const CommonValue& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteStream::WriteVariantType(const VariantType& data)
|
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);
|
WriteStringAnsi(StringAnsiView(data.TypeName), 77);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteStream::WriteVariant(const Variant& data)
|
void WriteStream::Write(const Variant& data)
|
||||||
{
|
{
|
||||||
WriteVariantType(data.Type);
|
WriteVariantType(data.Type);
|
||||||
Guid id;
|
Guid id;
|
||||||
@@ -911,6 +946,41 @@ void WriteStream::WriteJson(ISerializable* obj, const void* otherObj)
|
|||||||
WriteInt32(0);
|
WriteInt32(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WriteStream::WriteString(const StringView& data)
|
||||||
|
{
|
||||||
|
Write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteStream::WriteString(const StringView& data, int16 lock)
|
||||||
|
{
|
||||||
|
Write(data, lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteStream::WriteStringAnsi(const StringAnsiView& data)
|
||||||
|
{
|
||||||
|
Write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteStream::WriteStringAnsi(const StringAnsiView& data, int8 lock)
|
||||||
|
{
|
||||||
|
Write(data, lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteStream::WriteCommonValue(const CommonValue& data)
|
||||||
|
{
|
||||||
|
Write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteStream::WriteVariantType(const VariantType& data)
|
||||||
|
{
|
||||||
|
Write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteStream::WriteVariant(const Variant& data)
|
||||||
|
{
|
||||||
|
Write(data);
|
||||||
|
}
|
||||||
|
|
||||||
void WriteStream::WriteBoundingBox(const BoundingBox& box, bool useDouble)
|
void WriteStream::WriteBoundingBox(const BoundingBox& box, bool useDouble)
|
||||||
{
|
{
|
||||||
#if USE_LARGE_WORLDS
|
#if USE_LARGE_WORLDS
|
||||||
|
|||||||
@@ -164,49 +164,43 @@ public:
|
|||||||
void WriteText(const StringView& text);
|
void WriteText(const StringView& text);
|
||||||
void WriteText(const StringAnsiView& text);
|
void WriteText(const StringAnsiView& text);
|
||||||
|
|
||||||
// Writes String to the stream
|
|
||||||
// @param data Data to write
|
|
||||||
void WriteString(const StringView& data);
|
|
||||||
|
|
||||||
// Writes String to the stream
|
|
||||||
// @param data Data to write
|
|
||||||
// @param lock Characters pass in the stream
|
|
||||||
void WriteString(const StringView& data, int16 lock);
|
|
||||||
|
|
||||||
// Writes Ansi String to the stream
|
|
||||||
// @param data Data to write
|
|
||||||
void WriteStringAnsi(const StringAnsiView& data);
|
|
||||||
|
|
||||||
// Writes Ansi String to the stream
|
|
||||||
// @param data Data to write
|
|
||||||
// @param lock Characters pass in the stream
|
|
||||||
void WriteStringAnsi(const StringAnsiView& data, int8 lock);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Writes CommonValue to the stream
|
void Write(const StringView& data);
|
||||||
// @param data Data to write
|
void Write(const StringView& data, int16 lock);
|
||||||
void WriteCommonValue(const CommonValue& data);
|
void Write(const StringAnsiView& data);
|
||||||
|
void Write(const StringAnsiView& data, int8 lock);
|
||||||
|
void Write(const CommonValue& data);
|
||||||
|
void Write(const VariantType& data);
|
||||||
|
void Write(const Variant& data);
|
||||||
|
|
||||||
// Writes VariantType to the stream
|
template<typename T>
|
||||||
// @param data Data to write
|
FORCE_INLINE typename TEnableIf<TAnd<TIsPODType<T>, TNot<TIsPointer<T>>>::Value>::Type Write(const T& data)
|
||||||
void WriteVariantType(const VariantType& data);
|
{
|
||||||
|
WriteBytes((const void*)&data, sizeof(T));
|
||||||
// Writes Variant to the stream
|
}
|
||||||
// @param data Data to write
|
|
||||||
void WriteVariant(const Variant& data);
|
template<typename T, typename AllocationType = HeapAllocation>
|
||||||
|
void Write(const Array<T, AllocationType>& data)
|
||||||
/// <summary>
|
|
||||||
/// Write data array
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data">Array to write</param>
|
|
||||||
template<typename T, typename AllocationType = HeapAllocation>
|
|
||||||
void WriteArray(const Array<T, AllocationType>& data)
|
|
||||||
{
|
{
|
||||||
static_assert(TIsPODType<T>::Value, "Only POD types are valid for WriteArray.");
|
|
||||||
const int32 size = data.Count();
|
const int32 size = data.Count();
|
||||||
WriteInt32(size);
|
WriteInt32(size);
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
WriteBytes(data.Get(), size * sizeof(T));
|
Write(data.Get(), size * sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename KeyType, typename ValueType, typename AllocationType = HeapAllocation>
|
||||||
|
void Write(const Dictionary<KeyType, ValueType, AllocationType>& data)
|
||||||
|
{
|
||||||
|
const int32 count = data.Count();
|
||||||
|
WriteInt32(count);
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
for (const auto& e : data)
|
||||||
|
{
|
||||||
|
Write(&e.Key, sizeof(KeyType));
|
||||||
|
Write(&e.Value, sizeof(ValueType));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -217,6 +211,55 @@ public:
|
|||||||
/// <param name="otherObj">The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties.</param>
|
/// <param name="otherObj">The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties.</param>
|
||||||
void WriteJson(ISerializable* obj, const void* otherObj = nullptr);
|
void WriteJson(ISerializable* obj, const void* otherObj = nullptr);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Writes String to the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to write
|
||||||
|
void WriteString(const StringView& data);
|
||||||
|
|
||||||
|
// Writes String to the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to write
|
||||||
|
// @param lock Characters pass in the stream
|
||||||
|
void WriteString(const StringView& data, int16 lock);
|
||||||
|
|
||||||
|
// Writes Ansi String to the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to write
|
||||||
|
void WriteStringAnsi(const StringAnsiView& data);
|
||||||
|
|
||||||
|
// Writes Ansi String to the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to write
|
||||||
|
// @param lock Characters pass in the stream
|
||||||
|
void WriteStringAnsi(const StringAnsiView& data, int8 lock);
|
||||||
|
|
||||||
|
// Writes CommonValue to the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to write
|
||||||
|
void WriteCommonValue(const CommonValue& data);
|
||||||
|
|
||||||
|
// Writes VariantType to the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to write
|
||||||
|
void WriteVariantType(const VariantType& data);
|
||||||
|
|
||||||
|
// Writes Variant to the stream
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
// @param data Data to write
|
||||||
|
void WriteVariant(const Variant& data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write data array
|
||||||
|
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Array to write</param>
|
||||||
|
template<typename T, typename AllocationType = HeapAllocation>
|
||||||
|
FORCE_INLINE void WriteArray(const Array<T, AllocationType>& data)
|
||||||
|
{
|
||||||
|
Write(data);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user