mirror of
https://github.com/4sval/FModel.git
synced 2026-07-02 00:02:32 -05:00
it is about time the update thread gets fixed
This commit is contained in:
parent
5dc90e6ec8
commit
946d38c87b
|
|
@ -1 +1 @@
|
|||
Subproject commit f9bff17d172e72184678211c567f708e25bb3f68
|
||||
Subproject commit 4f5d66ac7cacb0aad373a9f19c203569f1c38a93
|
||||
|
|
@ -135,19 +135,19 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="AdonisUI" Version="1.17.1" />
|
||||
<PackageReference Include="AdonisUI.ClassicTheme" Version="1.17.1" />
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.8.2" />
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.8.3" />
|
||||
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
|
||||
<PackageReference Include="CSCore" Version="1.2.1.2" />
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.1.3.18" />
|
||||
<PackageReference Include="ImGui.NET" Version="1.89.5" />
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
|
||||
<PackageReference Include="ImGui.NET" Version="1.89.7.1" />
|
||||
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.3.5" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NVorbis" Version="0.10.5" />
|
||||
<PackageReference Include="Oodle.NET" Version="1.0.1" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="OpenTK" Version="4.7.7" />
|
||||
<PackageReference Include="OpenTK" Version="4.8.0" />
|
||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog" Version="3.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
|
||||
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.3" />
|
||||
|
|
|
|||
|
|
@ -83,9 +83,12 @@ public partial class MainWindow
|
|||
).ConfigureAwait(false);
|
||||
|
||||
#if DEBUG
|
||||
// await _threadWorkerView.Begin(cancellationToken =>
|
||||
// _applicationView.CUE4Parse.Extract(cancellationToken,
|
||||
// "fortnitegame/Content/Characters/Player/Female/Medium/Bodies/F_MED_Ballerina/Meshes/F_MED_Ballerina.uasset"));
|
||||
await _threadWorkerView.Begin(cancellationToken =>
|
||||
_applicationView.CUE4Parse.Extract(cancellationToken,
|
||||
"Hk_project/Content/Character/Cat/Mesh/SKM_Cat.uasset"));
|
||||
await _threadWorkerView.Begin(cancellationToken =>
|
||||
_applicationView.CUE4Parse.Extract(cancellationToken,
|
||||
"Hk_project/Content/Animation/CAT/Idle/CAT_SitBalledStrechingToStand_Idle.uasset"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
var scale = ImGuiController.GetDpiScale();
|
||||
var htz = Snooper.GetMaxRefreshFrequency();
|
||||
return _snooper = new Snooper(
|
||||
new GameWindowSettings { RenderFrequency = htz, UpdateFrequency = htz },
|
||||
new GameWindowSettings { UpdateFrequency = htz },
|
||||
new NativeWindowSettings
|
||||
{
|
||||
Size = new OpenTK.Mathematics.Vector2i(
|
||||
|
|
|
|||
|
|
@ -45,16 +45,17 @@ public class Grid : IDisposable
|
|||
{
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
|
||||
_vao.Bind();
|
||||
|
||||
_shader.Use();
|
||||
|
||||
_shader.SetUniform("view", viewMatrix);
|
||||
_shader.SetUniform("proj", projMatrix);
|
||||
_shader.SetUniform("uNear", near);
|
||||
_shader.SetUniform("uFar", far);
|
||||
|
||||
GL.DrawArrays(PrimitiveType.Triangles, 0, Indices.Length);
|
||||
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,8 +87,6 @@ public class Skybox : IDisposable
|
|||
GL.DepthFunc(DepthFunction.Lequal);
|
||||
|
||||
_vao.Bind();
|
||||
|
||||
_cubeMap.Bind(TextureUnit.Texture0);
|
||||
_shader.Use();
|
||||
|
||||
viewMatrix.M41 = 0;
|
||||
|
|
@ -97,6 +95,7 @@ public class Skybox : IDisposable
|
|||
_shader.SetUniform("uView", viewMatrix);
|
||||
_shader.SetUniform("uProjection", projMatrix);
|
||||
|
||||
_cubeMap.Bind(TextureUnit.Texture0);
|
||||
_shader.SetUniform("cubemap", 0);
|
||||
|
||||
GL.DrawArrays(PrimitiveType.Triangles, 0, 36);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ using FModel.Views.Snooper.Buffers;
|
|||
using FModel.Views.Snooper.Lights;
|
||||
using FModel.Views.Snooper.Models;
|
||||
using FModel.Views.Snooper.Shading;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
|
||||
namespace FModel.Views.Snooper;
|
||||
|
||||
|
|
@ -215,7 +216,7 @@ public class Renderer : IDisposable
|
|||
Options.SetupModelsAndLights();
|
||||
}
|
||||
|
||||
public void Render(float deltaSeconds)
|
||||
public void Render()
|
||||
{
|
||||
var viewMatrix = CameraOp.GetViewMatrix();
|
||||
var projMatrix = CameraOp.GetProjectionMatrix();
|
||||
|
|
@ -227,23 +228,9 @@ public class Renderer : IDisposable
|
|||
for (int i = 0; i < 5; i++)
|
||||
_shader.SetUniform($"bVertexColors[{i}]", i == (int) Color);
|
||||
|
||||
// update animations
|
||||
if (Options.Animations.Count > 0) Options.Tracker.Update(deltaSeconds);
|
||||
foreach (var animation in Options.Animations)
|
||||
{
|
||||
animation.TimeCalculation(Options.Tracker.ElapsedTime);
|
||||
foreach (var guid in animation.AttachedModels.Where(guid => Options.Models[guid].HasSkeleton))
|
||||
{
|
||||
Options.Models[guid].Skeleton.UpdateAnimationMatrices(
|
||||
animation.CurrentSequence, animation.FrameInSequence,
|
||||
animation.NextFrameInSequence, animation.LerpAmount);
|
||||
}
|
||||
}
|
||||
|
||||
// render model pass
|
||||
foreach (var model in Options.Models.Values)
|
||||
{
|
||||
model.UpdateMatrices(Options);
|
||||
if (!model.Show) continue;
|
||||
model.Render(_shader);
|
||||
}
|
||||
|
|
@ -272,6 +259,45 @@ public class Renderer : IDisposable
|
|||
Picking.Render(viewMatrix, projMatrix, Options.Models);
|
||||
}
|
||||
|
||||
public void Update(Snooper wnd, float deltaSeconds)
|
||||
{
|
||||
if (Options.Animations.Count > 0) Options.Tracker.Update(deltaSeconds);
|
||||
foreach (var animation in Options.Animations)
|
||||
{
|
||||
animation.TimeCalculation(Options.Tracker.ElapsedTime);
|
||||
foreach (var guid in animation.AttachedModels.Where(guid => Options.Models[guid].HasSkeleton))
|
||||
{
|
||||
Options.Models[guid].Skeleton.UpdateAnimationMatrices(
|
||||
animation.CurrentSequence, animation.FrameInSequence,
|
||||
animation.NextFrameInSequence, animation.LerpAmount);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var model in Options.Models.Values)
|
||||
{
|
||||
model.UpdateMatrices(Options);
|
||||
}
|
||||
|
||||
CameraOp.Modify(wnd.KeyboardState, deltaSeconds);
|
||||
|
||||
if (wnd.KeyboardState.IsKeyPressed(Keys.Z) &&
|
||||
Options.TryGetModel(out var selectedModel) &&
|
||||
selectedModel.HasSkeleton)
|
||||
{
|
||||
Options.RemoveAnimations();
|
||||
Options.AnimateMesh(true);
|
||||
wnd.WindowShouldClose(true, false);
|
||||
}
|
||||
if (wnd.KeyboardState.IsKeyPressed(Keys.Space))
|
||||
Options.Tracker.IsPaused = !Options.Tracker.IsPaused;
|
||||
if (wnd.KeyboardState.IsKeyPressed(Keys.Delete))
|
||||
Options.RemoveModel(Options.SelectedModel);
|
||||
if (wnd.KeyboardState.IsKeyPressed(Keys.H))
|
||||
wnd.WindowShouldClose(true, false);
|
||||
if (wnd.KeyboardState.IsKeyPressed(Keys.Escape))
|
||||
wnd.WindowShouldClose(true, true);
|
||||
}
|
||||
|
||||
private void LoadStaticMesh(UStaticMesh original)
|
||||
{
|
||||
var guid = original.LightingGuid;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class SnimGui
|
|||
public void Render(Snooper s)
|
||||
{
|
||||
Controller.SemiBold();
|
||||
DrawDockSpace(s.Size);
|
||||
DrawDockSpace(s.ClientSize);
|
||||
|
||||
SectionWindow("Material Inspector", s.Renderer, DrawMaterialInspector, false);
|
||||
AnimationWindow("Timeline", s.Renderer, (icons, tracker, animations) =>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System.Threading;
|
|||
using System.Windows.Forms;
|
||||
using CUE4Parse.UE4.Assets.Exports;
|
||||
using FModel.Views.Snooper.Buffers;
|
||||
using ImGuiNET;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Common.Input;
|
||||
|
|
@ -14,7 +13,6 @@ using OpenTK.Windowing.GraphicsLibraryFramework;
|
|||
using SixLabors.ImageSharp.Advanced;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using Application = System.Windows.Application;
|
||||
using Keys = OpenTK.Windowing.GraphicsLibraryFramework.Keys;
|
||||
|
||||
namespace FModel.Views.Snooper;
|
||||
|
||||
|
|
@ -112,33 +110,41 @@ public class Snooper : GameWindow
|
|||
_init = true;
|
||||
}
|
||||
|
||||
private void ClearWhatHasBeenDrawn()
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
}
|
||||
|
||||
protected override void OnRenderFrame(FrameEventArgs args)
|
||||
{
|
||||
base.OnRenderFrame(args);
|
||||
if (!IsVisible)
|
||||
return;
|
||||
|
||||
var delta = (float) args.Time;
|
||||
|
||||
ClearWhatHasBeenDrawn(); // clear window background
|
||||
_gui.Controller.Update(this, delta);
|
||||
_gui.Render(this);
|
||||
|
||||
Framebuffer.Bind(); // switch to viewport background
|
||||
ClearWhatHasBeenDrawn(); // clear viewport background
|
||||
|
||||
Renderer.Render(delta);
|
||||
Renderer.Render(); // render everything
|
||||
|
||||
Framebuffer.BindMsaa();
|
||||
Framebuffer.Bind(0); // switch to window background
|
||||
|
||||
_gui.Render(this); // render UI
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
private void ClearWhatHasBeenDrawn()
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
base.OnUpdateFrame(e);
|
||||
if (!IsVisible)
|
||||
return;
|
||||
|
||||
var delta = (float) e.Time;
|
||||
|
||||
_gui.Controller.Update(this, delta);
|
||||
Renderer.Update(this, delta);
|
||||
}
|
||||
|
||||
protected override void OnTextInput(TextInputEventArgs e)
|
||||
|
|
@ -150,33 +156,6 @@ public class Snooper : GameWindow
|
|||
_gui.Controller.PressChar((char) e.Unicode);
|
||||
}
|
||||
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnUpdateFrame(e);
|
||||
if (!IsVisible || ImGui.GetIO().WantTextInput)
|
||||
return;
|
||||
|
||||
var delta = (float) e.Time;
|
||||
Renderer.CameraOp.Modify(KeyboardState, delta);
|
||||
|
||||
if (KeyboardState.IsKeyPressed(Keys.Z) &&
|
||||
Renderer.Options.TryGetModel(out var selectedModel) &&
|
||||
selectedModel.HasSkeleton)
|
||||
{
|
||||
Renderer.Options.RemoveAnimations();
|
||||
Renderer.Options.AnimateMesh(true);
|
||||
WindowShouldClose(true, false);
|
||||
}
|
||||
if (KeyboardState.IsKeyPressed(Keys.Space))
|
||||
Renderer.Options.Tracker.IsPaused = !Renderer.Options.Tracker.IsPaused;
|
||||
if (KeyboardState.IsKeyPressed(Keys.Delete))
|
||||
Renderer.Options.RemoveModel(Renderer.Options.SelectedModel);
|
||||
if (KeyboardState.IsKeyPressed(Keys.H))
|
||||
WindowShouldClose(true, false);
|
||||
if (KeyboardState.IsKeyPressed(Keys.Escape))
|
||||
WindowShouldClose(true, true);
|
||||
}
|
||||
|
||||
protected override void OnResize(ResizeEventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user