Skip to content

Commit

Permalink
[unity] Prospective resizing for MeshGenerator AddSubmesh branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
pharan committed Oct 18, 2018
1 parent d78b2fd commit 8d74ef0
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,13 @@ public void AddSubmesh (SubmeshInstruction instruction, bool updateTriangles = t
// Add data to vertex buffers
{
int newVertexCount = ovc + attachmentVertexCount;
if (newVertexCount > vertexBuffer.Items.Length) { // Manual ExposedList.Resize()
Array.Resize(ref vertexBuffer.Items, newVertexCount);
Array.Resize(ref uvBuffer.Items, newVertexCount);
Array.Resize(ref colorBuffer.Items, newVertexCount);
int oldArraySize = vertexBuffer.Items.Length;
if (newVertexCount > oldArraySize) {
int newArraySize = (int)(oldArraySize * 1.3f);
if (newArraySize < newVertexCount) newArraySize = newVertexCount;
Array.Resize(ref vertexBuffer.Items, newArraySize);
Array.Resize(ref uvBuffer.Items, newArraySize);
Array.Resize(ref colorBuffer.Items, newArraySize);
}
vertexBuffer.Count = uvBuffer.Count = colorBuffer.Count = newVertexCount;
}
Expand Down

0 comments on commit 8d74ef0

Please sign in to comment.