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

View File

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

View File

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