Browse Source

Fixed Viewport center content and chunk change render bug

flabbet 1 year ago
parent
commit
ab97b2f72d

+ 0 - 1
src/PixiEditor/ViewModels/Document/DocumentViewModel.cs

@@ -169,7 +169,6 @@ internal partial class DocumentViewModel : PixiObservableObject, IDocument
 
 
     public IStructureMemberHandler? SelectedStructureMember { get; private set; } = null;
     public IStructureMemberHandler? SelectedStructureMember { get; private set; } = null;
 
 
-    //TODO: It was DrawingSurface before, check if it's correct
     public Dictionary<ChunkResolution, Texture> Surfaces { get; set; } = new()
     public Dictionary<ChunkResolution, Texture> Surfaces { get; set; } = new()
     {
     {
         [ChunkResolution.Full] = new Texture(new VecI(64, 64)),
         [ChunkResolution.Full] = new Texture(new VecI(64, 64)),

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

@@ -460,7 +460,7 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
     private void ResetViewportClicked(object sender, RoutedEventArgs e)
     private void ResetViewportClicked(object sender, RoutedEventArgs e)
     {
     {
         scene.AngleRadians = 0;
         scene.AngleRadians = 0;
-        scene.CenterContent();
+        scene.CenterContent(Document.SizeBindable);
     }
     }
 
 
     private static void CenterViewportTriggerChanged(AvaloniaPropertyChangedEventArgs<ExecutionTrigger<VecI>> e)
     private static void CenterViewportTriggerChanged(AvaloniaPropertyChangedEventArgs<ExecutionTrigger<VecI>> e)

+ 1 - 0
src/PixiEditor/Views/Rendering/Scene.cs

@@ -151,6 +151,7 @@ internal class Scene : Zoombox.Zoombox, ICustomHitTest
         RectD dirtyBounds = new RectD(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
         RectD dirtyBounds = new RectD(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
         Rect dirtyRect = new Rect(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
         Rect dirtyRect = new Rect(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
 
 
+        Surface.DrawingSurface.Flush();
         using var operation = new DrawSceneOperation(Surface, Document, CanvasPos, Scale * resolutionScale,
         using var operation = new DrawSceneOperation(Surface, Document, CanvasPos, Scale * resolutionScale,
             resolutionScale, angle,
             resolutionScale, angle,
             FlipX, FlipY,
             FlipX, FlipY,