Преглед на файлове

Fixed create new image allocation and node execution queue

flabbet преди 1 година
родител
ревизия
1f78a9bd24

+ 29 - 7
src/PixiEditor.AvaloniaUI/Helpers/DocumentViewModelBuilder.cs

@@ -288,13 +288,35 @@ internal class NodeGraphBuilder
                 .WithKeyFrames(
                 [
                     new KeyFrameData
-                        {
-                            AffectedElement = ImageLayerNode.ImageLayerKey,
-                            Data = new ChunkyImage(image),
-                            Duration = 0,
-                            StartFrame = 0,
-                            IsVisible = true
-                        }
+                    {
+                        AffectedElement = ImageLayerNode.ImageLayerKey,
+                        Data = new ChunkyImage(image),
+                        Duration = 0,
+                        StartFrame = 0,
+                        IsVisible = true
+                    }
+                ]));
+
+        id = AllNodes.Count;
+        return this;
+    }
+
+    public NodeGraphBuilder WithImageLayerNode(string name, VecI size, out int id)
+    {
+        AllNodes.Add(
+            this.WithNodeOfType(typeof(ImageLayerNode))
+                .WithName(name)
+                .WithId(AllNodes.Count + 1)
+                .WithKeyFrames(
+                [
+                    new KeyFrameData
+                    {
+                        AffectedElement = ImageLayerNode.ImageLayerKey,
+                        Data = new ChunkyImage(size),
+                        Duration = 0,
+                        StartFrame = 0,
+                        IsVisible = true
+                    }
                 ]));
 
         id = AllNodes.Count;

+ 1 - 1
src/PixiEditor.AvaloniaUI/ViewModels/SubViewModels/FileViewModel.cs

@@ -302,7 +302,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
                 .WithGraph(x => x
                     .WithImageLayerNode(
                         new LocalizedString("BASE_LAYER_NAME"),
-                        new Surface(new VecI(newFile.Width, newFile.Height)), out int id)
+                        new VecI(newFile.Width, newFile.Height), out int id)
                     .WithOutputNode(id, "Output")
                 ));
         }

+ 7 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/NodeGraph.cs

@@ -60,6 +60,13 @@ public class NodeGraph : IReadOnlyNodeGraph, IDisposable
                 {
                     continue;
                 }
+                
+                if(finalQueue.Contains(input.Connection.Node))
+                {
+                   // swap the order of the nodes
+                   finalQueue.Remove(input.Connection.Node);
+                   finalQueue.Add(input.Connection.Node);
+                }
 
                 queueNodes.Enqueue(input.Connection.Node);
             }