From 0ed26e1a7d4e306888628f028580370db3df8bc1 Mon Sep 17 00:00:00 2001 From: 4sval Date: Fri, 17 Feb 2023 16:23:15 +0100 Subject: [PATCH] fixed non virtual sockets being deleted on anim change --- CUE4Parse | 2 +- FModel/ViewModels/ApplicationViewModel.cs | 4 ++-- FModel/Views/Snooper/Animations/Skeleton.cs | 8 +++++++- FModel/Views/Snooper/Animations/TimeTracker.cs | 2 +- FModel/Views/Snooper/Options.cs | 14 +++++++++----- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index c24bb1a0..2623c0ba 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit c24bb1a031f8d463a8401e3952c9a11344e208a8 +Subproject commit 2623c0baa171d05f6f6d3922a1a6ea3ae675fb25 diff --git a/FModel/ViewModels/ApplicationViewModel.cs b/FModel/ViewModels/ApplicationViewModel.cs index 5cbe2b20..a9f58e26 100644 --- a/FModel/ViewModels/ApplicationViewModel.cs +++ b/FModel/ViewModels/ApplicationViewModel.cs @@ -186,10 +186,10 @@ public class ApplicationViewModel : ViewModel } } - public async Task InitImGuiSettings() + public async Task InitImGuiSettings(bool forceDownload) { var imgui = Path.Combine(/*UserSettings.Default.OutputDirectory, ".data", */"imgui.ini"); - if (File.Exists(imgui)) return; + if (!forceDownload || File.Exists(imgui)) return; await ApplicationService.ApiEndpointView.DownloadFileAsync("https://cdn.fmodel.app/d/configurations/imgui.ini", imgui); if (new FileInfo(imgui).Length == 0) diff --git a/FModel/Views/Snooper/Animations/Skeleton.cs b/FModel/Views/Snooper/Animations/Skeleton.cs index 5489ca04..49b9afd3 100644 --- a/FModel/Views/Snooper/Animations/Skeleton.cs +++ b/FModel/Views/Snooper/Animations/Skeleton.cs @@ -92,9 +92,15 @@ public class Skeleton : IDisposable { for (int frame = 0; frame < _animatedBonesTransform[s][boneIndices.BoneIndex].Length; frame++) { + // TODO: append the delta transform + // ex: if bone 4, with parent 3, has its first found parent transform at 2, + // we need to append the transform from 4 to 3 so that bone 4 won't be placed where bone 3 should be _animatedBonesTransform[s][boneIndices.BoneIndex][frame] = new Transform { - Relation = originalTransform.LocalMatrix * _animatedBonesTransform[s][boneIndices.ParentTrackIndex][frame].Matrix + Relation = _animatedBonesTransform[s][boneIndices.ParentTrackIndex][frame].Matrix, + Rotation = originalTransform.Rotation, + Position = originalTransform.Position, + Scale = originalTransform.Scale }; } } diff --git a/FModel/Views/Snooper/Animations/TimeTracker.cs b/FModel/Views/Snooper/Animations/TimeTracker.cs index c0784ce2..e540bc2c 100644 --- a/FModel/Views/Snooper/Animations/TimeTracker.cs +++ b/FModel/Views/Snooper/Animations/TimeTracker.cs @@ -140,7 +140,7 @@ public class TimeTracker : IDisposable for (int i = 0; i < animations.Count; i++) { - var y = timelineP0.Y + _timeBarHeight + timeStep.Y * (i % 2); + var y = timelineP0.Y + _timeBarHeight + timeStep.Y * i; animations[i].ImGuiAnimation(drawList, timelineP0, treeP0, treeP1, timeStep, timeRatio, y, _thickness); DrawSeparator(drawList, timelineP0, y + timeStep.Y, animations[i].EndTime * timeRatio.X, ETrackerType.End); } diff --git a/FModel/Views/Snooper/Options.cs b/FModel/Views/Snooper/Options.cs index 3b7fa599..844e3cc2 100644 --- a/FModel/Views/Snooper/Options.cs +++ b/FModel/Views/Snooper/Options.cs @@ -99,12 +99,12 @@ public class Options { if (!TryGetModel(guid, out var model)) return; - DetachAndRemoveModels(model); + DetachAndRemoveModels(model, true); model.Dispose(); Models.Remove(guid); } - private void DetachAndRemoveModels(Model model) + private void DetachAndRemoveModels(Model model, bool detach) { foreach (var socket in model.Sockets.ToList()) { @@ -112,8 +112,12 @@ public class Options { if (!TryGetModel(info.Guid, out var attachedModel)) continue; - attachedModel.SafeDetachModel(model); - RemoveModel(info.Guid); + if (attachedModel.IsAnimatedProp) + { + attachedModel.SafeDetachModel(model); + RemoveModel(info.Guid); + } + else if (detach) attachedModel.SafeDetachModel(model); } if (socket.IsVirtual) @@ -139,7 +143,7 @@ public class Options if (!TryGetModel(guid, out var animatedModel)) continue; animatedModel.Skeleton.ResetAnimatedData(true); - DetachAndRemoveModels(animatedModel); + DetachAndRemoveModels(animatedModel, false); } animation.Dispose(); }