更改Bounds属性为GetBounds方法
This commit is contained in:
@@ -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].Bounds.Contains(src)) continue;
|
if (!spines[i].GetBounds().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].Bounds.Contains(src)) continue;
|
if (!spines[i].GetBounds().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].Bounds.Contains(src)) continue;
|
if (!spines[i].GetBounds().Contains(src)) continue;
|
||||||
|
|
||||||
SpineListView.SelectedIndices.Add(i);
|
SpineListView.SelectedIndices.Add(i);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -188,9 +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 bounds
|
protected override RectangleF getBounds()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
float[] temp = new float[8];
|
float[] temp = new float[8];
|
||||||
var drawOrderItems = skeleton.DrawOrder;
|
var drawOrderItems = skeleton.DrawOrder;
|
||||||
@@ -236,7 +234,6 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
}
|
}
|
||||||
return new RectangleF(minX, minY, maxX - minX, maxY - minY);
|
return new RectangleF(minX, minY, maxX - minX, maxY - minY);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void update(float delta)
|
protected override void update(float delta)
|
||||||
{
|
{
|
||||||
@@ -503,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 = bounds;
|
var b = getBounds();
|
||||||
|
|
||||||
vt.Position.X = b.Left;
|
vt.Position.X = b.Left;
|
||||||
vt.Position.Y = b.Top;
|
vt.Position.Y = b.Top;
|
||||||
|
|||||||
@@ -187,15 +187,12 @@ 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 bounds
|
protected override RectangleF getBounds()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
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 _);
|
||||||
return new RectangleF(x, y, w, h);
|
return new RectangleF(x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void update(float delta)
|
protected override void update(float delta)
|
||||||
{
|
{
|
||||||
@@ -489,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 = bounds;
|
var b = getBounds();
|
||||||
|
|
||||||
vt.Position.X = b.Left;
|
vt.Position.X = b.Left;
|
||||||
vt.Position.Y = b.Top;
|
vt.Position.Y = b.Top;
|
||||||
|
|||||||
@@ -159,15 +159,12 @@ 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 bounds
|
protected override RectangleF getBounds()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
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 _);
|
||||||
return new RectangleF(x, y, w, h);
|
return new RectangleF(x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void update(float delta)
|
protected override void update(float delta)
|
||||||
{
|
{
|
||||||
@@ -461,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 = bounds;
|
var b = getBounds();
|
||||||
|
|
||||||
vt.Position.X = b.Left;
|
vt.Position.X = b.Left;
|
||||||
vt.Position.Y = b.Top;
|
vt.Position.Y = b.Top;
|
||||||
|
|||||||
@@ -167,15 +167,12 @@ 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 bounds
|
protected override RectangleF getBounds()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
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 _);
|
||||||
return new RectangleF(x, y, w, h);
|
return new RectangleF(x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void update(float delta)
|
protected override void update(float delta)
|
||||||
{
|
{
|
||||||
@@ -469,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 = bounds;
|
var b = getBounds();
|
||||||
|
|
||||||
vt.Position.X = b.Left;
|
vt.Position.X = b.Left;
|
||||||
vt.Position.Y = b.Top;
|
vt.Position.Y = b.Top;
|
||||||
|
|||||||
@@ -163,15 +163,12 @@ 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 bounds
|
protected override RectangleF getBounds()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
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 _);
|
||||||
return new RectangleF(x, y, w, h);
|
return new RectangleF(x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void update(float delta)
|
protected override void update(float delta)
|
||||||
{
|
{
|
||||||
@@ -465,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 = bounds;
|
var b = getBounds();
|
||||||
|
|
||||||
vt.Position.X = b.Left;
|
vt.Position.X = b.Left;
|
||||||
vt.Position.Y = b.Top;
|
vt.Position.Y = b.Top;
|
||||||
|
|||||||
@@ -163,15 +163,12 @@ 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 bounds
|
protected override RectangleF getBounds()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
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 _);
|
||||||
return new RectangleF(x, y, w, h);
|
return new RectangleF(x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void update(float delta)
|
protected override void update(float delta)
|
||||||
{
|
{
|
||||||
@@ -465,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 = bounds;
|
var b = getBounds();
|
||||||
|
|
||||||
vt.Position.X = b.Left;
|
vt.Position.X = b.Left;
|
||||||
vt.Position.Y = b.Top;
|
vt.Position.Y = b.Top;
|
||||||
|
|||||||
@@ -163,15 +163,12 @@ 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 bounds
|
protected override RectangleF getBounds()
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
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 _);
|
||||||
return new RectangleF(x, y, w, h);
|
return new RectangleF(x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void update(float delta)
|
protected override void update(float delta)
|
||||||
{
|
{
|
||||||
@@ -465,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 = bounds;
|
var b = getBounds();
|
||||||
|
|
||||||
vt.Position.X = b.Left;
|
vt.Position.X = b.Left;
|
||||||
vt.Position.Y = b.Top;
|
vt.Position.Y = b.Top;
|
||||||
|
|||||||
@@ -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 = bounds.GetView(PREVIEW_WIDTH, PREVIEW_HEIGHT);
|
using var view = getBounds().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);
|
||||||
@@ -163,12 +163,6 @@ namespace SpineViewer.Spine
|
|||||||
public bool UsePma { get { lock (_lock) return usePma; } set { lock (_lock) usePma = value; } }
|
public bool UsePma { get { lock (_lock) return usePma; } set { lock (_lock) usePma = value; } }
|
||||||
protected bool usePma = false;
|
protected bool usePma = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 骨骼包围盒
|
|
||||||
/// </summary>
|
|
||||||
public RectangleF Bounds { get { lock (_lock) return bounds; } }
|
|
||||||
protected abstract RectangleF bounds { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缩放比例
|
/// 缩放比例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -447,6 +441,12 @@ namespace SpineViewer.Spine
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ResetAnimationsTime() { lock (_lock) { foreach (var i in getTrackIndices()) setAnimation(i, getAnimation(i)); update(0); } }
|
public void ResetAnimationsTime() { lock (_lock) { foreach (var i in getTrackIndices()) setAnimation(i, getAnimation(i)); update(0); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前状态包围盒
|
||||||
|
/// </summary>
|
||||||
|
public RectangleF GetBounds() { lock (_lock) return getBounds(); }
|
||||||
|
protected abstract RectangleF getBounds();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新内部状态
|
/// 更新内部状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user