Remove deprecated CommonValue

Deprecated on 31th July 2020
This commit is contained in:
Wojtek Figat
2026-02-12 18:26:08 +01:00
parent 1df608e902
commit 865a26cbbe
24 changed files with 64 additions and 2849 deletions

View File

@@ -201,10 +201,9 @@ namespace FlaxEditor.GUI.Timeline
var idx = stream.ReadInt32();
var id = stream.ReadGuid();
object value = null;
if (version == 2)
stream.ReadCommonValue(ref value);
else
value = stream.ReadVariant();
if (version <= 2)
throw new Exception("Not supported asset version. Open and re-save asset with Flax 1.11.");
value = stream.ReadVariant();
Emitters[idx].ParametersOverrides.Add(id, value);
}

View File

@@ -4,7 +4,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using FlaxEditor.Scripting;
using FlaxEditor.Surface.Elements;
using FlaxEditor.Utilities;
using FlaxEngine;
@@ -503,205 +502,8 @@ namespace FlaxEditor.Surface
var tmpHints = _cachedConnections.Value;
var guidBytes = new byte[16];
if (version < 7000)
{
// Time saved (not used anymore to prevent binary diffs after saving unmodified surface)
stream.ReadInt64();
// Nodes count
int nodesCount = stream.ReadInt32();
if (Nodes.Capacity < nodesCount)
Nodes.Capacity = nodesCount;
tmpHints.Clear();
tmpHints.Capacity = Mathf.Max(tmpHints.Capacity, nodesCount * 4);
// Parameters count
int parametersCount = stream.ReadInt32();
if (Parameters.Capacity < parametersCount)
Parameters.Capacity = parametersCount;
// For each node
for (int i = 0; i < nodesCount; i++)
{
// ID
uint id = stream.ReadUInt32();
// Type
ushort typeId = stream.ReadUInt16();
ushort groupId = stream.ReadUInt16();
// Create node
SurfaceNode node;
if (groupId == Archetypes.Custom.GroupID)
node = new DummyCustomNode(id, this);
else
node = NodeFactory.CreateNode(nodeArchetypes, id, this, groupId, typeId);
if (node == null)
node = new MissingNode(id, this, groupId, typeId);
Nodes.Add(node);
}
// For each param
for (int i = 0; i < parametersCount; i++)
{
// Create param
var param = new SurfaceParameter();
Parameters.Add(param);
// Properties
param.Type = new ScriptType(GetGraphParameterValueType((GraphParamType_Deprecated)stream.ReadByte()));
stream.Read(guidBytes, 0, 16);
param.ID = new Guid(guidBytes);
param.Name = stream.ReadStr(97);
param.IsPublic = stream.ReadByte() != 0;
bool isStatic = stream.ReadByte() != 0;
bool isUIVisible = stream.ReadByte() != 0;
bool isUIEditable = stream.ReadByte() != 0;
// References [Deprecated]
int refsCount = stream.ReadInt32();
for (int j = 0; j < refsCount; j++)
{
uint refID = stream.ReadUInt32();
}
// Value
stream.ReadCommonValue(ref param.Value);
// Meta
param.Meta.Load(stream);
}
// For each node
for (int i = 0; i < nodesCount; i++)
{
var node = Nodes[i];
int valuesCnt = stream.ReadInt32();
int firstValueReadIdx = 0;
// Special case for missing nodes
if (node is DummyCustomNode customNode)
{
node = null;
// Values check
if (valuesCnt < 2)
throw new Exception("Missing custom nodes data.");
// Node typename check
object typeNameValue = null;
stream.ReadCommonValue(ref typeNameValue);
firstValueReadIdx = 1;
string typeName = typeNameValue as string ?? string.Empty;
// Find custom node archetype that matches this node type (it must be unique)
if (customNodes?.Archetypes != null && typeName.Length != 0)
{
NodeArchetype arch = null;
foreach (var nodeArchetype in customNodes.Archetypes)
{
if (string.Equals(Archetypes.Custom.GetNodeTypeName(nodeArchetype), typeName, StringComparison.OrdinalIgnoreCase))
{
arch = nodeArchetype;
break;
}
}
if (arch != null)
node = NodeFactory.CreateNode(customNode.ID, this, customNodes, arch);
}
// Fallback to the
if (node == null)
{
Editor.LogWarning(string.Format("Cannot find custom node archetype for {0}", typeName));
node = new MissingNode(customNode.ID, this, Archetypes.Custom.GroupID, customNode.Archetype.TypeID);
}
Nodes[i] = node;
// Store node typename in values container
node.Values[0] = typeName;
}
if (node is MissingNode)
{
// Read all values
Array.Resize(ref node.Values, valuesCnt);
for (int j = firstValueReadIdx; j < valuesCnt; j++)
{
// ReSharper disable once PossibleNullReferenceException
stream.ReadCommonValue(ref node.Values[j]);
}
firstValueReadIdx = valuesCnt = node.Values.Length;
}
// Values
int nodeValuesCnt = node.Values?.Length ?? 0;
if (valuesCnt == nodeValuesCnt)
{
for (int j = firstValueReadIdx; j < valuesCnt; j++)
{
// ReSharper disable once PossibleNullReferenceException
stream.ReadCommonValue(ref node.Values[j]);
}
}
else if ((node.Archetype.Flags & NodeFlags.VariableValuesSize) != 0)
{
node.Values = new object[valuesCnt];
for (int j = firstValueReadIdx; j < valuesCnt; j++)
{
// ReSharper disable once PossibleNullReferenceException
stream.ReadCommonValue(ref node.Values[j]);
}
}
else
{
Editor.LogWarning(string.Format("Invalid node values. Loaded: {0}, expected: {1}. Type: {2}, {3}", valuesCnt, nodeValuesCnt, node.Archetype.Title, node.Archetype.TypeID));
object dummy = null;
for (int j = firstValueReadIdx; j < valuesCnt; j++)
{
stream.ReadCommonValue(ref dummy);
if (j < nodeValuesCnt &&
dummy != null &&
node.Values[j] != null &&
node.Values[j].GetType() == dummy.GetType())
{
node.Values[j] = dummy;
}
}
}
// Boxes
ushort boxesCount = stream.ReadUInt16();
for (int j = 0; j < boxesCount; j++)
{
var id = stream.ReadByte();
stream.ReadUInt32(); // Skip type
ushort connectionsCnt = stream.ReadUInt16();
ConnectionHint hint;
hint.NodeB = node.ID;
hint.BoxB = id;
for (int k = 0; k < connectionsCnt; k++)
{
uint targetNodeID = stream.ReadUInt32();
byte targetBoxID = stream.ReadByte();
hint.NodeA = targetNodeID;
hint.BoxA = targetBoxID;
tmpHints.Add(hint);
}
}
// Meta
node.Meta.Load(stream);
OnControlLoaded(node, SurfaceNodeActions.Load);
}
}
else if (version == 7000)
throw new Exception("Not supported Visject Surface version. Open and re-save asset with Flax 1.11.");
if (version == 7000)
{
// Nodes count
int nodesCount = stream.ReadInt32();

View File

@@ -667,310 +667,6 @@ namespace FlaxEditor.Utilities
stream.Write(value.Size.Y);
}
internal static void ReadCommonValue(this BinaryReader stream, ref object value)
{
byte type = stream.ReadByte();
switch (type)
{
case 0: // CommonType::Bool:
value = stream.ReadByte() != 0;
break;
case 1: // CommonType::Integer:
{
value = stream.ReadInt32();
}
break;
case 2: // CommonType::Float:
{
value = stream.ReadSingle();
}
break;
case 3: // CommonType::Vector2:
{
value = stream.ReadFloat2();
}
break;
case 4: // CommonType::Vector3:
{
value = stream.ReadFloat3();
}
break;
case 5: // CommonType::Vector4:
{
value = stream.ReadFloat4();
}
break;
case 6: // CommonType::Color:
{
value = stream.ReadColor();
}
break;
case 7: // CommonType::Guid:
{
value = stream.ReadGuid();
}
break;
case 8: // CommonType::String:
{
int length = stream.ReadInt32();
if (length <= 0)
{
value = string.Empty;
}
else
{
var data = new char[length];
for (int i = 0; i < length; i++)
{
var c = stream.ReadUInt16();
data[i] = (char)(c ^ 953);
}
value = new string(data);
}
break;
}
case 9: // CommonType::Box:
{
value = new BoundingBox(new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()),
new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()));
}
break;
case 10: // CommonType::Rotation:
{
value = stream.ReadQuaternion();
}
break;
case 11: // CommonType::Transform:
{
value = new Transform(new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()),
new Quaternion(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()),
new Float3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()));
}
break;
case 12: // CommonType::Sphere:
{
value = new BoundingSphere(new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()),
stream.ReadSingle());
}
break;
case 13: // CommonType::Rect:
{
value = new Rectangle(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle());
}
break;
case 15: // CommonType::Matrix
{
value = new Matrix(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(),
stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(),
stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(),
stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle());
break;
}
case 16: // CommonType::Blob
{
int length = stream.ReadInt32();
value = stream.ReadBytes(length);
break;
}
case 18: // CommonType::Ray
{
value = new Ray(new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()),
new Vector3(stream.ReadSingle(), stream.ReadSingle(), stream.ReadSingle()));
break;
}
case 19: // CommonType::Int2
{
value = stream.ReadInt2();
break;
}
case 20: // CommonType::Int3
{
value = stream.ReadInt3();
break;
}
case 21: // CommonType::Int4
{
value = stream.ReadInt4();
break;
}
default: throw new SystemException();
}
}
internal static void WriteCommonValue(this BinaryWriter stream, object value)
{
if (value is bool asBool)
{
stream.Write((byte)0);
stream.Write((byte)(asBool ? 1 : 0));
}
else if (value is int asInt)
{
stream.Write((byte)1);
stream.Write(asInt);
}
else if (value is long asLong)
{
stream.Write((byte)1);
stream.Write((int)asLong);
}
else if (value is float asFloat)
{
stream.Write((byte)2);
stream.Write(asFloat);
}
else if (value is double asDouble)
{
stream.Write((byte)2);
stream.Write((float)asDouble);
}
else if (value is Vector2 asVector2)
{
stream.Write((byte)3);
stream.Write((float)asVector2.X);
stream.Write((float)asVector2.Y);
}
else if (value is Vector3 asVector3)
{
stream.Write((byte)4);
stream.Write((float)asVector3.X);
stream.Write((float)asVector3.Y);
stream.Write((float)asVector3.Z);
}
else if (value is Vector4 asVector4)
{
stream.Write((byte)5);
stream.Write((float)asVector4.X);
stream.Write((float)asVector4.Y);
stream.Write((float)asVector4.Z);
stream.Write((float)asVector4.W);
}
else if (value is Color asColor)
{
stream.Write((byte)6);
stream.Write(asColor.R);
stream.Write(asColor.G);
stream.Write(asColor.B);
stream.Write(asColor.A);
}
else if (value is Guid asGuid)
{
stream.Write((byte)7);
stream.WriteGuid(ref asGuid);
}
else if (value is string asString)
{
stream.Write((byte)8);
stream.Write(asString.Length);
for (int i = 0; i < asString.Length; i++)
stream.Write((ushort)(asString[i] ^ -14));
}
else if (value is BoundingBox asBox)
{
stream.Write((byte)9);
stream.Write((float)asBox.Minimum.X);
stream.Write((float)asBox.Minimum.Y);
stream.Write((float)asBox.Minimum.Z);
stream.Write((float)asBox.Maximum.X);
stream.Write((float)asBox.Maximum.Y);
stream.Write((float)asBox.Maximum.Z);
}
else if (value is Quaternion asRotation)
{
stream.Write((byte)10);
stream.Write(asRotation.X);
stream.Write(asRotation.Y);
stream.Write(asRotation.Z);
stream.Write(asRotation.X);
}
else if (value is Transform asTransform)
{
stream.Write((byte)11);
stream.Write((float)asTransform.Translation.X);
stream.Write((float)asTransform.Translation.Y);
stream.Write((float)asTransform.Translation.Z);
stream.Write(asTransform.Orientation.X);
stream.Write(asTransform.Orientation.Y);
stream.Write(asTransform.Orientation.Z);
stream.Write(asTransform.Orientation.X);
stream.Write(asTransform.Scale.X);
stream.Write(asTransform.Scale.Y);
stream.Write(asTransform.Scale.Z);
}
else if (value is BoundingSphere asSphere)
{
stream.Write((byte)12);
stream.Write((float)asSphere.Center.X);
stream.Write((float)asSphere.Center.Y);
stream.Write((float)asSphere.Center.Z);
stream.Write((float)asSphere.Radius);
}
else if (value is Rectangle asRect)
{
stream.Write((byte)13);
stream.Write(asRect.Location.X);
stream.Write(asRect.Location.Y);
stream.Write(asRect.Size.X);
stream.Write(asRect.Size.Y);
}
else if (value is Matrix asMatrix)
{
stream.Write((byte)15);
stream.Write(asMatrix.M11);
stream.Write(asMatrix.M12);
stream.Write(asMatrix.M13);
stream.Write(asMatrix.M14);
stream.Write(asMatrix.M21);
stream.Write(asMatrix.M22);
stream.Write(asMatrix.M23);
stream.Write(asMatrix.M24);
stream.Write(asMatrix.M31);
stream.Write(asMatrix.M32);
stream.Write(asMatrix.M33);
stream.Write(asMatrix.M34);
stream.Write(asMatrix.M41);
stream.Write(asMatrix.M42);
stream.Write(asMatrix.M43);
stream.Write(asMatrix.M44);
}
else if (value is byte[] asBlob)
{
stream.Write((byte)16);
stream.Write(asBlob.Length);
stream.Write(asBlob);
}
else if (value is Ray asRay)
{
stream.Write((byte)18);
stream.Write((float)asRay.Position.X);
stream.Write((float)asRay.Position.Y);
stream.Write((float)asRay.Position.Z);
stream.Write((float)asRay.Direction.X);
stream.Write((float)asRay.Direction.Y);
stream.Write((float)asRay.Direction.Z);
}
else if (value is Int2 asInt2)
{
stream.Write((byte)19);
stream.Write(asInt2);
}
else if (value is Int3 asInt3)
{
stream.Write((byte)20);
stream.Write(asInt3);
}
else if (value is Int4 asInt4)
{
stream.Write((byte)21);
stream.Write(asInt4);
}
else
{
throw new NotSupportedException(string.Format("Invalid Common Value type {0}", value != null ? value.GetType().ToString() : "null"));
}
}
/// <summary>
/// Shows the source code window.
/// </summary>

View File

@@ -3,6 +3,7 @@
#include "Material.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/DataContainer.h"
#include "Engine/Content/Deprecated.h"
#include "Engine/Content/Upgraders/ShaderAssetUpgrader.h"
#include "Engine/Content/Factories/BinaryAssetFactory.h"
#include "Engine/Graphics/GPUDevice.h"

View File

@@ -1,182 +0,0 @@
// Copyright (c) Wojciech Figat. All rights reserved.
#include "CommonValue.h"
#include "Engine/Scripting/ScriptingObject.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
const CommonValue CommonValue::Zero(0.0f);
const CommonValue CommonValue::One(1.0f);
const CommonValue CommonValue::Null(static_cast<void*>(nullptr));
const CommonValue CommonValue::False(false);
const CommonValue CommonValue::True(true);
const Char* ToString(CommonType value)
{
const Char* result;
switch (value)
{
case CommonType::Bool:
result = TEXT("Bool");
break;
case CommonType::Integer:
result = TEXT("Integer");
break;
case CommonType::Float:
result = TEXT("Float");
break;
case CommonType::Vector2:
result = TEXT("Vector2");
break;
case CommonType::Vector3:
result = TEXT("Vector3");
break;
case CommonType::Vector4:
result = TEXT("Vector4");
break;
case CommonType::Color:
result = TEXT("Color");
break;
case CommonType::Guid:
result = TEXT("Guid");
break;
case CommonType::String:
result = TEXT("String");
break;
case CommonType::Box:
result = TEXT("Box");
break;
case CommonType::Rotation:
result = TEXT("Rotation");
break;
case CommonType::Transform:
result = TEXT("Transform");
break;
case CommonType::Sphere:
result = TEXT("Sphere");
break;
case CommonType::Rectangle:
result = TEXT("Rectangle");
break;
case CommonType::Pointer:
result = TEXT("Pointer");
break;
case CommonType::Matrix:
result = TEXT("Matrix");
break;
case CommonType::Blob:
result = TEXT("Blob");
break;
case CommonType::Object:
result = TEXT("Object");
break;
case CommonType::Ray:
result = TEXT("Ray");
break;
default:
result = TEXT("");
break;
}
return result;
}
bool CommonValue::NearEqual(const CommonValue& a, const CommonValue& b, float epsilon)
{
ASSERT(a.Type == b.Type);
switch (a.Type)
{
case CommonType::Bool:
return a.AsBool == b.AsBool;
case CommonType::Integer:
return Math::Abs(a.AsInteger - b.AsInteger) < epsilon;
case CommonType::Float:
return Math::Abs(a.AsFloat - b.AsFloat) < epsilon;
case CommonType::Vector2:
return Float2::NearEqual(a.AsVector2, b.AsVector2, epsilon);
case CommonType::Vector3:
return Float3::NearEqual(a.AsVector3, b.AsVector3, epsilon);
case CommonType::Vector4:
return Float4::NearEqual(a.AsVector4, b.AsVector4, epsilon);
case CommonType::Color:
return Color::NearEqual(a.AsColor, b.AsColor, epsilon);
case CommonType::Guid:
return a.AsGuid == b.AsGuid;
case CommonType::String:
return StringUtils::Compare(a.AsString, b.AsString) > 0;
case CommonType::Box:
return BoundingBox::NearEqual(a.AsBox, b.AsBox, epsilon);
case CommonType::Rotation:
return Quaternion::NearEqual(a.AsRotation, b.AsRotation, epsilon);
case CommonType::Transform:
return Transform::NearEqual(a.AsTransform, b.AsTransform, epsilon);
case CommonType::Sphere:
return BoundingSphere::NearEqual(a.AsSphere, b.AsSphere, epsilon);
case CommonType::Rectangle:
return Rectangle::NearEqual(a.AsRectangle, b.AsRectangle, epsilon);
case CommonType::Ray:
return Ray::NearEqual(a.AsRay, b.AsRay, epsilon);
case CommonType::Pointer:
case CommonType::Object:
return a.AsPointer == b.AsPointer;
case CommonType::Matrix:
return a.AsMatrix == b.AsMatrix;
case CommonType::Blob:
return a.AsBlob.Length == b.AsBlob.Length;
default: CRASH;
return false;
}
}
CommonValue CommonValue::Lerp(const CommonValue& a, const CommonValue& b, float alpha)
{
ASSERT(a.Type == b.Type);
switch (a.Type)
{
case CommonType::Bool:
return alpha < 0.5f ? a : b;
case CommonType::Integer:
return Math::Lerp(a.AsInteger, b.AsInteger, alpha);
case CommonType::Float:
return Math::Lerp(a.AsFloat, b.AsFloat, alpha);
case CommonType::Vector2:
return Float2::Lerp(a.AsVector2, b.AsVector2, alpha);
case CommonType::Vector3:
return Float3::Lerp(a.AsVector3, b.AsVector3, alpha);
case CommonType::Vector4:
return Float4::Lerp(a.AsVector4, b.AsVector4, alpha);
case CommonType::Color:
return Color::Lerp(a.AsColor, b.AsColor, alpha);
case CommonType::Box:
return BoundingBox(Vector3::Lerp(a.AsBox.Minimum, b.AsBox.Minimum, alpha), Vector3::Lerp(a.AsBox.Maximum, b.AsBox.Maximum, alpha));
case CommonType::Rotation:
return Quaternion::Lerp(a.AsRotation, b.AsRotation, alpha);
case CommonType::Transform:
return Transform::Lerp(a.AsTransform, b.AsTransform, alpha);
case CommonType::Sphere:
return BoundingSphere(Vector3::Lerp(a.AsSphere.Center, b.AsSphere.Center, alpha), Math::Lerp(a.AsSphere.Radius, b.AsSphere.Radius, alpha));
case CommonType::Rectangle:
return Rectangle(Float2::Lerp(a.AsRectangle.Location, b.AsRectangle.Location, alpha), Float2::Lerp(a.AsRectangle.Size, b.AsRectangle.Size, alpha));
case CommonType::Ray:
return Ray(Vector3::Lerp(a.AsRay.Position, b.AsRay.Position, alpha), Vector3::Normalize(Vector3::Lerp(a.AsRay.Direction, b.AsRay.Direction, alpha)));
default:
return a;
}
}
Guid CommonValue::GetObjectId() const
{
ASSERT(Type == CommonType::Object);
return AsObject ? AsObject->GetID() : Guid::Empty;
}
void CommonValue::LinkObject()
{
AsObject->Deleted.Bind<CommonValue, &CommonValue::OnObjectDeleted>(this);
}
void CommonValue::UnlinkObject()
{
AsObject->Deleted.Unbind<CommonValue, &CommonValue::OnObjectDeleted>(this);
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
// Copyright (c) Wojciech Figat. All rights reserved.
#include "Variant.h"
#include "CommonValue.h"
#include "Engine/Core/Collections/HashFunctions.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "Engine/Content/Asset.h"
@@ -964,78 +963,6 @@ Variant::Variant(const Span<byte>& v)
}
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#include "Engine/Content/Deprecated.h"
Variant::Variant(const CommonValue& value)
: Variant()
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
MARK_CONTENT_DEPRECATED();
switch (value.Type)
{
case CommonType::Bool:
*this = value.AsBool;
break;
case CommonType::Integer:
*this = value.AsInteger;
break;
case CommonType::Float:
*this = value.AsFloat;
break;
case CommonType::Vector2:
*this = value.AsVector2;
break;
case CommonType::Vector3:
*this = value.AsVector3;
break;
case CommonType::Vector4:
*this = value.AsVector4;
break;
case CommonType::Color:
*this = value.AsColor;
break;
case CommonType::Guid:
*this = value.AsGuid;
break;
case CommonType::String:
SetString(StringView(value.AsString));
break;
case CommonType::Box:
*this = Variant(value.AsBox);
break;
case CommonType::Rotation:
*this = value.AsRotation;
break;
case CommonType::Transform:
*this = Variant(value.AsTransform);
break;
case CommonType::Sphere:
*this = value.AsSphere;
break;
case CommonType::Rectangle:
*this = value.AsRectangle;
break;
case CommonType::Pointer:
*this = value.AsPointer;
break;
case CommonType::Matrix:
*this = Variant(value.AsMatrix);
break;
case CommonType::Blob:
SetBlob(value.AsBlob.Data, value.AsBlob.Length);
break;
case CommonType::Object:
SetObject(value.AsObject);
break;
case CommonType::Ray:
*this = Variant(value.AsRay);
break;
default:
CRASH;
}
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
Variant::~Variant()
{
switch (Type.Type)

View File

@@ -7,7 +7,6 @@
class Asset;
struct Transform;
struct CommonValue;
template<typename T>
class AssetReference;
struct ScriptingTypeHandle;
@@ -264,7 +263,6 @@ public:
explicit Variant(Dictionary<Variant, Variant, HeapAllocation>&& v);
explicit Variant(const Dictionary<Variant, Variant, HeapAllocation>& v);
explicit Variant(const Span<byte>& v);
explicit Variant(const CommonValue& v);
template<typename T>
Variant(const class AssetReference<T>& v)

View File

@@ -2,60 +2,12 @@
#include "GameplayGlobals.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/CommonValue.h"
#include "Engine/Serialization/MemoryReadStream.h"
#include "Engine/Serialization/MemoryWriteStream.h"
#include "Engine/Content/Factories/BinaryAssetFactory.h"
#include "Engine/Content/Upgraders/BinaryAssetUpgrader.h"
#include "Engine/Threading/Threading.h"
#if USE_EDITOR
class GameplayGlobalsUpgrader : public BinaryAssetUpgrader
{
public:
GameplayGlobalsUpgrader()
{
const Upgrader upgraders[] =
{
{ 1, 2, &Upgrade_1_To_2 }, // [Deprecated on 31.07.2020, expires on 31.07.2022]
};
setup(upgraders, ARRAY_COUNT(upgraders));
}
private:
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);
if (context.AllocateChunk(0))
return true;
auto& data = context.Input.Header.Chunks[0]->Data;
MemoryReadStream stream(data.Get(), data.Length());
MemoryWriteStream output;
int32 count;
stream.ReadInt32(&count);
output.WriteInt32(count);
String name;
for (int32 i = 0; i < count; i++)
{
stream.Read(name, 71);
CommonValue commonValue;
stream.ReadCommonValue(&commonValue);
Variant variant(commonValue);
output.WriteVariant(variant);
}
context.Output.Header.Chunks[0]->Data.Copy(output.GetHandle(), output.GetPosition());
PRAGMA_ENABLE_DEPRECATION_WARNINGS
return false;
}
};
#endif
REGISTER_BINARY_ASSET_WITH_UPGRADER(GameplayGlobals, "FlaxEngine.GameplayGlobals", GameplayGlobalsUpgrader, true);
REGISTER_BINARY_ASSET(GameplayGlobals, "FlaxEngine.GameplayGlobals", true);
GameplayGlobals::GameplayGlobals(const SpawnParams& params, const AssetInfo* info)
: BinaryAsset(params, info)

View File

@@ -3,10 +3,10 @@
#if COMPILE_WITH_PARTICLE_GPU_GRAPH
#include "ParticleEmitterGraph.GPU.h"
#include "Engine/Core/Math/Matrix.h"
#include "Engine/Serialization/FileReadStream.h"
#include "Engine/Visject/ShaderGraphUtilities.h"
#include "Engine/Engine/Globals.h"
#include "Engine/Core/Types/CommonValue.h"
/// <summary>
/// GPU particles shader source code template has special marks for generated code.

View File

@@ -2,7 +2,6 @@
#include "ParticleEffect.h"
#include "Particles.h"
#include "Engine/Core/Types/CommonValue.h"
#include "Engine/Content/Deprecated.h"
#include "Engine/Serialization/JsonTools.h"
#include "Engine/Serialization/Serialization.h"
@@ -728,86 +727,39 @@ void ParticleEffect::Deserialize(DeserializeStream& stream, ISerializeModifier*
const auto overridesMember = stream.FindMember("Overrides");
if (overridesMember != stream.MemberEnd())
{
// [Deprecated on 25.11.2018, expires on 25.11.2022]
if (modifier->EngineBuild < 6197)
const auto& overrides = overridesMember->value;
CHECK(overrides.IsArray());
_parametersOverrides.EnsureCapacity(_parametersOverrides.Count() + overrides.Size());
for (rapidjson::SizeType i = 0; i < overrides.Size(); i++)
{
PRAGMA_DISABLE_DEPRECATION_WARNINGS
MARK_CONTENT_DEPRECATED();
const auto& overrides = overridesMember->value;
ASSERT(overrides.IsArray());
_parametersOverrides.EnsureCapacity(_parametersOverrides.Count() + overrides.Size());
for (rapidjson::SizeType i = 0; i < overrides.Size(); i++)
auto& o = (DeserializeStream&)overrides[i];
const String trackName = JsonTools::GetString(o, "Track");
const Guid id = JsonTools::GetGuid(o, "Id");
ParameterOverride* e = nullptr;
for (auto& q : _parametersOverrides)
{
const auto& o = (DeserializeStream&)overrides[i];
const String trackName = JsonTools::GetString(o, "Track");
const Guid id = JsonTools::GetGuid(o, "Id");
ParameterOverride* e = nullptr;
for (auto& q : _parametersOverrides)
if (q.Id == id && q.Track == trackName)
{
if (q.Id == id && q.Track == trackName)
{
e = &q;
break;
}
}
if (e)
{
// Update overriden parameter value
CommonValue value;
auto mValue = SERIALIZE_FIND_MEMBER(o, "Value");
if (mValue != o.MemberEnd())
e->Value = Variant(JsonTools::GetCommonValue(mValue->value));
}
else
{
// Add parameter override
auto& p = _parametersOverrides.AddOne();
p.Track = trackName;
p.Id = id;
CommonValue value;
auto mValue = SERIALIZE_FIND_MEMBER(o, "Value");
if (mValue != o.MemberEnd())
p.Value = Variant(JsonTools::GetCommonValue(mValue->value));
e = &q;
break;
}
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
}
else
{
const auto& overrides = overridesMember->value;
ASSERT(overrides.IsArray());
_parametersOverrides.EnsureCapacity(_parametersOverrides.Count() + overrides.Size());
for (rapidjson::SizeType i = 0; i < overrides.Size(); i++)
if (e)
{
auto& o = (DeserializeStream&)overrides[i];
const String trackName = JsonTools::GetString(o, "Track");
const Guid id = JsonTools::GetGuid(o, "Id");
ParameterOverride* e = nullptr;
for (auto& q : _parametersOverrides)
{
if (q.Id == id && q.Track == trackName)
{
e = &q;
break;
}
}
if (e)
{
// Update overriden parameter value
const auto mValue = SERIALIZE_FIND_MEMBER(o, "Value");
if (mValue != stream.MemberEnd())
Serialization::Deserialize(mValue->value, e->Value, modifier);
}
else
{
// Add parameter override
auto& p = _parametersOverrides.AddOne();
p.Track = trackName;
p.Id = id;
const auto mValue = SERIALIZE_FIND_MEMBER(o, "Value");
if (mValue != stream.MemberEnd())
Serialization::Deserialize(mValue->value, p.Value, modifier);
}
// Update overriden parameter value
const auto mValue = SERIALIZE_FIND_MEMBER(o, "Value");
if (mValue != stream.MemberEnd())
Serialization::Deserialize(mValue->value, e->Value, modifier);
}
else
{
// Add parameter override
auto& p = _parametersOverrides.AddOne();
p.Track = trackName;
p.Id = id;
const auto mValue = SERIALIZE_FIND_MEMBER(o, "Value");
if (mValue != stream.MemberEnd())
Serialization::Deserialize(mValue->value, p.Value, modifier);
}
}
}

View File

@@ -4,6 +4,7 @@
#include "ParticleSystem.h"
#include "ParticleEffect.h"
#include "Particles.h"
#include "Engine/Content/Deprecated.h"
#include "Engine/Content/Factories/BinaryAssetFactory.h"
#include "Engine/Content/Upgraders/ShaderAssetUpgrader.h"
#include "Engine/Core/Log.h"

View File

@@ -2,7 +2,6 @@
#include "ParticleSystem.h"
#include "ParticleEffect.h"
#include "Engine/Core/Types/CommonValue.h"
#include "Engine/Level/Level.h"
#include "Engine/Content/Deprecated.h"
#include "Engine/Content/Factories/BinaryAssetFactory.h"
@@ -225,158 +224,6 @@ Asset::LoadResult ParticleSystem::load()
#endif
switch (version)
{
PRAGMA_DISABLE_DEPRECATION_WARNINGS
case 1:
{
// [Deprecated on 23.07.2019, expires on 27.04.2021]
MARK_CONTENT_DEPRECATED();
// Load properties
stream.ReadFloat(&FramesPerSecond);
stream.ReadInt32(&DurationFrames);
// Load emitters
int32 emittersCount;
stream.ReadInt32(&emittersCount);
Emitters.Resize(emittersCount, false);
// Load tracks
Guid id;
int32 tracksCount;
stream.ReadInt32(&tracksCount);
Tracks.Resize(tracksCount, false);
for (int32 i = 0; i < tracksCount; i++)
{
auto& track = Tracks[i];
track.Type = (Track::Types)stream.ReadByte();
track.Flag = (Track::Flags)stream.ReadByte();
stream.ReadInt32(&track.ParentIndex);
stream.ReadInt32(&track.ChildrenCount);
stream.ReadString(&track.Name, -13);
track.Disabled = (int32)track.Flag & (int32)Track::Flags::Mute || (track.ParentIndex != -1 && Tracks[track.ParentIndex].Disabled);
switch (track.Type)
{
case Track::Types::Emitter:
stream.Read(id);
stream.ReadInt32(&track.AsEmitter.Index);
stream.ReadInt32(&track.AsEmitter.StartFrame);
stream.ReadInt32(&track.AsEmitter.DurationFrames);
Emitters[track.AsEmitter.Index] = id;
break;
case Track::Types::Folder:
stream.Read(track.Color);
break;
default:
return LoadResult::InvalidData;
}
}
// Wait for all tracks to be loaded - particle system cannot be used if any of the emitters is not loaded yet
// Note: this loop might trigger loading referenced assets on this thread
for (int32 i = 0; i < Emitters.Count(); i++)
{
if (Emitters[i])
Emitters[i]->WaitForLoaded();
}
// Load parameters overrides
int32 overridesCount = 0;
if (stream.CanRead())
stream.ReadInt32(&overridesCount);
if (overridesCount != 0)
{
EmitterParameterOverrideKey key;
CommonValue value;
for (int32 i = 0; i < overridesCount; i++)
{
stream.ReadInt32(&key.First);
stream.Read(key.Second);
stream.ReadCommonValue(&value);
SKIP_UNUSED_PARAM_OVERRIDE();
EmittersParametersOverrides.Add(key, Variant(value));
}
}
break;
}
case 2:
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
MARK_CONTENT_DEPRECATED();
// Load properties
stream.ReadFloat(&FramesPerSecond);
stream.ReadInt32(&DurationFrames);
// Load emitters
int32 emittersCount;
stream.ReadInt32(&emittersCount);
Emitters.Resize(emittersCount, false);
// Load tracks
Guid id;
int32 tracksCount;
stream.ReadInt32(&tracksCount);
Tracks.Resize(tracksCount, false);
for (int32 i = 0; i < tracksCount; i++)
{
auto& track = Tracks[i];
track.Type = (Track::Types)stream.ReadByte();
track.Flag = (Track::Flags)stream.ReadByte();
stream.ReadInt32(&track.ParentIndex);
stream.ReadInt32(&track.ChildrenCount);
stream.ReadString(&track.Name, -13);
track.Disabled = (int32)track.Flag & (int32)Track::Flags::Mute || (track.ParentIndex != -1 && Tracks[track.ParentIndex].Disabled);
stream.Read(track.Color);
switch (track.Type)
{
case Track::Types::Emitter:
stream.Read(id);
stream.ReadInt32(&track.AsEmitter.Index);
stream.ReadInt32(&track.AsEmitter.StartFrame);
stream.ReadInt32(&track.AsEmitter.DurationFrames);
Emitters[track.AsEmitter.Index] = id;
break;
case Track::Types::Folder:
break;
default:
return LoadResult::InvalidData;
}
}
// Wait for all tracks to be loaded - particle system cannot be used if any of the emitters is not loaded yet
// Note: this loop might trigger loading referenced assets on this thread
for (int32 i = 0; i < Emitters.Count(); i++)
{
if (Emitters[i])
Emitters[i]->WaitForLoaded();
}
// Load parameters overrides
int32 overridesCount = 0;
if (stream.CanRead())
stream.ReadInt32(&overridesCount);
if (overridesCount != 0)
{
EmitterParameterOverrideKey key;
CommonValue value;
for (int32 i = 0; i < overridesCount; i++)
{
stream.ReadInt32(&key.First);
stream.Read(key.Second);
stream.ReadCommonValue(&value);
SKIP_UNUSED_PARAM_OVERRIDE();
EmittersParametersOverrides[key] = Variant(value);
}
}
break;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
case 3: // [Deprecated on 03.09.2021 expires on 03.09.2023]
MARK_CONTENT_DEPRECATED();
case 4:

View File

@@ -6,7 +6,6 @@
#include "Particles.h"
#include "Engine/Graphics/GPUBuffer.h"
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Core/Types/CommonValue.h"
ParticleEmitterInstance::ParticleEmitterInstance()
{

View File

@@ -3,7 +3,6 @@
#include "JsonTools.h"
#include "ISerializable.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "Engine/Core/Types/CommonValue.h"
#include "Engine/Core/Types/DateTime.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Scripting/ScriptingObjectReference.h"
@@ -284,87 +283,3 @@ DateTime JsonTools::GetDateTime(const Value& value)
{
return DateTime(value.GetInt64());
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#include "Engine/Content/Deprecated.h"
CommonValue JsonTools::GetCommonValue(const Value& value)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
MARK_CONTENT_DEPRECATED();
CommonValue result;
const auto typeMember = value.FindMember("Type");
const auto valueMember = value.FindMember("Value");
if (typeMember != value.MemberEnd() && typeMember->value.IsInt() && valueMember != value.MemberEnd())
{
const auto& v = valueMember->value;
switch ((CommonType)typeMember->value.GetInt())
{
case CommonType::Bool:
result = v.GetBool();
break;
case CommonType::Integer:
result = v.GetInt();
break;
case CommonType::Float:
result = v.GetFloat();
break;
case CommonType::Vector2:
result = GetFloat2(v);
break;
case CommonType::Vector3:
result = GetFloat3(v);
break;
case CommonType::Vector4:
result = GetFloat4(v);
break;
case CommonType::Color:
result = GetColor(v);
break;
case CommonType::Guid:
result = GetGuid(v);
break;
case CommonType::String:
result = v.GetText();
break;
case CommonType::Box:
result = GetBoundingBox(v);
break;
case CommonType::Rotation:
result = GetQuaternion(v);
break;
case CommonType::Transform:
result = GetTransform(v);
break;
case CommonType::Sphere:
result = GetBoundingSphere(v);
break;
case CommonType::Rectangle:
result = GetRectangle(v);
break;
case CommonType::Ray:
result = GetRay(v);
break;
case CommonType::Pointer:
result = (void*)v.GetInt64();
break;
case CommonType::Matrix:
result = GetMatrix(v);
break;
case CommonType::Blob:
{
const int32 length = v.GetStringLength();
result.SetBlob(length);
Encryption::Base64Decode(v.GetString(), length, result.AsBlob.Data);
break;
}
case CommonType::Object:
result = FindObject(GetGuid(v), ScriptingObject::GetStaticClass());
break;
default:
CRASH;
break;
}
}
return result;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS

View File

@@ -20,8 +20,6 @@
#include "Engine/Core/Math/Matrix.h"
#include "ISerializable.h"
struct CommonValue;
/// <summary>
/// Json value container utilities.
/// </summary>
@@ -103,7 +101,6 @@ public:
static Guid GetGuid(const Value& value);
static DateTime GetDate(const Value& value);
static DateTime GetDateTime(const Value& value);
static CommonValue GetCommonValue(const Value& value);
public:
FORCE_INLINE static String GetString(const Value& node, const char* name)

View File

@@ -2,10 +2,18 @@
#include "JsonWriter.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/CommonValue.h"
#include "Engine/Content/Content.h"
#include "Engine/Core/Math/Vector2.h"
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Math/Vector4.h"
#include "Engine/Core/Math/Color.h"
#include "Engine/Core/Math/Ray.h"
#include "Engine/Core/Math/Plane.h"
#include "Engine/Core/Math/Matrix.h"
#include "Engine/Core/Math/Rectangle.h"
#include "Engine/Core/Math/Transform.h"
#include "Engine/Core/Math/BoundingBox.h"
#include "Engine/Core/Math/BoundingSphere.h"
#include "Engine/Core/Types/DateTime.h"
#include "Engine/Level/Prefabs/Prefab.h"
#include "Engine/Level/SceneObject.h"
@@ -244,84 +252,6 @@ void JsonWriter::Matrix(const ::Matrix& value)
EndObject();
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void JsonWriter::CommonValue(const ::CommonValue& value)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
StartObject();
JKEY("Type");
Int((int32)value.Type);
JKEY("Value");
switch (value.Type)
{
case CommonType::Bool:
Bool(value.AsBool);
break;
case CommonType::Integer:
Int(value.AsInteger);
break;
case CommonType::Float:
Float(value.AsFloat);
break;
case CommonType::Vector2:
Vector2(value.AsVector2);
break;
case CommonType::Vector3:
Vector3(value.AsVector3);
break;
case CommonType::Vector4:
Vector4(value.AsVector4);
break;
case CommonType::Color:
Color(value.AsColor);
break;
case CommonType::Guid:
Guid(value.AsGuid);
break;
case CommonType::String:
String(value.AsString);
break;
case CommonType::Box:
BoundingBox(value.AsBox);
break;
case CommonType::Rotation:
Quaternion(value.AsRotation);
break;
case CommonType::Transform:
Transform(value.AsTransform);
break;
case CommonType::Sphere:
BoundingSphere(value.AsSphere);
break;
case CommonType::Rectangle:
Rectangle(value.AsRectangle);
break;
case CommonType::Ray:
Ray(value.AsRay);
break;
case CommonType::Pointer:
Int64((int64)value.AsPointer);
break;
case CommonType::Matrix:
Matrix(value.AsMatrix);
break;
case CommonType::Blob:
Blob(value.AsBlob.Data, value.AsBlob.Length);
break;
case CommonType::Object:
Guid(value.GetObjectId());
break;
default:
CRASH;
break;
}
EndObject();
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
void JsonWriter::Transform(const ::Transform& value)
{
StartObject();

View File

@@ -6,7 +6,6 @@
#include "Engine/Core/Types/StringView.h"
#include "Engine/Utilities/StringConverter.h"
struct CommonValue;
class ISerializable;
// Helper macro for JSON serialization keys (reduces allocations count)
@@ -140,7 +139,6 @@ public:
void Quaternion(const Quaternion& value);
void Ray(const Ray& value);
void Matrix(const Matrix& value);
void CommonValue(const CommonValue& value);
void Transform(const ::Transform& value);
void Transform(const ::Transform& value, const ::Transform* other);
void Plane(const Plane& value);

View File

@@ -108,7 +108,6 @@ public:
void Read(String& data, int16 lock);
void Read(StringAnsi& data);
void Read(StringAnsi& data, int8 lock);
void Read(CommonValue& data);
void Read(VariantType& data);
void Read(Variant& data);
@@ -238,10 +237,6 @@ public:
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
DEPRECATED("Use Read method") void ReadString(String* data, int16 lock);
// Reads CommonValue from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
DEPRECATED("Use Read method") void ReadCommonValue(CommonValue* data);
// Reads VariantType from the stream
/// [Deprecated on 11.10.2022, expires on 11.10.2024]
DEPRECATED("Use Read method") void ReadVariantType(VariantType* data);

View File

@@ -5,9 +5,18 @@
#include "JsonWriters.h"
#include "JsonSerializer.h"
#include "MemoryReadStream.h"
#include "Engine/Core/Types/CommonValue.h"
#include "Engine/Core/Types/Variant.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "Engine/Core/Math/Vector2.h"
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Math/Vector4.h"
#include "Engine/Core/Math/Matrix.h"
#include "Engine/Core/Math/Ray.h"
#include "Engine/Core/Math/Rectangle.h"
#include "Engine/Core/Math/Transform.h"
#include "Engine/Core/Math/BoundingBox.h"
#include "Engine/Core/Math/BoundingSphere.h"
#include "Engine/Core/Math/Color.h"
#include "Engine/Content/Asset.h"
#include "Engine/Core/Cache.h"
#include "Engine/Debug/Exceptions/JsonParseException.h"
@@ -105,137 +114,6 @@ void ReadStream::Read(String& data, int16 lock)
}
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void ReadStream::Read(CommonValue& data)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
byte type;
ReadByte(&type);
switch (static_cast<CommonType>(type))
{
case CommonType::Bool:
data.Set(ReadBool());
break;
case CommonType::Integer:
{
int32 v;
ReadInt32(&v);
data.Set(v);
}
break;
case CommonType::Float:
{
float v;
ReadFloat(&v);
data.Set(v);
}
break;
case CommonType::Vector2:
{
Float2 v;
Read(v);
data.Set(v);
}
break;
case CommonType::Vector3:
{
Float3 v;
Read(v);
data.Set(v);
}
break;
case CommonType::Vector4:
{
Float4 v;
Read(v);
data.Set(v);
}
break;
case CommonType::Color:
{
Color v;
Read(v);
data.Set(v);
}
break;
case CommonType::Guid:
{
Guid v;
Read(v);
data.Set(v);
}
break;
case CommonType::String:
{
String v;
Read(v, 953);
data.Set(v);
}
break;
case CommonType::Box:
{
BoundingBox v;
Read(v);
data.Set(v);
}
break;
case CommonType::Rotation:
{
Quaternion v;
Read(v);
data.Set(v);
}
break;
case CommonType::Transform:
{
Transform v;
Read(v);
data.Set(v);
}
break;
case CommonType::Sphere:
{
BoundingSphere v;
Read(v);
data.Set(v);
}
break;
case CommonType::Rectangle:
{
Rectangle v;
Read(v);
data.Set(v);
}
case CommonType::Ray:
{
Ray v;
Read(v);
data.Set(v);
}
break;
case CommonType::Matrix:
{
Matrix v;
Read(v);
data.Set(v);
}
break;
case CommonType::Blob:
{
int32 length;
Read(length);
data.SetBlob(length);
if (length > 0)
{
ReadBytes(data.AsBlob.Data, length);
}
}
break;
default: CRASH;
}
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
void ReadStream::Read(VariantType& data)
{
data = VariantType((VariantType::Types)ReadByte());
@@ -550,13 +428,6 @@ void ReadStream::ReadString(String* data, int16 lock)
Read(*data, lock);
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void ReadStream::ReadCommonValue(CommonValue* data)
{
Read(*data);
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
void ReadStream::ReadVariantType(VariantType* data)
{
Read(*data);
@@ -740,71 +611,6 @@ void WriteStream::Write(const StringAnsiView& data, int8 lock)
WriteUint8((uint8)((uint8)data[i] ^ lock));
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void WriteStream::Write(const CommonValue& data)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
WriteByte(static_cast<byte>(data.Type));
switch (data.Type)
{
case CommonType::Bool:
Write(data.AsBool);
break;
case CommonType::Integer:
Write(data.AsInteger);
break;
case CommonType::Float:
Write(data.AsFloat);
break;
case CommonType::Vector2:
Write(data.AsVector2);
break;
case CommonType::Vector3:
Write(data.AsVector3);
break;
case CommonType::Vector4:
Write(data.AsVector4);
break;
case CommonType::Color:
Write(data.AsColor);
break;
case CommonType::Guid:
Write(data.AsGuid);
break;
case CommonType::String:
Write(data.AsString, 953);
break;
case CommonType::Box:
Write(data.AsBox);
break;
case CommonType::Rotation:
Write(data.AsRotation);
break;
case CommonType::Transform:
Write(data.AsTransform);
break;
case CommonType::Sphere:
Write(data.AsSphere);
break;
case CommonType::Rectangle:
Write(data.AsRectangle);
break;
case CommonType::Ray:
Write(data.AsRay);
break;
case CommonType::Matrix:
Write(data.AsMatrix);
break;
case CommonType::Blob:
WriteInt32(data.AsBlob.Length);
if (data.AsBlob.Length > 0)
WriteBytes(data.AsBlob.Data, data.AsBlob.Length);
break;
default: CRASH;
}
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
void WriteStream::Write(const VariantType& data)
{
WriteByte((byte)data.Type);
@@ -1004,13 +810,6 @@ void WriteStream::WriteStringAnsi(const StringAnsiView& data, int8 lock)
Write(data, lock);
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void WriteStream::WriteCommonValue(const CommonValue& data)
{
Write(data);
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
void WriteStream::WriteVariantType(const VariantType& data)
{
Write(data);

View File

@@ -10,7 +10,6 @@
class ReadStream;
class WriteStream;
struct CommonValue;
struct Variant;
struct VariantType;
class ISerializable;

View File

@@ -133,7 +133,6 @@ public:
void Write(const StringView& data, int16 lock);
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);
@@ -262,11 +261,6 @@ public:
// @param lock Characters pass in the stream
DEPRECATED("Use Write method") 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
DEPRECATED("Use Write method") 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

View File

@@ -7,13 +7,10 @@
#include "VisjectMeta.h"
#include "GraphNode.h"
#include "GraphParameter.h"
#include "Engine/Content/Deprecated.h"
#include "Engine/Serialization/ReadStream.h"
#include "Engine/Serialization/WriteStream.h"
// [Deprecated on 31.07.2020, expires on 31.07.2022]
extern FLAXENGINE_API void ReadOldGraphParamValue_Deprecated(byte graphParamType, ReadStream* stream, GraphParameter* param);
extern FLAXENGINE_API void ReadOldGraphNodeValue_Deprecated(ReadStream* stream, Variant& result);
extern FLAXENGINE_API void ReadOldGraphBoxType_Deprecated(uint32 connectionType, VariantType& type);
extern FLAXENGINE_API StringView GetGraphFunctionTypeName_Deprecated(const Variant& v);
@@ -183,158 +180,10 @@ public:
Array<TmpConnectionHint> tmpHints;
if (version < 7000)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
MARK_CONTENT_DEPRECATED();
// Time saved
int64 timeSaved;
stream->ReadInt64(&timeSaved);
// Nodes count
int32 nodesCount;
stream->ReadInt32(&nodesCount);
Nodes.Resize(nodesCount, false);
// Parameters count
int32 parametersCount;
stream->ReadInt32(&parametersCount);
Parameters.Resize(parametersCount, false);
// For each node
for (int32 i = 0; i < nodesCount; i++)
{
auto node = &Nodes[i];
// ID
stream->ReadUint32(&node->ID);
// Type
stream->ReadUint32(&node->Type);
if (onNodeCreated(node))
return true;
}
// For each param
for (int32 i = 0; i < parametersCount; i++)
{
// Create param
auto param = &Parameters[i];
// Properties
auto type = stream->ReadByte();
stream->Read(param->Identifier);
stream->Read(param->Name, 97);
param->IsPublic = stream->ReadBool();
bool isStatic = stream->ReadBool();
bool isUIVisible = stream->ReadBool();
bool isUIEditable = stream->ReadBool();
// References [Deprecated]
int32 refsCount;
stream->ReadInt32(&refsCount);
for (int32 j = 0; j < refsCount; j++)
{
uint32 refID;
stream->ReadUint32(&refID);
}
// Value
ReadOldGraphParamValue_Deprecated(type, stream, param);
// Meta
if (param->Meta.Load(stream, loadMeta))
return true;
if (onParamCreated(param))
return true;
}
// For each node
for (int32 i = 0; i < nodesCount; i++)
{
auto node = &Nodes[i];
// Values
int32 valuesCnt;
stream->ReadInt32(&valuesCnt);
node->Values.Resize(valuesCnt);
for (int32 j = 0; j < valuesCnt; j++)
ReadOldGraphNodeValue_Deprecated(stream, node->Values[j]);
// Boxes
uint16 boxesCount;
stream->ReadUint16(&boxesCount);
node->Boxes.Clear();
for (int32 j = 0; j < boxesCount; j++)
{
byte boxID = stream->ReadByte();
node->Boxes.Resize(node->Boxes.Count() > boxID + 1 ? node->Boxes.Count() : boxID + 1);
Box* box = &node->Boxes[boxID];
box->Parent = node;
box->ID = boxID;
uint32 connectionType;
stream->ReadUint32((uint32*)&connectionType);
ReadOldGraphBoxType_Deprecated(connectionType, box->Type);
uint16 connectionsCount;
stream->ReadUint16(&connectionsCount);
box->Connections.Resize(connectionsCount);
for (int32 k = 0; k < connectionsCount; k++)
{
uint32 targetNodeID;
stream->ReadUint32(&targetNodeID);
byte targetBoxID = stream->ReadByte();
TmpConnectionHint hint;
hint.Node = GetNode(targetNodeID);
if (hint.Node == nullptr)
return true;
hint.BoxID = targetBoxID;
box->Connections[k] = (Box*)(intptr)tmpHints.Count();
tmpHints.Add(hint);
}
}
// Meta
if (node->Meta.Load(stream, loadMeta))
return true;
if (onNodeLoaded(node))
return true;
}
// Visject Meta
if (Meta.Load(stream, loadMeta))
return true;
// Setup connections
for (int32 i = 0; i < Nodes.Count(); i++)
{
auto node = &Nodes[i];
for (int32 j = 0; j < node->Boxes.Count(); j++)
{
Box* box = &node->Boxes[j];
if (box->Parent == nullptr)
continue;
for (int32 k = 0; k < box->Connections.Count(); k++)
{
int32 hintIndex = (int32)(intptr)box->Connections[k];
TmpConnectionHint hint = tmpHints[hintIndex];
box->Connections[k] = hint.Node->GetBox(hint.BoxID);
}
}
}
// Ending char
byte end;
stream->ReadByte(&end);
if (end != '\t')
{
return true;
}
LOG(Warning, "Not supported Visject Surface version. Open and re-save asset with Flax 1.11.");
return true;
}
else if (version == 7000)
if (version == 7000)
{
// Nodes count
int32 nodesCount;

View File

@@ -1,6 +1,9 @@
// Copyright (c) Wojciech Figat. All rights reserved.
#include "GraphUtilities.h"
#include "Engine/Core/Math/Vector2.h"
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Math/Vector4.h"
// [Deprecated on 31.07.2020, expires on 31.07.2022]
enum class GraphParamType_Deprecated
@@ -56,130 +59,17 @@ enum class GraphConnectionType_Deprecated : uint32
};
// Required by deprecated graph data upgrade code
#include "Engine/Content/Deprecated.h"
#include "Engine/Content/Assets/Texture.h"
#include "Engine/Content/Assets/CubeTexture.h"
#include "Engine/Scripting/ScriptingObjectReference.h"
#include "Engine/Core/Types/CommonValue.h"
#include "Engine/Level/Actor.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
FLAXENGINE_API void ReadOldGraphParamValue_Deprecated(byte graphParamType, ReadStream* stream, GraphParameter* param)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
CommonValue value;
stream->ReadCommonValue(&value);
switch ((GraphParamType_Deprecated)graphParamType)
{
case GraphParamType_Deprecated::Bool:
param->Type = VariantType(VariantType::Bool);
param->Value = value.GetBool();
break;
case GraphParamType_Deprecated::Integer:
param->Type = VariantType(VariantType::Int);
param->Value = value.GetInteger();
break;
case GraphParamType_Deprecated::Float:
param->Type = VariantType(VariantType::Float);
param->Value = value.GetFloat();
break;
case GraphParamType_Deprecated::Vector2:
param->Type = VariantType(VariantType::Float2);
param->Value = value.GetVector2();
break;
case GraphParamType_Deprecated::Vector3:
param->Type = VariantType(VariantType::Float3);
param->Value = value.GetVector3();
break;
case GraphParamType_Deprecated::Vector4:
param->Type = VariantType(VariantType::Float4);
param->Value = value.GetVector4();
break;
case GraphParamType_Deprecated::Color:
param->Type = VariantType(VariantType::Color);
param->Value = value.GetColor();
break;
case GraphParamType_Deprecated::Texture:
case GraphParamType_Deprecated::NormalMap:
ASSERT(value.Type == CommonType::Guid);
param->Type = VariantType(VariantType::Asset, TEXT("FlaxEngine.Texture"));
param->Value.SetAsset(LoadAsset(value.AsGuid, Texture::TypeInitializer));
break;
case GraphParamType_Deprecated::String:
ASSERT(value.Type == CommonType::String);
param->Type = VariantType(VariantType::String);
param->Value.SetString(StringView(value.AsString));
break;
case GraphParamType_Deprecated::Box:
ASSERT(value.Type == CommonType::Box);
param->Type = VariantType(VariantType::BoundingBox);
param->Value = Variant(value.AsBox);
break;
case GraphParamType_Deprecated::Rotation:
ASSERT(value.Type == CommonType::Rotation);
param->Type = VariantType(VariantType::Quaternion);
param->Value = value.AsRotation;
break;
case GraphParamType_Deprecated::Transform:
ASSERT(value.Type == CommonType::Transform);
param->Type = VariantType(VariantType::Transform);
param->Value = Variant(value.AsTransform);
break;
case GraphParamType_Deprecated::Asset:
ASSERT(value.Type == CommonType::Guid);
param->Type = VariantType(VariantType::Asset);
param->Value.SetAsset(LoadAsset(value.AsGuid, Asset::TypeInitializer));
break;
case GraphParamType_Deprecated::Rectangle:
ASSERT(value.Type == CommonType::Rectangle);
param->Type = VariantType(VariantType::Rectangle);
param->Value = value.AsRectangle;
break;
case GraphParamType_Deprecated::Matrix:
ASSERT(value.Type == CommonType::Matrix);
param->Type = VariantType(VariantType::Matrix);
param->Value = Variant(value.AsMatrix);
break;
case GraphParamType_Deprecated::Actor:
ASSERT(value.Type == CommonType::Guid);
param->Type = VariantType(VariantType::Object, TEXT("FlaxEngine.Actor"));
param->Value.SetObject(FindObject(value.AsGuid, Actor::GetStaticClass()));
break;
case GraphParamType_Deprecated::CubeTexture:
ASSERT(value.Type == CommonType::Guid);
param->Type = VariantType(VariantType::Asset, TEXT("FlaxEngine.CubeTexture"));
param->Value.SetAsset(LoadAsset(value.AsGuid, CubeTexture::TypeInitializer));
break;
case GraphParamType_Deprecated::GPUTexture:
case GraphParamType_Deprecated::GPUTextureArray:
case GraphParamType_Deprecated::GPUTextureVolume:
case GraphParamType_Deprecated::GPUTextureCube:
param->Type = VariantType(VariantType::Object, TEXT("FlaxEngine.GPUTexture"));
param->Value.SetObject(nullptr);
break;
case GraphParamType_Deprecated::SceneTexture:
param->Type = VariantType(VariantType::Enum, TEXT("FlaxEngine.MaterialSceneTextures"));
param->Value.AsUint64 = (uint64)value.AsInteger;
break;
case GraphParamType_Deprecated::ChannelMask:
param->Type = VariantType(VariantType::Enum, TEXT("FlaxEngine.ChannelMask"));
param->Value.AsUint64 = (uint64)value.AsInteger;
break;
default:
CRASH;
}
}
FLAXENGINE_API void ReadOldGraphNodeValue_Deprecated(ReadStream* stream, Variant& result)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
CommonValue value;
stream->ReadCommonValue(&value);
result = Variant(value);
}
FLAXENGINE_API void ReadOldGraphBoxType_Deprecated(uint32 connectionType, VariantType& type)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
MARK_CONTENT_DEPRECATED();
switch ((GraphConnectionType_Deprecated)connectionType)
{
case GraphConnectionType_Deprecated::Invalid:
@@ -247,6 +137,7 @@ FLAXENGINE_API void ReadOldGraphBoxType_Deprecated(uint32 connectionType, Varian
FLAXENGINE_API StringView GetGraphFunctionTypeName_Deprecated(const Variant& v)
{
// [Deprecated on 31.07.2020, expires on 31.07.2022]
MARK_CONTENT_DEPRECATED();
if (v.Type.Type == VariantType::String)
return (StringView)v;
if (v.Type.Type == VariantType::Int)