diff --git a/SpineViewer/Spine/Implementations/SpineObject/SpineObject21.cs b/SpineViewer/Spine/Implementations/SpineObject/SpineObject21.cs index e0124c0..1ae8a7e 100644 --- a/SpineViewer/Spine/Implementations/SpineObject/SpineObject21.cs +++ b/SpineViewer/Spine/Implementations/SpineObject/SpineObject21.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using SpineRuntime21; +using SpineViewer.Extensions; using SpineViewer.Utils; namespace SpineViewer.Spine.Implementations.SpineObject @@ -237,15 +238,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject tmpSkeleton.Update(0); tmpSkeleton.UpdateWorldTransform(); - // 切成 100 帧获取边界最大值 + // 按 10 帧每秒计算边框 var bounds = getCurrentBounds(); - for (float tick = 0, delta = maxDuration / 100; tick < maxDuration; tick += delta) + float[] _ = []; + for (float tick = 0, delta = 0.1f; tick < maxDuration; tick += delta) { tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h); - if (x < bounds.X) bounds.X = x; - if (y < bounds.Y) bounds.Y = y; - if (w > bounds.Width) bounds.Width = w; - if (h > bounds.Height) bounds.Height = h; + bounds = bounds.Union(new(x, y, w, h)); tmpAnimationState.Update(delta); tmpAnimationState.Apply(tmpSkeleton); tmpSkeleton.Update(delta); diff --git a/SpineViewer/Spine/Implementations/SpineObject/SpineObject36.cs b/SpineViewer/Spine/Implementations/SpineObject/SpineObject36.cs index d900252..a2f7f72 100644 --- a/SpineViewer/Spine/Implementations/SpineObject/SpineObject36.cs +++ b/SpineViewer/Spine/Implementations/SpineObject/SpineObject36.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using SpineRuntime36; +using SpineViewer.Extensions; using SpineViewer.Utils; namespace SpineViewer.Spine.Implementations.SpineObject @@ -237,16 +238,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject tmpSkeleton.Update(0); tmpSkeleton.UpdateWorldTransform(); - // 切成 100 帧获取边界最大值 + // 按 10 帧每秒计算边框 var bounds = getCurrentBounds(); float[] _ = []; - for (float tick = 0, delta = maxDuration / 100; tick < maxDuration; tick += delta) + for (float tick = 0, delta = 0.1f; tick < maxDuration; tick += delta) { tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _); - if (x < bounds.X) bounds.X = x; - if (y < bounds.Y) bounds.Y = y; - if (w > bounds.Width) bounds.Width = w; - if (h > bounds.Height) bounds.Height = h; + bounds = bounds.Union(new(x, y, w, h)); tmpAnimationState.Update(delta); tmpAnimationState.Apply(tmpSkeleton); tmpSkeleton.Update(delta); diff --git a/SpineViewer/Spine/Implementations/SpineObject/SpineObject37.cs b/SpineViewer/Spine/Implementations/SpineObject/SpineObject37.cs index 9c75f93..1c4d8b9 100644 --- a/SpineViewer/Spine/Implementations/SpineObject/SpineObject37.cs +++ b/SpineViewer/Spine/Implementations/SpineObject/SpineObject37.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using SpineRuntime37; +using SpineViewer.Extensions; using SpineViewer.Utils; namespace SpineViewer.Spine.Implementations.SpineObject @@ -208,16 +209,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject tmpSkeleton.Update(0); tmpSkeleton.UpdateWorldTransform(); - // 切成 100 帧获取边界最大值 + // 按 10 帧每秒计算边框 var bounds = getCurrentBounds(); float[] _ = []; - for (float tick = 0, delta = maxDuration / 100; tick < maxDuration; tick += delta) + for (float tick = 0, delta = 0.1f; tick < maxDuration; tick += delta) { tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _); - if (x < bounds.X) bounds.X = x; - if (y < bounds.Y) bounds.Y = y; - if (w > bounds.Width) bounds.Width = w; - if (h > bounds.Height) bounds.Height = h; + bounds = bounds.Union(new(x, y, w, h)); tmpAnimationState.Update(delta); tmpAnimationState.Apply(tmpSkeleton); tmpSkeleton.Update(delta); diff --git a/SpineViewer/Spine/Implementations/SpineObject/SpineObject38.cs b/SpineViewer/Spine/Implementations/SpineObject/SpineObject38.cs index a1ff841..5c3b2ed 100644 --- a/SpineViewer/Spine/Implementations/SpineObject/SpineObject38.cs +++ b/SpineViewer/Spine/Implementations/SpineObject/SpineObject38.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Xml.Linq; using SpineRuntime38; using SpineRuntime38.Attachments; +using SpineViewer.Extensions; using SpineViewer.Utils; namespace SpineViewer.Spine.Implementations.SpineObject @@ -209,16 +210,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject tmpSkeleton.Update(0); tmpSkeleton.UpdateWorldTransform(); - // 切成 100 帧获取边界最大值 + // 按 10 帧每秒计算边框 var bounds = getCurrentBounds(); float[] _ = []; - for (float tick = 0, delta = maxDuration / 100; tick < maxDuration; tick += delta) + for (float tick = 0, delta = 0.1f; tick < maxDuration; tick += delta) { tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _); - if (x < bounds.X) bounds.X = x; - if (y < bounds.Y) bounds.Y = y; - if (w > bounds.Width) bounds.Width = w; - if (h > bounds.Height) bounds.Height = h; + bounds = bounds.Union(new(x, y, w, h)); tmpAnimationState.Update(delta); tmpAnimationState.Apply(tmpSkeleton); tmpSkeleton.Update(delta); diff --git a/SpineViewer/Spine/Implementations/SpineObject/SpineObject40.cs b/SpineViewer/Spine/Implementations/SpineObject/SpineObject40.cs index df0c483..e2fb80e 100644 --- a/SpineViewer/Spine/Implementations/SpineObject/SpineObject40.cs +++ b/SpineViewer/Spine/Implementations/SpineObject/SpineObject40.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using SpineRuntime40; +using SpineViewer.Extensions; using SpineViewer.Utils; namespace SpineViewer.Spine.Implementations.SpineObject @@ -204,16 +205,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject tmpSkeleton.Update(0); tmpSkeleton.UpdateWorldTransform(); - // 切成 100 帧获取边界最大值 + // 按 10 帧每秒计算边框 var bounds = getCurrentBounds(); float[] _ = []; - for (float tick = 0, delta = maxDuration / 100; tick < maxDuration; tick += delta) + for (float tick = 0, delta = 0.1f; tick < maxDuration; tick += delta) { tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _); - if (x < bounds.X) bounds.X = x; - if (y < bounds.Y) bounds.Y = y; - if (w > bounds.Width) bounds.Width = w; - if (h > bounds.Height) bounds.Height = h; + bounds = bounds.Union(new(x, y, w, h)); tmpAnimationState.Update(delta); tmpAnimationState.Apply(tmpSkeleton); tmpSkeleton.Update(delta); diff --git a/SpineViewer/Spine/Implementations/SpineObject/SpineObject41.cs b/SpineViewer/Spine/Implementations/SpineObject/SpineObject41.cs index e13dada..20a6339 100644 --- a/SpineViewer/Spine/Implementations/SpineObject/SpineObject41.cs +++ b/SpineViewer/Spine/Implementations/SpineObject/SpineObject41.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using SpineRuntime41; +using SpineViewer.Extensions; using SpineViewer.Utils; namespace SpineViewer.Spine.Implementations.SpineObject @@ -204,19 +205,15 @@ namespace SpineViewer.Spine.Implementations.SpineObject //tmpSkeleton.Update(0); tmpSkeleton.UpdateWorldTransform(); - // 切成 100 帧获取边界最大值 + // 按 10 帧每秒计算边框 var bounds = getCurrentBounds(); float[] _ = []; - for (float tick = 0, delta = maxDuration / 100; tick < maxDuration; tick += delta) + for (float tick = 0, delta = 0.1f; tick < maxDuration; tick += delta) { tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _); - if (x < bounds.X) bounds.X = x; - if (y < bounds.Y) bounds.Y = y; - if (w > bounds.Width) bounds.Width = w; - if (h > bounds.Height) bounds.Height = h; + bounds = bounds.Union(new(x, y, w, h)); tmpAnimationState.Update(delta); tmpAnimationState.Apply(tmpSkeleton); - //tmpSkeleton.Update(delta); tmpSkeleton.UpdateWorldTransform(); } diff --git a/SpineViewer/Spine/Implementations/SpineObject/Spineobject42.cs b/SpineViewer/Spine/Implementations/SpineObject/Spineobject42.cs index 063c748..f76d50b 100644 --- a/SpineViewer/Spine/Implementations/SpineObject/Spineobject42.cs +++ b/SpineViewer/Spine/Implementations/SpineObject/Spineobject42.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using SpineRuntime42; +using SpineViewer.Extensions; using SpineViewer.Utils; namespace SpineViewer.Spine.Implementations.SpineObject @@ -204,16 +205,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject tmpSkeleton.Update(0); tmpSkeleton.UpdateWorldTransform(Skeleton.Physics.Update); - // 切成 100 帧获取边界最大值 + // 按 10 帧每秒计算边框 var bounds = getCurrentBounds(); float[] _ = []; - for (float tick = 0, delta = maxDuration / 100; tick < maxDuration; tick += delta) + for (float tick = 0, delta = 0.1f; tick < maxDuration; tick += delta) { tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _); - if (x < bounds.X) bounds.X = x; - if (y < bounds.Y) bounds.Y = y; - if (w > bounds.Width) bounds.Width = w; - if (h > bounds.Height) bounds.Height = h; + bounds = bounds.Union(new(x, y, w, h)); tmpAnimationState.Update(delta); tmpAnimationState.Apply(tmpSkeleton); tmpSkeleton.Update(delta);