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
0b36f0becc
commit
7d2647baff
@ -171,6 +171,10 @@ namespace Spine.Unity {
|
|||||||
if (skeleton != null) skeleton.SetToSetupPose();
|
if (skeleton != null) skeleton.SetToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
||||||
|
|||||||
@ -1059,6 +1059,39 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//vertexBuffer.Count = uvBuffer.Count = colorBuffer.Count = minimumVertexCount;
|
||||||
|
}
|
||||||
|
|
||||||
public void TrimExcess () {
|
public void TrimExcess () {
|
||||||
vertexBuffer.TrimExcess();
|
vertexBuffer.TrimExcess();
|
||||||
uvBuffer.TrimExcess();
|
uvBuffer.TrimExcess();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user