修复包围盒并集错误

This commit is contained in:
ww-rm
2025-04-17 20:29:20 +08:00
parent b0b1c85047
commit 775268c01a
7 changed files with 29 additions and 43 deletions

View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime21; using SpineRuntime21;
using SpineViewer.Extensions;
using SpineViewer.Utils; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.SpineObject namespace SpineViewer.Spine.Implementations.SpineObject
@@ -237,15 +238,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject
tmpSkeleton.Update(0); tmpSkeleton.Update(0);
tmpSkeleton.UpdateWorldTransform(); tmpSkeleton.UpdateWorldTransform();
// 切成 100获取边界最大值 // 10 帧每秒计算边框
var bounds = getCurrentBounds(); 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); tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h);
if (x < bounds.X) bounds.X = x; bounds = bounds.Union(new(x, y, w, h));
if (y < bounds.Y) bounds.Y = y;
if (w > bounds.Width) bounds.Width = w;
if (h > bounds.Height) bounds.Height = h;
tmpAnimationState.Update(delta); tmpAnimationState.Update(delta);
tmpAnimationState.Apply(tmpSkeleton); tmpAnimationState.Apply(tmpSkeleton);
tmpSkeleton.Update(delta); tmpSkeleton.Update(delta);

View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime36; using SpineRuntime36;
using SpineViewer.Extensions;
using SpineViewer.Utils; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.SpineObject namespace SpineViewer.Spine.Implementations.SpineObject
@@ -237,16 +238,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject
tmpSkeleton.Update(0); tmpSkeleton.Update(0);
tmpSkeleton.UpdateWorldTransform(); tmpSkeleton.UpdateWorldTransform();
// 切成 100获取边界最大值 // 10 帧每秒计算边框
var bounds = getCurrentBounds(); var bounds = getCurrentBounds();
float[] _ = []; 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 _); tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
if (x < bounds.X) bounds.X = x; bounds = bounds.Union(new(x, y, w, h));
if (y < bounds.Y) bounds.Y = y;
if (w > bounds.Width) bounds.Width = w;
if (h > bounds.Height) bounds.Height = h;
tmpAnimationState.Update(delta); tmpAnimationState.Update(delta);
tmpAnimationState.Apply(tmpSkeleton); tmpAnimationState.Apply(tmpSkeleton);
tmpSkeleton.Update(delta); tmpSkeleton.Update(delta);

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime37; using SpineRuntime37;
using SpineViewer.Extensions;
using SpineViewer.Utils; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.SpineObject namespace SpineViewer.Spine.Implementations.SpineObject
@@ -208,16 +209,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject
tmpSkeleton.Update(0); tmpSkeleton.Update(0);
tmpSkeleton.UpdateWorldTransform(); tmpSkeleton.UpdateWorldTransform();
// 切成 100获取边界最大值 // 10 帧每秒计算边框
var bounds = getCurrentBounds(); var bounds = getCurrentBounds();
float[] _ = []; 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 _); tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
if (x < bounds.X) bounds.X = x; bounds = bounds.Union(new(x, y, w, h));
if (y < bounds.Y) bounds.Y = y;
if (w > bounds.Width) bounds.Width = w;
if (h > bounds.Height) bounds.Height = h;
tmpAnimationState.Update(delta); tmpAnimationState.Update(delta);
tmpAnimationState.Apply(tmpSkeleton); tmpAnimationState.Apply(tmpSkeleton);
tmpSkeleton.Update(delta); tmpSkeleton.Update(delta);

View File

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
using SpineRuntime38; using SpineRuntime38;
using SpineRuntime38.Attachments; using SpineRuntime38.Attachments;
using SpineViewer.Extensions;
using SpineViewer.Utils; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.SpineObject namespace SpineViewer.Spine.Implementations.SpineObject
@@ -209,16 +210,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject
tmpSkeleton.Update(0); tmpSkeleton.Update(0);
tmpSkeleton.UpdateWorldTransform(); tmpSkeleton.UpdateWorldTransform();
// 切成 100获取边界最大值 // 10 帧每秒计算边框
var bounds = getCurrentBounds(); var bounds = getCurrentBounds();
float[] _ = []; 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 _); tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
if (x < bounds.X) bounds.X = x; bounds = bounds.Union(new(x, y, w, h));
if (y < bounds.Y) bounds.Y = y;
if (w > bounds.Width) bounds.Width = w;
if (h > bounds.Height) bounds.Height = h;
tmpAnimationState.Update(delta); tmpAnimationState.Update(delta);
tmpAnimationState.Apply(tmpSkeleton); tmpAnimationState.Apply(tmpSkeleton);
tmpSkeleton.Update(delta); tmpSkeleton.Update(delta);

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime40; using SpineRuntime40;
using SpineViewer.Extensions;
using SpineViewer.Utils; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.SpineObject namespace SpineViewer.Spine.Implementations.SpineObject
@@ -204,16 +205,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject
tmpSkeleton.Update(0); tmpSkeleton.Update(0);
tmpSkeleton.UpdateWorldTransform(); tmpSkeleton.UpdateWorldTransform();
// 切成 100获取边界最大值 // 10 帧每秒计算边框
var bounds = getCurrentBounds(); var bounds = getCurrentBounds();
float[] _ = []; 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 _); tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
if (x < bounds.X) bounds.X = x; bounds = bounds.Union(new(x, y, w, h));
if (y < bounds.Y) bounds.Y = y;
if (w > bounds.Width) bounds.Width = w;
if (h > bounds.Height) bounds.Height = h;
tmpAnimationState.Update(delta); tmpAnimationState.Update(delta);
tmpAnimationState.Apply(tmpSkeleton); tmpAnimationState.Apply(tmpSkeleton);
tmpSkeleton.Update(delta); tmpSkeleton.Update(delta);

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime41; using SpineRuntime41;
using SpineViewer.Extensions;
using SpineViewer.Utils; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.SpineObject namespace SpineViewer.Spine.Implementations.SpineObject
@@ -204,19 +205,15 @@ namespace SpineViewer.Spine.Implementations.SpineObject
//tmpSkeleton.Update(0); //tmpSkeleton.Update(0);
tmpSkeleton.UpdateWorldTransform(); tmpSkeleton.UpdateWorldTransform();
// 切成 100获取边界最大值 // 10 帧每秒计算边框
var bounds = getCurrentBounds(); var bounds = getCurrentBounds();
float[] _ = []; 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 _); tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
if (x < bounds.X) bounds.X = x; bounds = bounds.Union(new(x, y, w, h));
if (y < bounds.Y) bounds.Y = y;
if (w > bounds.Width) bounds.Width = w;
if (h > bounds.Height) bounds.Height = h;
tmpAnimationState.Update(delta); tmpAnimationState.Update(delta);
tmpAnimationState.Apply(tmpSkeleton); tmpAnimationState.Apply(tmpSkeleton);
//tmpSkeleton.Update(delta);
tmpSkeleton.UpdateWorldTransform(); tmpSkeleton.UpdateWorldTransform();
} }

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SpineRuntime42; using SpineRuntime42;
using SpineViewer.Extensions;
using SpineViewer.Utils; using SpineViewer.Utils;
namespace SpineViewer.Spine.Implementations.SpineObject namespace SpineViewer.Spine.Implementations.SpineObject
@@ -204,16 +205,13 @@ namespace SpineViewer.Spine.Implementations.SpineObject
tmpSkeleton.Update(0); tmpSkeleton.Update(0);
tmpSkeleton.UpdateWorldTransform(Skeleton.Physics.Update); tmpSkeleton.UpdateWorldTransform(Skeleton.Physics.Update);
// 切成 100获取边界最大值 // 10 帧每秒计算边框
var bounds = getCurrentBounds(); var bounds = getCurrentBounds();
float[] _ = []; 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 _); tmpSkeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
if (x < bounds.X) bounds.X = x; bounds = bounds.Union(new(x, y, w, h));
if (y < bounds.Y) bounds.Y = y;
if (w > bounds.Width) bounds.Width = w;
if (h > bounds.Height) bounds.Height = h;
tmpAnimationState.Update(delta); tmpAnimationState.Update(delta);
tmpAnimationState.Apply(tmpSkeleton); tmpAnimationState.Apply(tmpSkeleton);
tmpSkeleton.Update(delta); tmpSkeleton.Update(delta);