mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Allow user to preallocate MeshGenerator buffer size.
This commit is contained in:
parent
6dec3d37fa
commit
fac440c434
@ -172,6 +172,13 @@ namespace Spine.Unity {
|
|||||||
if (skeleton != null) skeleton.SetToSetupPose();
|
if (skeleton != null) skeleton.SetToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets a minimum buffer size for the internal MeshGenerator to prevent excess allocations during animation.
|
||||||
|
/// </summary>
|
||||||
|
public void EnsureMeshGeneratorCapacity (int minimumVertexCount) {
|
||||||
|
meshGenerator.EnsureVertexCapacity(minimumVertexCount);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize this component. Attempts to load the SkeletonData and creates the internal Skeleton object and buffers.</summary>
|
/// Initialize this component. Attempts to load the SkeletonData and creates the internal Skeleton object and buffers.</summary>
|
||||||
/// <param name="overwrite">If set to <c>true</c>, it will overwrite internal objects if they were already generated. Otherwise, the initialized component will ignore subsequent calls to initialize.</param>
|
/// <param name="overwrite">If set to <c>true</c>, it will overwrite internal objects if they were already generated. Otherwise, the initialized component will ignore subsequent calls to initialize.</param>
|
||||||
|
|||||||
@ -1057,6 +1057,38 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void EnsureVertexCapacity (int minimumVertexCount, bool inlcudeTintBlack = false, bool includeTangents = false, bool includeNormals = false) {
|
||||||
|
if (minimumVertexCount > vertexBuffer.Items.Length) {
|
||||||
|
Array.Resize(ref vertexBuffer.Items, minimumVertexCount);
|
||||||
|
Array.Resize(ref uvBuffer.Items, minimumVertexCount);
|
||||||
|
Array.Resize(ref colorBuffer.Items, minimumVertexCount);
|
||||||
|
|
||||||
|
if (inlcudeTintBlack) {
|
||||||
|
if (uv2 == null) {
|
||||||
|
uv2 = new ExposedList<Vector2>(minimumVertexCount);
|
||||||
|
uv3 = new ExposedList<Vector2>(minimumVertexCount);
|
||||||
|
}
|
||||||
|
uv2.Resize(minimumVertexCount);
|
||||||
|
uv3.Resize(minimumVertexCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeNormals) {
|
||||||
|
if (normals == null)
|
||||||
|
normals = new Vector3[minimumVertexCount];
|
||||||
|
else
|
||||||
|
Array.Resize(ref normals, minimumVertexCount);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeTangents) {
|
||||||
|
if (tangents == null)
|
||||||
|
tangents = new Vector4[minimumVertexCount];
|
||||||
|
else
|
||||||
|
Array.Resize(ref tangents, minimumVertexCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void TrimExcess () {
|
public void TrimExcess () {
|
||||||
vertexBuffer.TrimExcess();
|
vertexBuffer.TrimExcess();
|
||||||
uvBuffer.TrimExcess();
|
uvBuffer.TrimExcess();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user