This commit is contained in:
iAmAsval 2021-11-21 16:35:14 +01:00
parent 235f663ea5
commit d846750ac6
5 changed files with 18 additions and 46 deletions

@ -1 +1 @@
Subproject commit c1fbac1c5729fb541d36546f4ff32cbfa347e741
Subproject commit d2163de354e97a0e62222221b96666a678255884

View File

@ -6,9 +6,7 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using AdonisUI.Controls;
using CUE4Parse.Encryption.Aes;
using CUE4Parse.FileProvider;
using CUE4Parse.FileProvider.Vfs;
@ -28,13 +26,10 @@ using CUE4Parse.UE4.Oodle.Objects;
using CUE4Parse.UE4.Shaders;
using CUE4Parse.UE4.Versions;
using CUE4Parse.UE4.Wwise;
using CUE4Parse_Conversion;
using CUE4Parse_Conversion.Sounds;
using CUE4Parse_Conversion.Textures;
using EpicManifestParser.Objects;
using FModel.Creator;
using FModel.Extensions;
using FModel.Framework;
@ -42,11 +37,8 @@ using FModel.Services;
using FModel.Settings;
using FModel.Views;
using FModel.Views.Resources.Controls;
using Newtonsoft.Json;
using Serilog;
using SkiaSharp;
namespace FModel.ViewModels
@ -687,21 +679,19 @@ namespace FModel.ViewModels
export.Owner.Name.EndsWith($"/RenderSwitch_Materials/{export.Name}", StringComparison.OrdinalIgnoreCase) ||
export.Owner.Name.EndsWith($"/MI_BPTile/{export.Name}", StringComparison.OrdinalIgnoreCase))):
{
Application.Current.Dispatcher.Invoke(async () =>
Application.Current.Dispatcher.InvokeAsync(() =>
{
var modelViewer = Helper.GetWindow<ModelViewer>("Model Viewer", () => new ModelViewer().Show());
await Task.Delay(100).ConfigureAwait(true);
await modelViewer.Load(export).ConfigureAwait(true);
modelViewer.Load(export);
});
return true;
}
case UMaterialInstance m when ModelIsSwappingMaterial:
{
Application.Current.Dispatcher.Invoke(async () =>
Application.Current.Dispatcher.InvokeAsync(() =>
{
var modelViewer = Helper.GetWindow<ModelViewer>("Model Viewer", () => new ModelViewer().Show());
await Task.Delay(100).ConfigureAwait(true);
await modelViewer.Swap(m).ConfigureAwait(true);
modelViewer.Swap(m);
});
return true;
}

View File

@ -3,40 +3,29 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Media3D;
using CUE4Parse.UE4.Assets.Exports;
using CUE4Parse.UE4.Assets.Exports.Material;
using CUE4Parse.UE4.Assets.Exports.SkeletalMesh;
using CUE4Parse.UE4.Assets.Exports.StaticMesh;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse.UE4.Objects.Core.Math;
using CUE4Parse_Conversion.Meshes;
using CUE4Parse_Conversion.Meshes.PSK;
using CUE4Parse_Conversion.Textures;
using FModel.Extensions;
using FModel.Framework;
using FModel.Services;
using FModel.Settings;
using FModel.Views.Resources.Controls;
using HelixToolkit.SharpDX.Core;
using HelixToolkit.Wpf.SharpDX;
using Ookii.Dialogs.Wpf;
using Serilog;
using SharpDX;
using SkiaSharp;
using Camera = HelixToolkit.Wpf.SharpDX.Camera;
using Geometry3D = HelixToolkit.SharpDX.Core.Geometry3D;
using PerspectiveCamera = HelixToolkit.Wpf.SharpDX.PerspectiveCamera;
@ -152,8 +141,8 @@ namespace FModel.ViewModels
}
bool valid = false;
//await _threadWorkerView.Begin(_ =>
//{
await _threadWorkerView.Begin(_ =>
{
valid = export switch
{
UStaticMesh st => TryLoadStaticMesh(st, p),
@ -161,7 +150,7 @@ namespace FModel.ViewModels
UMaterialInstance mi => TryLoadMaterialInstance(mi, p),
_ => throw new ArgumentOutOfRangeException(nameof(export))
};
//}).ConfigureAwait(true);
});
if (!valid) return;
SelectedModel = p;
}
@ -258,7 +247,7 @@ namespace FModel.ViewModels
{
var (material, _, _) = LoadMaterial(materialInstance);
m = material;
}).ConfigureAwait(true);
});
if (m == null) return false;
model.SelectedGeometry.Material = m;

View File

@ -1,12 +1,10 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using FModel.Extensions;
using FModel.Framework;
using FModel.Services;
using FModel.Views.Resources.Controls;
using Serilog;
namespace FModel.ViewModels
@ -59,7 +57,7 @@ namespace FModel.ViewModels
CurrentCancellationTokenSource ??= new CancellationTokenSource();
_jobs.Enqueue(action);
await ProcessQueues().ConfigureAwait(true);
await ProcessQueues();
}
public void Cancel()
@ -78,12 +76,12 @@ namespace FModel.ViewModels
if (_jobs.Count > 0)
{
_applicationView.Status = EStatusKind.Loading;
await foreach (var job in _jobs.ConfigureAwait(true))
await foreach (var job in _jobs)
{
try
{
// will end in "catch" if canceled
await Task.Run(() => job(CurrentCancellationTokenSource.Token)).ConfigureAwait(true);
await Task.Run(() => job(CurrentCancellationTokenSource.Token));
}
catch (OperationCanceledException)
{

View File

@ -1,16 +1,11 @@
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using AdonisUI.Controls;
using CUE4Parse.UE4.Assets.Exports;
using CUE4Parse.UE4.Assets.Exports.Material;
using FModel.Services;
using FModel.ViewModels;
using MessageBox = AdonisUI.Controls.MessageBox;
using MessageBoxImage = AdonisUI.Controls.MessageBoxImage;
@ -27,10 +22,10 @@ namespace FModel.Views
InitializeComponent();
}
public async Task Load(UObject export) => await _applicationView.ModelViewer.LoadExport(export).ConfigureAwait(true);
public async Task Swap(UMaterialInstance materialInstance)
public async void Load(UObject export) => await _applicationView.ModelViewer.LoadExport(export);
public async void Swap(UMaterialInstance materialInstance)
{
var sucess = await _applicationView.ModelViewer.TryChangeSelectedMaterial(materialInstance).ConfigureAwait(true);
var sucess = await _applicationView.ModelViewer.TryChangeSelectedMaterial(materialInstance);
if (sucess)
{
_applicationView.CUE4Parse.ModelIsSwappingMaterial = false;
@ -66,9 +61,9 @@ namespace FModel.Views
case Key.H:
_applicationView.ModelViewer.RenderingToggle();
break;
case Key.D:
_applicationView.ModelViewer.DiffuseOnlyToggle();
break;
// case Key.D:
// _applicationView.ModelViewer.DiffuseOnlyToggle();
// break;
case Key.Decimal:
_applicationView.ModelViewer.FocusOnSelectedMesh();
break;