mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 23:34:53 +08:00
[unity] Fixed costly Vector3 *= operator on 2019.4- in MeshGenerator.ScaleVertexData. Closes #2558.
This commit is contained in:
parent
5d37fac0fc
commit
469735e96a
@ -31,6 +31,12 @@
|
||||
#define MESH_SET_TRIANGLES_PROVIDES_LENGTH_PARAM
|
||||
#endif
|
||||
|
||||
#if !UNITY_2020_1_OR_NEWER
|
||||
// Note: on Unity 2019.4 or older, e.g. operator* was not inlined via AggressiveInlining and at least with some
|
||||
// configurations will lead to unnecessary overhead.
|
||||
#define MANUALLY_INLINE_VECTOR_OPERATORS
|
||||
#endif
|
||||
|
||||
// Not for optimization. Do not disable.
|
||||
#define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame.
|
||||
//#define SPINE_DEBUG
|
||||
@ -1112,7 +1118,13 @@ namespace Spine.Unity {
|
||||
public void ScaleVertexData (float scale) {
|
||||
Vector3[] vbi = vertexBuffer.Items;
|
||||
for (int i = 0, n = vertexBuffer.Count; i < n; i++) {
|
||||
vbi[i] *= scale; // vbi[i].x *= scale; vbi[i].y *= scale;
|
||||
#if MANUALLY_INLINE_VECTOR_OPERATORS
|
||||
vbi[i].x *= scale;
|
||||
vbi[i].y *= scale;
|
||||
vbi[i].z *= scale;
|
||||
#else
|
||||
vbi[i] *= scale;
|
||||
#endif
|
||||
}
|
||||
|
||||
meshBoundsMin *= scale;
|
||||
@ -1124,7 +1136,13 @@ namespace Spine.Unity {
|
||||
Vector3 offset = new Vector3(offset2D.x, offset2D.y);
|
||||
Vector3[] vbi = vertexBuffer.Items;
|
||||
for (int i = 0, n = vertexBuffer.Count; i < n; i++) {
|
||||
#if MANUALLY_INLINE_VECTOR_OPERATORS
|
||||
vbi[i].x = vbi[i].x * scale + offset.x;
|
||||
vbi[i].y = vbi[i].y * scale + offset.y;
|
||||
vbi[i].z = vbi[i].z * scale + offset.z;
|
||||
#else
|
||||
vbi[i] = vbi[i] * scale + offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
meshBoundsMin *= scale;
|
||||
@ -1184,9 +1202,9 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Step 3 : Transfer vertex and triangle data to UnityEngine.Mesh
|
||||
#region Step 3 : Transfer vertex and triangle data to UnityEngine.Mesh
|
||||
public void FillVertexData (Mesh mesh) {
|
||||
Vector3[] vbi = vertexBuffer.Items;
|
||||
Vector2[] ubi = uvBuffer.Items;
|
||||
@ -1266,7 +1284,7 @@ namespace Spine.Unity {
|
||||
mesh.SetTriangles(submeshesItems[i].Items, i, false);
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public void EnsureVertexCapacity (int minimumVertexCount, bool inlcudeTintBlack = false, bool includeTangents = false, bool includeNormals = false) {
|
||||
if (minimumVertexCount > vertexBuffer.Items.Length) {
|
||||
@ -1314,7 +1332,7 @@ namespace Spine.Unity {
|
||||
if (tangents != null) Array.Resize(ref tangents, vbiLength);
|
||||
}
|
||||
|
||||
#region TangentSolver2D
|
||||
#region TangentSolver2D
|
||||
// Thanks to contributions from forum user ToddRivers
|
||||
|
||||
/// <summary>Step 1 of solving tangents. Ensure you have buffers of the correct size.</summary>
|
||||
@ -1401,9 +1419,9 @@ namespace Spine.Unity {
|
||||
tangents[i] = tangent;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region AttachmentRendering
|
||||
#region AttachmentRendering
|
||||
static List<Vector3> AttachmentVerts = new List<Vector3>();
|
||||
static List<Vector2> AttachmentUVs = new List<Vector2>();
|
||||
static List<Color32> AttachmentColors32 = new List<Color32>();
|
||||
@ -1515,6 +1533,6 @@ namespace Spine.Unity {
|
||||
AttachmentColors32.Clear();
|
||||
AttachmentIndices.Clear();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "com.esotericsoftware.spine.spine-unity",
|
||||
"displayName": "spine-unity Runtime",
|
||||
"description": "This plugin provides the spine-unity runtime core.",
|
||||
"version": "4.2.72",
|
||||
"version": "4.2.73",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user