From 023b68ffae1815a45f2905307942088c50ab6a59 Mon Sep 17 00:00:00 2001 From: 4sval Date: Sat, 22 Oct 2022 00:17:56 +0200 Subject: [PATCH] fixed gap between grid and skybox --- FModel/MainWindow.xaml.cs | 2 +- FModel/ViewModels/Commands/LoadCommand.cs | 13 ++++++- FModel/Views/Snooper/Camera.cs | 42 ++++++++++++++++++++++- FModel/Views/Snooper/Section.cs | 1 - 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index e559073d..718b4a77 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -79,7 +79,7 @@ public partial class MainWindow #if DEBUG await _threadWorkerView.Begin(cancellationToken => _applicationView.CUE4Parse.Extract(cancellationToken, - "FortniteGame/Content/Environments/Apollo/Props/Log_Sign/Meshes/SM_Apollo_Log_Sign.uasset")); + "fortnitegame/Content/Accessories/FORT_Backpacks/Backpack_F_MED_FNCS_S20/Meshes/F_MED_FNCS_S20_Pack.uasset")); #endif } diff --git a/FModel/ViewModels/Commands/LoadCommand.cs b/FModel/ViewModels/Commands/LoadCommand.cs index 3e26ccc4..df010f86 100644 --- a/FModel/ViewModels/Commands/LoadCommand.cs +++ b/FModel/ViewModels/Commands/LoadCommand.cs @@ -131,12 +131,19 @@ public class LoadCommand : ViewModelCommand if (hasFilter) { if (filter.Contains(entry.Vfs.Name)) + { entries.Add(entry); + _applicationView.Status.UpdateStatusLabel(entry.Vfs.Name); + } } else + { entries.Add(entry); + _applicationView.Status.UpdateStatusLabel(entry.Vfs.Name); + } } + _applicationView.Status.UpdateStatusLabel("Folders & Packages"); _applicationView.CUE4Parse.AssetsFolder.BulkPopulate(entries); } @@ -170,7 +177,8 @@ public class LoadCommand : ViewModelCommand using var archive = new FStreamArchive(fileStream.Name, memoryStream); var entries = new List(); - switch (UserSettings.Default.LoadingMode) + var mode = UserSettings.Default.LoadingMode; + switch (mode) { case ELoadingMode.AllButNew: { @@ -191,6 +199,7 @@ public class LoadCommand : ViewModelCommand entry.Path.EndsWith(".ubulk") || entry.Path.EndsWith(".uptnl")) continue; entries.Add(entry); + _applicationView.Status.UpdateStatusLabel(entry.Vfs.Name); } break; @@ -214,12 +223,14 @@ public class LoadCommand : ViewModelCommand continue; entries.Add(entry); + _applicationView.Status.UpdateStatusLabel(entry.Vfs.Name); } break; } } + _applicationView.Status.UpdateStatusLabel($"{mode.ToString()[6..]} Folders & Packages"); _applicationView.CUE4Parse.AssetsFolder.BulkPopulate(entries); } } diff --git a/FModel/Views/Snooper/Camera.cs b/FModel/Views/Snooper/Camera.cs index c53f3234..aacb5a1a 100644 --- a/FModel/Views/Snooper/Camera.cs +++ b/FModel/Views/Snooper/Camera.cs @@ -61,6 +61,46 @@ public class Camera public Matrix4 GetProjectionMatrix() { - return Matrix4.CreatePerspectiveFieldOfView(Helper.DegreesToRadians(Zoom), AspectRatio, Near, Far); + return CreatePerspectiveFieldOfView(Helper.DegreesToRadians(Zoom), AspectRatio, Near, Far); + } + + /// + /// OpenTK function causes a gap between the faded out grid & the skybox + /// so we use the System.Numerics function instead with OpenTK types + /// + private Matrix4 CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance) + { + if (fieldOfView is <= 0.0f or >= MathF.PI) + throw new ArgumentOutOfRangeException(nameof(fieldOfView)); + + if (nearPlaneDistance <= 0.0f) + throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); + + if (farPlaneDistance <= 0.0f) + throw new ArgumentOutOfRangeException(nameof(farPlaneDistance)); + + if (nearPlaneDistance >= farPlaneDistance) + throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); + + float yScale = 1.0f / MathF.Tan(fieldOfView * 0.5f); + float xScale = yScale / aspectRatio; + + Matrix4 result = Matrix4.Zero; + + result.M11 = xScale; + result.M12 = result.M13 = result.M14 = 0.0f; + + result.M22 = yScale; + result.M21 = result.M23 = result.M24 = 0.0f; + + result.M31 = result.M32 = 0.0f; + float negFarRange = float.IsPositiveInfinity(farPlaneDistance) ? -1.0f : farPlaneDistance / (nearPlaneDistance - farPlaneDistance); + result.M33 = negFarRange; + result.M34 = -1.0f; + + result.M41 = result.M42 = result.M44 = 0.0f; + result.M43 = nearPlaneDistance * negFarRange; + + return result; } } diff --git a/FModel/Views/Snooper/Section.cs b/FModel/Views/Snooper/Section.cs index 9a388f05..b2ba61ed 100644 --- a/FModel/Views/Snooper/Section.cs +++ b/FModel/Views/Snooper/Section.cs @@ -7,7 +7,6 @@ using FModel.Services; using FModel.Settings; using OpenTK.Graphics.OpenGL4; using OpenTK.Mathematics; -using SkiaSharp; namespace FModel.Views.Snooper;