精简代码
This commit is contained in:
@@ -7,46 +7,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Spine.Interfaces.Attachments
|
||||
{
|
||||
public interface ISkinnedMeshAttachment : IAttachment
|
||||
public interface ISkinnedMeshAttachment : IMeshAttachment
|
||||
{
|
||||
/// <summary>
|
||||
/// R
|
||||
/// </summary>
|
||||
public float R { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// G
|
||||
/// </summary>
|
||||
public float G { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// B
|
||||
/// </summary>
|
||||
public float B { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A
|
||||
/// </summary>
|
||||
public float A { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用于渲染的纹理对象
|
||||
/// </summary>
|
||||
public SFML.Graphics.Texture RendererObject { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 顶点纹理坐标, 每个坐标有 u 和 v 两个数, 有效长度和 <see cref="IAttachment.ComputeWorldVertices(ISlot, ref float[])"/> 返回值一致
|
||||
/// </summary>
|
||||
public float[] UVs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 三角形索引顶点数组, 每 3 个为一组, 指向顶点的下标 (不是顶点坐标数组下标)
|
||||
/// </summary>
|
||||
public int[] Triangles { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 边缘顶点数组长度
|
||||
/// </summary>
|
||||
public int HullLength { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,18 +558,6 @@ namespace Spine
|
||||
tintA *= meshAttachment.A;
|
||||
texture = meshAttachment.RendererObject;
|
||||
break;
|
||||
case ISkinnedMeshAttachment skinnedMeshAttachment:
|
||||
worldVerticesLength = skinnedMeshAttachment.ComputeWorldVertices(slot, ref _worldVertices);
|
||||
worldVertices = _worldVertices;
|
||||
triangles = skinnedMeshAttachment.Triangles;
|
||||
trianglesLength = triangles.Length;
|
||||
uvs = skinnedMeshAttachment.UVs;
|
||||
tintR *= skinnedMeshAttachment.R;
|
||||
tintG *= skinnedMeshAttachment.G;
|
||||
tintB *= skinnedMeshAttachment.B;
|
||||
tintA *= skinnedMeshAttachment.A;
|
||||
texture = skinnedMeshAttachment.RendererObject;
|
||||
break;
|
||||
case IClippingAttachment clippingAttachment:
|
||||
_clipping.ClipStart(slot, clippingAttachment);
|
||||
continue;
|
||||
@@ -697,34 +685,6 @@ namespace Spine
|
||||
vt.Position.Y = _worldVertices[idx2 + 1];
|
||||
_lineVertices.Append(vt); _lineVertices.Append(vt);
|
||||
|
||||
vt.Position.X = _worldVertices[idx0];
|
||||
vt.Position.Y = _worldVertices[idx0 + 1];
|
||||
_lineVertices.Append(vt);
|
||||
}
|
||||
}
|
||||
else if (slot.Attachment is ISkinnedMeshAttachment skinnedMeshAttachment)
|
||||
{
|
||||
skinnedMeshAttachment.ComputeWorldVertices(slot, ref _worldVertices);
|
||||
|
||||
var triangles = skinnedMeshAttachment.Triangles;
|
||||
for (int i = 0; i < triangles.Length - 2; i += 3)
|
||||
{
|
||||
var idx0 = triangles[i] << 1;
|
||||
var idx1 = triangles[i + 1] << 1;
|
||||
var idx2 = triangles[i + 2] << 1;
|
||||
|
||||
vt.Position.X = _worldVertices[idx0];
|
||||
vt.Position.Y = _worldVertices[idx0 + 1];
|
||||
_lineVertices.Append(vt);
|
||||
|
||||
vt.Position.X = _worldVertices[idx1];
|
||||
vt.Position.Y = _worldVertices[idx1 + 1];
|
||||
_lineVertices.Append(vt); _lineVertices.Append(vt);
|
||||
|
||||
vt.Position.X = _worldVertices[idx2];
|
||||
vt.Position.Y = _worldVertices[idx2 + 1];
|
||||
_lineVertices.Append(vt); _lineVertices.Append(vt);
|
||||
|
||||
vt.Position.X = _worldVertices[idx0];
|
||||
vt.Position.Y = _worldVertices[idx0 + 1];
|
||||
_lineVertices.Append(vt);
|
||||
@@ -757,29 +717,6 @@ namespace Spine
|
||||
_lineVertices.Append(vt);
|
||||
}
|
||||
|
||||
vt.Position.X = _worldVertices[0];
|
||||
vt.Position.Y = _worldVertices[1];
|
||||
_lineVertices.Append(vt);
|
||||
}
|
||||
else if (slot.Attachment is ISkinnedMeshAttachment skinnedMeshAttachment)
|
||||
{
|
||||
skinnedMeshAttachment.ComputeWorldVertices(slot, ref _worldVertices);
|
||||
|
||||
var hullLength = skinnedMeshAttachment.HullLength;
|
||||
if (hullLength < 4) continue;
|
||||
|
||||
vt.Position.X = _worldVertices[0];
|
||||
vt.Position.Y = _worldVertices[1];
|
||||
_lineVertices.Append(vt);
|
||||
|
||||
for (int i = 2; i < hullLength - 1; i += 2)
|
||||
{
|
||||
vt.Position.X = _worldVertices[i];
|
||||
vt.Position.Y = _worldVertices[i + 1];
|
||||
_lineVertices.Append(vt);
|
||||
_lineVertices.Append(vt);
|
||||
}
|
||||
|
||||
vt.Position.X = _worldVertices[0];
|
||||
vt.Position.Y = _worldVertices[1];
|
||||
_lineVertices.Append(vt);
|
||||
|
||||
Reference in New Issue
Block a user