Browse Source

Fixed Node cloning

flabbet 1 year ago
parent
commit
da4cecab81

+ 8 - 5
src/PixiEditor.AvaloniaUI/Data/Localization/Languages/en.json

@@ -657,10 +657,13 @@
   "MODIFY_IMAGE_RIGHT_NODE": "End Modify Image",
   "COMBINE_CHANNELS_NODE": "Combine Channels",
   "COMBINE_COLOR_NODE": "Combine Color",
-  "COMBINE_VECD_NODE": "Combine Vector (float)",
-  "COMBINE_VECI_NODE": "Combine Vector (int)",
+  "COMBINE_VECD_NODE": "Combine Vector",
+  "COMBINE_VECI_NODE": "Combine Integer Vector",
   "SEPARATE_CHANNELS_NODE": "Separate Channels",
-  "SEPARATE_VECD_NODE": "Separate Vector (float)",
-  "SEPARATE_VECI_NODE": "Separate Vector (int)",
-  "TIME_NODE": "Time"
+  "SEPARATE_VECD_NODE": "Separate Vector",
+  "SEPARATE_VECI_NODE": "Separate Integer Vector",
+  "TIME_NODE": "Time",
+  "FILTERS": "Filters",
+  "PREVIOUS": "Previous",
+  "FILL": "Fill",
 }

+ 6 - 6
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Node.cs

@@ -313,16 +313,16 @@ public abstract class Node : IReadOnlyNode, IDisposable
 
         for (var i = 0; i < clone.inputs.Count; i++)
         {
-            var input = inputs[i];
-            var newInput = input.Clone(clone);
-            input.NonOverridenValue = newInput.NonOverridenValue;
+            var cloneInput = inputs[i];
+            var newInput = cloneInput.Clone(clone);
+            clone.inputs[i].NonOverridenValue = newInput.NonOverridenValue;
         }
 
         for (var i = 0; i < clone.outputs.Count; i++)
         {
-            var output = outputs[i];
-            var newOutput = output.Clone(clone);
-            output.Value = newOutput.Value;
+            var cloneOutput = outputs[i];
+            var newOutput = cloneOutput.Clone(clone);
+            clone.outputs[i].Value = newOutput.Value; 
         }
 
         return clone;

+ 2 - 2
src/PixiEditor.ChangeableDocument/Changeables/Graph/OutputProperty.cs

@@ -81,8 +81,8 @@ public class OutputProperty : IOutputProperty
             return new OutputProperty(clone, InternalPropertyName, DisplayName, enumVal, ValueType);
         }
 
-        if (Value is not ICloneable && !Value.GetType().IsPrimitive && Value.GetType() != typeof(string))
-            throw new InvalidOperationException("Value is not cloneable and not a primitive type");
+        /*if (Value is not ICloneable && !Value.GetType().IsPrimitive && Value.GetType() != typeof(string))
+            throw new InvalidOperationException("Value is not cloneable and not a primitive type");*/
      
         object value = Value is ICloneable cloneableValue ? cloneableValue.Clone() : Value;
         

+ 7 - 1
src/PixiEditor.Numerics/Kernel.cs

@@ -2,7 +2,7 @@
 
 namespace PixiEditor.Numerics;
 
-public class Kernel
+public class Kernel : ICloneable
 {
     private KernelArray _buffer;
 
@@ -77,4 +77,10 @@ public class Kernel
     }
 
     public ReadOnlySpan<float> AsSpan() => _buffer.AsSpan();
+    public object Clone()
+    {
+        float[] values = new float[Width * Height];
+        AsSpan().CopyTo(values);
+        return new Kernel(Width, Height, values);
+    }
 }