Browse Source

Use intermediate only for pen

Krzysztof Krysiński 1 month ago
parent
commit
ac06fa4a30

+ 5 - 3
src/PixiEditor.ChangeableDocument/Changeables/Brushes/BrushEngine.cs

@@ -1,5 +1,6 @@
 using System.Diagnostics;
 using System.Diagnostics;
 using Drawie.Backend.Core;
 using Drawie.Backend.Core;
+using Drawie.Backend.Core.ColorsImpl;
 using Drawie.Backend.Core.ColorsImpl.Paintables;
 using Drawie.Backend.Core.ColorsImpl.Paintables;
 using Drawie.Backend.Core.Numerics;
 using Drawie.Backend.Core.Numerics;
 using Drawie.Backend.Core.Surfaces;
 using Drawie.Backend.Core.Surfaces;
@@ -42,7 +43,7 @@ public class BrushEngine : IDisposable
             return;
             return;
         }
         }
 
 
-        if (brushData.BrushGraph.AllNodes.FirstOrDefault(x => x is BrushOutputNode) is not BrushOutputNode brushNode)
+        if (brushData.BrushGraph.LookupNode(brushData.TargetBrushNodeId) is not BrushOutputNode brushNode)
         {
         {
             return;
             return;
         }
         }
@@ -108,7 +109,7 @@ public class BrushEngine : IDisposable
     public void ExecuteBrush(ChunkyImage? target, BrushData brushData, VecD point, KeyFrameTime frameTime, ColorSpace cs,
     public void ExecuteBrush(ChunkyImage? target, BrushData brushData, VecD point, KeyFrameTime frameTime, ColorSpace cs,
         SamplingOptions samplingOptions, PointerInfo pointerInfo, KeyboardInfo keyboardInfo, EditorData editorData)
         SamplingOptions samplingOptions, PointerInfo pointerInfo, KeyboardInfo keyboardInfo, EditorData editorData)
     {
     {
-        var brushNode = brushData.BrushGraph?.AllNodes?.FirstOrDefault(x => x is BrushOutputNode) as BrushOutputNode;
+        var brushNode = brushData.BrushGraph?.LookupNode(brushData.TargetBrushNodeId) as BrushOutputNode;
         if (brushNode == null)
         if (brushNode == null)
         {
         {
             return;
             return;
@@ -119,7 +120,8 @@ public class BrushEngine : IDisposable
             editorData);
             editorData);
     }
     }
 
 
-    private void ExecuteVectorShapeBrush(ChunkyImage? target, BrushOutputNode brushNode, BrushData brushData, VecD point,
+    private void ExecuteVectorShapeBrush(ChunkyImage? target, BrushOutputNode brushNode, BrushData brushData,
+        VecD point,
         KeyFrameTime frameTime,
         KeyFrameTime frameTime,
         ColorSpace colorSpace, SamplingOptions samplingOptions,
         ColorSpace colorSpace, SamplingOptions samplingOptions,
         PointerInfo pointerInfo, KeyboardInfo keyboardInfo, EditorData editorData)
         PointerInfo pointerInfo, KeyboardInfo keyboardInfo, EditorData editorData)

+ 1 - 1
src/PixiEditor/Models/DocumentModels/ChangeExecutionController.cs

@@ -181,7 +181,7 @@ internal class ChangeExecutionController
 
 
     public void MouseMoveInlet(MouseOnCanvasEventArgs args)
     public void MouseMoveInlet(MouseOnCanvasEventArgs args)
     {
     {
-        if (args.IntermediatePoints != null)
+        if (args.IntermediatePoints != null && args.PointerType == PointerType.Pen)
         {
         {
             foreach (var point in args.IntermediatePoints)
             foreach (var point in args.IntermediatePoints)
             {
             {

+ 2 - 1
src/PixiEditor/Views/Main/ViewportControls/Viewport.axaml.cs

@@ -580,8 +580,9 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
 
 
         var intermediate = e.GetIntermediatePoints(this);
         var intermediate = e.GetIntermediatePoints(this);
         List<PointerPosition> intermediatePositions = new();
         List<PointerPosition> intermediatePositions = new();
-        foreach (var point in intermediate)
+        for (var i = 0; i < intermediate.Count; i++)
         {
         {
+            var point = intermediate[i];
             Point interPos = point.Position;
             Point interPos = point.Position;
             VecD interConv = Scene.ToZoomboxSpace(new VecD(interPos.X, interPos.Y));
             VecD interConv = Scene.ToZoomboxSpace(new VecD(interPos.X, interPos.Y));
             intermediatePositions.Add(new PointerPosition(interConv, point.Properties));
             intermediatePositions.Add(new PointerPosition(interConv, point.Properties));