From fa561fa25a421100d8402f39b793877624dd3e20 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Sat, 30 Nov 2024 16:53:25 -0500 Subject: [PATCH] Fix texture pattern offsetting due to quantization --- .../CafeLibrary/Bfres/Animations/BfresCameraAnim.cs | 12 +++++++++++- .../Editing/AnimConversion/MaterialAnimConverter.cs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugins/CafeLibrary/Bfres/Animations/BfresCameraAnim.cs b/Plugins/CafeLibrary/Bfres/Animations/BfresCameraAnim.cs index f808bb6..fe54e85 100644 --- a/Plugins/CafeLibrary/Bfres/Animations/BfresCameraAnim.cs +++ b/Plugins/CafeLibrary/Bfres/Animations/BfresCameraAnim.cs @@ -139,7 +139,17 @@ private void ReplaceAction() if (dlg.ShowDialog()) { CameraAnim.Import(dlg.FilePath, ResFile); - CameraAnim.Name = this.Name; + CameraAnim.Name = this.UINode.Header; + + //Update types if needed as can be broken by user error + foreach (var curve in CameraAnim.Curves) + { + var maxFrame = curve.Frames.Max(x => x); + if (maxFrame > 255 && curve.FrameType == AnimCurveFrameType.Byte) + curve.FrameType = AnimCurveFrameType.Decimal10x5; + if (maxFrame > ushort.MaxValue) + curve.FrameType = AnimCurveFrameType.Single; + } Reload(CameraAnim); } diff --git a/Plugins/CafeLibrary/Bfres/Editing/AnimConversion/MaterialAnimConverter.cs b/Plugins/CafeLibrary/Bfres/Editing/AnimConversion/MaterialAnimConverter.cs index 25ff1cc..b39069f 100644 --- a/Plugins/CafeLibrary/Bfres/Editing/AnimConversion/MaterialAnimConverter.cs +++ b/Plugins/CafeLibrary/Bfres/Editing/AnimConversion/MaterialAnimConverter.cs @@ -47,6 +47,9 @@ public static void ConvertAnimation(BfresMaterialAnim anim, MaterialAnim animTar samplerAnimHelper.Name = track.Name; samplerAnimHelper.Constant = (ushort)track.KeyFrames[0].Value; + ((BfresAnimationTrack)track).Offset = 0; + ((BfresAnimationTrack)track).Scale = 1f; + if (track.KeyFrames.Count > 1) samplerAnimHelper.Curve = ConvertCurve((BfresAnimationTrack)track, 0);