修改GetBounds为GetCurrentBounds

This commit is contained in:
ww-rm
2025-04-15 14:58:25 +08:00
parent 09dd220abf
commit ee36f8981c
9 changed files with 26 additions and 20 deletions

View File

@@ -475,7 +475,7 @@ namespace SpineViewer.Controls
foreach (int i in SpineListView.SelectedIndices)
{
if (spines[i].IsHidden) continue;
if (!spines[i].GetBounds().Contains(src)) continue;
if (!spines[i].GetCurrentBounds().Contains(src)) continue;
hit = true;
break;
}
@@ -492,7 +492,7 @@ namespace SpineViewer.Controls
for (int i = 0; i < spines.Count; i++)
{
if (spines[i].IsHidden) continue;
if (!spines[i].GetBounds().Contains(src)) continue;
if (!spines[i].GetCurrentBounds().Contains(src)) continue;
hit = true;
@@ -514,7 +514,7 @@ namespace SpineViewer.Controls
for (int i = 0; i < spines.Count; i++)
{
if (spines[i].IsHidden) continue;
if (!spines[i].GetBounds().Contains(src)) continue;
if (!spines[i].GetCurrentBounds().Contains(src)) continue;
SpineListView.SelectedIndices.Add(i);
break;

View File

@@ -188,7 +188,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
public override float GetAnimationDuration(string name) { return skeletonData.FindAnimation(name)?.Duration ?? 0f; }
protected override RectangleF getBounds()
protected override RectangleF getCurrentBounds()
{
float[] temp = new float[8];
var drawOrderItems = skeleton.DrawOrder;
@@ -500,7 +500,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
if (debugBounds)
{
var vt = new SFML.Graphics.Vertex() { Color = BoundsColor };
var b = getBounds();
var b = getCurrentBounds();
vt.Position.X = b.Left;
vt.Position.Y = b.Top;

View File

@@ -187,7 +187,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
public override float GetAnimationDuration(string name) { return skeletonData.FindAnimation(name)?.Duration ?? 0f; }
protected override RectangleF getBounds()
protected override RectangleF getCurrentBounds()
{
float[] _ = [];
skeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
@@ -486,7 +486,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
if (debugBounds)
{
var vt = new SFML.Graphics.Vertex() { Color = BoundsColor };
var b = getBounds();
var b = getCurrentBounds();
vt.Position.X = b.Left;
vt.Position.Y = b.Top;

View File

@@ -159,7 +159,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
public override float GetAnimationDuration(string name) { return skeletonData.FindAnimation(name)?.Duration ?? 0f; }
protected override RectangleF getBounds()
protected override RectangleF getCurrentBounds()
{
float[] _ = [];
skeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
@@ -458,7 +458,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
if (debugBounds)
{
var vt = new SFML.Graphics.Vertex() { Color = BoundsColor };
var b = getBounds();
var b = getCurrentBounds();
vt.Position.X = b.Left;
vt.Position.Y = b.Top;

View File

@@ -167,7 +167,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
public override float GetAnimationDuration(string name) { return skeletonData.FindAnimation(name)?.Duration ?? 0f; }
protected override RectangleF getBounds()
protected override RectangleF getCurrentBounds()
{
float[] _ = [];
skeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
@@ -466,7 +466,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
if (debugBounds)
{
var vt = new SFML.Graphics.Vertex() { Color = BoundsColor };
var b = getBounds();
var b = getCurrentBounds();
vt.Position.X = b.Left;
vt.Position.Y = b.Top;

View File

@@ -163,7 +163,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
public override float GetAnimationDuration(string name) { return skeletonData.FindAnimation(name)?.Duration ?? 0f; }
protected override RectangleF getBounds()
protected override RectangleF getCurrentBounds()
{
float[] _ = [];
skeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
@@ -462,7 +462,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
if (debugBounds)
{
var vt = new SFML.Graphics.Vertex() { Color = BoundsColor };
var b = getBounds();
var b = getCurrentBounds();
vt.Position.X = b.Left;
vt.Position.Y = b.Top;

View File

@@ -163,7 +163,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
public override float GetAnimationDuration(string name) { return skeletonData.FindAnimation(name)?.Duration ?? 0f; }
protected override RectangleF getBounds()
protected override RectangleF getCurrentBounds()
{
float[] _ = [];
skeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
@@ -462,7 +462,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
if (debugBounds)
{
var vt = new SFML.Graphics.Vertex() { Color = BoundsColor };
var b = getBounds();
var b = getCurrentBounds();
vt.Position.X = b.Left;
vt.Position.Y = b.Top;

View File

@@ -163,7 +163,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
public override float GetAnimationDuration(string name) { return skeletonData.FindAnimation(name)?.Duration ?? 0f; }
protected override RectangleF getBounds()
protected override RectangleF getCurrentBounds()
{
float[] _ = [];
skeleton.GetBounds(out var x, out var y, out var w, out var h, ref _);
@@ -462,7 +462,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
if (debugBounds)
{
var vt = new SFML.Graphics.Vertex() { Color = BoundsColor };
var b = getBounds();
var b = getCurrentBounds();
vt.Position.X = b.Left;
vt.Position.Y = b.Top;

View File

@@ -83,7 +83,7 @@ namespace SpineViewer.Spine
// 除此之外, 似乎还和 tex 的 Dispose 有关
// 如果不对 tex 进行 Dispose, 那么不管是否 Draw 都正常不会死锁
var tex = new SFML.Graphics.RenderTexture(PREVIEW_WIDTH, PREVIEW_HEIGHT);
using var view = getBounds().GetView(PREVIEW_WIDTH, PREVIEW_HEIGHT);
using var view = getCurrentBounds().GetView(PREVIEW_WIDTH, PREVIEW_HEIGHT);
tex.SetView(view);
tex.Clear(SFML.Graphics.Color.Transparent);
tex.Draw(this);
@@ -444,8 +444,14 @@ namespace SpineViewer.Spine
/// <summary>
/// 获取当前状态包围盒
/// </summary>
public RectangleF GetBounds() { lock (_lock) return getBounds(); }
protected abstract RectangleF getBounds();
public RectangleF GetCurrentBounds() { lock (_lock) return getCurrentBounds(); }
protected abstract RectangleF getCurrentBounds();
/// <summary>
/// 获取当前参数下包围盒最大范围, 不是精确值
/// </summary>
//public RectangleF GetBounds() { }
//protected abstract RectangleF getBounds();
/// <summary>
/// 更新内部状态