diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj
index 6182ae44..5641d311 100644
--- a/FModel/FModel.csproj
+++ b/FModel/FModel.csproj
@@ -145,7 +145,7 @@
-
+
diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs
index 440e3657..17c2782a 100644
--- a/FModel/ViewModels/CUE4ParseViewModel.cs
+++ b/FModel/ViewModels/CUE4ParseViewModel.cs
@@ -88,19 +88,24 @@ public class CUE4ParseViewModel : ViewModel
{
get
{
+ if (_snooper != null) return _snooper;
+
return Application.Current.Dispatcher.Invoke(delegate
{
- return _snooper ??= new Snooper(
- new GameWindowSettings { RenderFrequency = Snooper.GetMaxRefreshFrequency() },
+ var scale = ImGuiController.GetDpiScale();
+ var htz = Snooper.GetMaxRefreshFrequency();
+ return _snooper = new Snooper(
+ new GameWindowSettings { RenderFrequency = htz, UpdateFrequency = htz },
new NativeWindowSettings
{
Size = new OpenTK.Mathematics.Vector2i(
- Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenWidth * .75 * ImGuiController.GetDpiScale()),
- Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenHeight * .85 * ImGuiController.GetDpiScale())),
+ Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenWidth * .75 * scale),
+ Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenHeight * .85 * scale)),
NumberOfSamples = Constants.SAMPLES_COUNT,
WindowBorder = WindowBorder.Resizable,
Flags = ContextFlags.ForwardCompatible,
Profile = ContextProfile.Core,
+ Vsync = VSyncMode.Adaptive,
APIVersion = new Version(4, 6),
StartVisible = false,
StartFocused = false,
diff --git a/FModel/Views/Snooper/Animations/Animation.cs b/FModel/Views/Snooper/Animations/Animation.cs
index b297b750..fec58844 100644
--- a/FModel/Views/Snooper/Animations/Animation.cs
+++ b/FModel/Views/Snooper/Animations/Animation.cs
@@ -142,10 +142,6 @@ public class Animation : IDisposable
}
}
ImGui.EndMenu();
- }
- if (ImGui.MenuItem("Additive", false))
- {
-
}
if (ImGui.MenuItem("Save"))
{
diff --git a/FModel/Views/Snooper/Animations/BoneIndice.cs b/FModel/Views/Snooper/Animations/BoneIndice.cs
index 25c7331f..e206ac4d 100644
--- a/FModel/Views/Snooper/Animations/BoneIndice.cs
+++ b/FModel/Views/Snooper/Animations/BoneIndice.cs
@@ -7,8 +7,13 @@ public class BoneIndice
public string LoweredParentBoneName;
public bool IsRoot => BoneIndex == 0 && ParentBoneIndex == -1 && string.IsNullOrEmpty(LoweredParentBoneName);
- public int TrackIndex = -1;
- public int ParentTrackIndex = -1; // bone index of the first tracked parent bone
- public bool HasTrack => TrackIndex > -1;
- public bool HasParentTrack => ParentTrackIndex > -1;
+ public int TrackedBoneIndex = -1;
+ public int TrackedParentBoneIndex = -1; // bone index of the first tracked parent bone
+ public bool IsTracked => TrackedBoneIndex > -1;
+ public bool IsParentTracked => TrackedParentBoneIndex > -1;
+
+ public bool IsNative => BoneIndex == TrackedBoneIndex;
+ public bool IsParentNative => ParentBoneIndex == TrackedParentBoneIndex; // always true?
+
+ public override string ToString() => $"Mesh Ref '{BoneIndex}' is Skel Ref '{TrackedBoneIndex}' ({IsNative}, {IsParentNative})";
}
diff --git a/FModel/Views/Snooper/Animations/Skeleton.cs b/FModel/Views/Snooper/Animations/Skeleton.cs
index 78ae1334..9abc45bf 100644
--- a/FModel/Views/Snooper/Animations/Skeleton.cs
+++ b/FModel/Views/Snooper/Animations/Skeleton.cs
@@ -88,36 +88,36 @@ public class Skeleton : IDisposable
var originalTransform = BonesTransformByIndex[boneIndices.BoneIndex];
_animatedBonesTransform[s][boneIndices.BoneIndex] = new Transform[sequence.NumFrames];
- if (!boneIndices.HasTrack)
+ var trackedBoneIndex = boneIndices.TrackedBoneIndex;
+ if (sequence.OriginalSequence.FindTrackForBoneIndex(trackedBoneIndex) < 0)
{
for (int frame = 0; frame < _animatedBonesTransform[s][boneIndices.BoneIndex].Length; frame++)
{
_animatedBonesTransform[s][boneIndices.BoneIndex][frame] = new Transform
{
- Relation = boneIndices.HasParentTrack ?
- originalTransform.LocalMatrix * _animatedBonesTransform[s][boneIndices.ParentTrackIndex][frame].Matrix :
+ Relation = boneIndices.IsParentTracked ?
+ originalTransform.LocalMatrix * _animatedBonesTransform[s][boneIndices.TrackedParentBoneIndex][frame].Matrix :
originalTransform.Relation
};
}
}
else
{
- var trackIndex = boneIndices.TrackIndex;
for (int frame = 0; frame < _animatedBonesTransform[s][boneIndices.BoneIndex].Length; frame++)
{
var boneOrientation = originalTransform.Rotation;
var bonePosition = originalTransform.Position;
var boneScale = originalTransform.Scale;
- sequence.Tracks[trackIndex].GetBonePosition(frame, sequence.NumFrames, false, ref bonePosition, ref boneOrientation);
- if (frame < sequence.Tracks[trackIndex].KeyScale.Length)
- boneScale = sequence.Tracks[trackIndex].KeyScale[frame];
+ sequence.Tracks[trackedBoneIndex].GetBonePosition(frame, sequence.NumFrames, false, ref bonePosition, ref boneOrientation);
+ if (frame < sequence.Tracks[trackedBoneIndex].KeyScale.Length)
+ boneScale = sequence.Tracks[trackedBoneIndex].KeyScale[frame];
- switch (anim.BoneModes[trackIndex])
+ switch (anim.BoneModes[trackedBoneIndex])
{
case EBoneTranslationRetargetingMode.Skeleton when !rotationOnly:
{
- var targetTransform = sequence.RetargetBasePose?[trackIndex] ?? anim.BonePositions[trackIndex];
+ var targetTransform = sequence.RetargetBasePose?[trackedBoneIndex] ?? anim.BonePositions[trackedBoneIndex];
bonePosition = targetTransform.Translation;
break;
}
@@ -126,7 +126,7 @@ public class Skeleton : IDisposable
var sourceTranslationLength = (originalTransform.Position / Constants.SCALE_DOWN_RATIO).Size();
if (sourceTranslationLength > UnrealMath.KindaSmallNumber)
{
- var targetTranslationLength = sequence.RetargetBasePose?[trackIndex].Translation.Size() ?? anim.BonePositions[trackIndex].Translation.Size();
+ var targetTranslationLength = sequence.RetargetBasePose?[trackedBoneIndex].Translation.Size() ?? anim.BonePositions[trackedBoneIndex].Translation.Size();
bonePosition.Scale(targetTranslationLength / sourceTranslationLength);
}
break;
@@ -135,7 +135,7 @@ public class Skeleton : IDisposable
{
// can't tell if it's working or not
var sourceSkelTrans = originalTransform.Position / Constants.SCALE_DOWN_RATIO;
- var refPoseTransform = sequence.RetargetBasePose?[trackIndex] ?? anim.BonePositions[trackIndex];
+ var refPoseTransform = sequence.RetargetBasePose?[trackedBoneIndex] ?? anim.BonePositions[trackedBoneIndex];
boneOrientation = boneOrientation * FQuat.Conjugate(originalTransform.Rotation) * refPoseTransform.Rotation;
bonePosition += refPoseTransform.Translation - sourceSkelTrans;
@@ -146,7 +146,7 @@ public class Skeleton : IDisposable
case EBoneTranslationRetargetingMode.OrientAndScale when !rotationOnly:
{
var sourceSkelTrans = originalTransform.Position / Constants.SCALE_DOWN_RATIO;
- var targetSkelTrans = sequence.RetargetBasePose?[trackIndex].Translation ?? anim.BonePositions[trackIndex].Translation;
+ var targetSkelTrans = sequence.RetargetBasePose?[trackedBoneIndex].Translation ?? anim.BonePositions[trackedBoneIndex].Translation;
if (!sourceSkelTrans.Equals(targetSkelTrans))
{
@@ -167,12 +167,12 @@ public class Skeleton : IDisposable
}
// revert FixRotationKeys
- if (trackIndex > 0) boneOrientation.Conjugate();
+ if (trackedBoneIndex > 0) boneOrientation.Conjugate();
bonePosition *= Constants.SCALE_DOWN_RATIO;
_animatedBonesTransform[s][boneIndices.BoneIndex][frame] = new Transform
{
- Relation = boneIndices.HasParentTrack ? _animatedBonesTransform[s][boneIndices.ParentTrackIndex][frame].Matrix : originalTransform.Relation,
+ Relation = boneIndices.IsParentTracked ? _animatedBonesTransform[s][boneIndices.TrackedParentBoneIndex][frame].Matrix : originalTransform.Relation,
Rotation = boneOrientation,
Position = rotationOnly ? originalTransform.Position : bonePosition,
Scale = sequence.bAdditive ? FVector.OneVector : boneScale
@@ -194,7 +194,7 @@ public class Skeleton : IDisposable
if (!BonesIndicesByLoweredName.TryGetValue(info.Name.Text.ToLower(), out var boneIndices))
continue;
- boneIndices.TrackIndex = trackIndex;
+ boneIndices.TrackedBoneIndex = trackIndex;
var parentTrackIndex = info.ParentIndex;
do
@@ -202,16 +202,16 @@ public class Skeleton : IDisposable
if (parentTrackIndex < 0) break;
info = anim.TrackBonesInfo[parentTrackIndex];
if (boneIndices.LoweredParentBoneName.Equals(info.Name.Text, StringComparison.OrdinalIgnoreCase) && // same parent (name based)
- BonesIndicesByLoweredName.TryGetValue(info.Name.Text.ToLower(), out var parentBoneIndices) && parentBoneIndices.HasTrack)
- boneIndices.ParentTrackIndex = parentBoneIndices.BoneIndex;
+ BonesIndicesByLoweredName.TryGetValue(info.Name.Text.ToLower(), out var parentBoneIndices) && parentBoneIndices.IsTracked)
+ boneIndices.TrackedParentBoneIndex = parentBoneIndices.BoneIndex;
else parentTrackIndex = info.ParentIndex;
- } while (!boneIndices.HasParentTrack);
+ } while (!boneIndices.IsParentTracked);
}
// fix parent of untracked bones
foreach ((var boneName, var boneIndices) in BonesIndicesByLoweredName)
{
- if (boneIndices.IsRoot || boneIndices.HasTrack && boneIndices.HasParentTrack) // assuming root bone always has a track
+ if (boneIndices.IsRoot || boneIndices.IsTracked && boneIndices.IsParentTracked) // assuming root bone always has a track
continue;
#if DEBUG
@@ -222,9 +222,9 @@ public class Skeleton : IDisposable
do
{
var parentBoneIndices = BonesIndicesByLoweredName[loweredParentBoneName];
- if (parentBoneIndices.HasParentTrack || parentBoneIndices.IsRoot) boneIndices.ParentTrackIndex = parentBoneIndices.BoneIndex;
+ if (parentBoneIndices.IsParentTracked || parentBoneIndices.IsRoot) boneIndices.TrackedParentBoneIndex = parentBoneIndices.BoneIndex;
else loweredParentBoneName = parentBoneIndices.LoweredParentBoneName;
- } while (!boneIndices.HasParentTrack);
+ } while (!boneIndices.IsParentTracked);
}
}
@@ -232,8 +232,8 @@ public class Skeleton : IDisposable
{
foreach (var boneIndices in BonesIndicesByLoweredName.Values)
{
- boneIndices.TrackIndex = -1;
- boneIndices.ParentTrackIndex = -1;
+ boneIndices.TrackedBoneIndex = -1;
+ boneIndices.TrackedParentBoneIndex = -1;
}
if (!full) return;
diff --git a/FModel/Views/Snooper/Snooper.cs b/FModel/Views/Snooper/Snooper.cs
index 5a658d63..ea1545c9 100644
--- a/FModel/Views/Snooper/Snooper.cs
+++ b/FModel/Views/Snooper/Snooper.cs
@@ -156,7 +156,8 @@ public class Snooper : GameWindow
if (!IsVisible || ImGui.GetIO().WantTextInput)
return;
- Renderer.CameraOp.Modify(KeyboardState, (float) e.Time);
+ var delta = (float) e.Time;
+ Renderer.CameraOp.Modify(KeyboardState, delta);
if (KeyboardState.IsKeyPressed(Keys.Space))
Renderer.Options.Tracker.IsPaused = !Renderer.Options.Tracker.IsPaused;
@@ -233,7 +234,7 @@ public class Snooper : GameWindow
public static int GetMaxRefreshFrequency()
{
var rf = 60;
- DEVMODE vDevMode = new DEVMODE();
+ var vDevMode = new DEVMODE();
var i = 0;
while (EnumDisplaySettings(null, i, ref vDevMode))
{