Skip to content

Commit aa11aba

Browse files
committed
deprecated old cloning logic / fixed spline cloning
1 parent c58fa09 commit aa11aba

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

CathodeLib/Scripts/CATHODE/CommandsPAK/Components/ParameterData.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ public object Clone()
106106
switch (dataType)
107107
{
108108
case DataType.RESOURCE:
109-
return Utilities.CloneObject(this);
110-
//HOTFIX FOR VECTOR 3 CLONE ISSUE - TODO: FIND WHY THIS ISN'T WORKING WITH MEMBERWISE CLONE
109+
cResource r = (cResource)this.MemberwiseClone();
110+
r.value = ((cResource)this).value.Select(item => (ResourceReference)item.Clone()).ToList();
111+
return r;
112+
case DataType.SPLINE:
113+
cSpline s = (cSpline)this.MemberwiseClone();
114+
s.splinePoints = ((cSpline)this).splinePoints.Select(item => (cTransform)item.Clone()).ToList();
115+
return s;
111116
case DataType.VECTOR:
112117
cVector3 v3 = (cVector3)this.MemberwiseClone();
113118
Vector3 v3_v = (Vector3)((cVector3)this).value;
@@ -132,7 +137,6 @@ public object Clone()
132137
tr.rotation = new Vector3(tr_r.X, tr_r.Y, tr_r.Z);
133138
#endif
134139
return tr;
135-
//END OF HOTFIX - SHOULD THIS ALSO APPLY TO OTHERS?? SPLINE?
136140
default:
137141
return this.MemberwiseClone();
138142
}

CathodeLib/Scripts/Utilities.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,6 @@ public static void Write<T>(BinaryWriter stream, List<T> aux)
184184
Write<T>(stream, aux.ToArray<T>());
185185
}
186186

187-
//Clones an object (slow!)
188-
public static T CloneObject<T>(T obj)
189-
{
190-
//A somewhat hacky an inefficient way of deep cloning an object (TODO: optimise this as we use it a lot!)
191-
MemoryStream ms = new MemoryStream();
192-
new BinaryFormatter().Serialize(ms, obj);
193-
ms.Position = 0;
194-
T obj2 = (T)new BinaryFormatter().Deserialize(ms);
195-
ms.Close();
196-
return obj2;
197-
//obj.MemberwiseClone();
198-
}
199-
200187
//Generate a hashed string for use in the animation system (FNV hash)
201188
public static uint AnimationHashedString(string str)
202189
{

0 commit comments

Comments
 (0)