private void GenerateSelectionMesh()
{
SkinnedMeshRenderer component = this.cloth.GetComponent<SkinnedMeshRenderer>();
Vector3[] vertices = this.cloth.vertices;
int length = vertices.Length;
this.m_Selection = new bool[vertices.Length];
this.m_RectSelection = new bool[vertices.Length];
if (this.m_SelectionMesh != null)
{
foreach (Mesh mesh in this.m_SelectionMesh)
{
Object.DestroyImmediate(mesh);
}
foreach (Mesh mesh2 in this.m_SelectedMesh)
{
Object.DestroyImmediate(mesh2);
}
}
int num4 = (length / s_MaxVertices) + 1;
this.m_SelectionMesh = new Mesh[num4];
this.m_SelectedMesh = new Mesh[num4];
this.m_LastVertices = new Vector3[length];
this.m_MeshVerticesPerSelectionVertex = this.m_VertexMesh.vertices.Length;
Transform actualRootBone = component.actualRootBone;
for (int i = 0; i < num4; i++)
{
this.m_SelectionMesh[i] = new Mesh();
Mesh mesh1 = this.m_SelectionMesh[i];
mesh1.hideFlags |= HideFlags.DontSave;
this.m_SelectedMesh[i] = new Mesh();
Mesh mesh3 = this.m_SelectedMesh[i];
mesh3.hideFlags |= HideFlags.DontSave;
int num6 = length - (i * s_MaxVertices);
if (num6 > s_MaxVertices)
{
num6 = s_MaxVertices;
}
CombineInstance[] combine = new CombineInstance[num6];
int num7 = i * s_MaxVertices;
for (int j = 0; j < num6; j++)
{
this.m_LastVertices[num7 + j] = ((Vector3) (actualRootBone.rotation * vertices[num7 + j])) + actualRootBone.position;
combine[j].mesh = this.m_VertexMesh;
combine[j].transform = Matrix4x4.TRS(this.m_LastVertices[num7 + j], Quaternion.identity, Vector3.one);
}
this.m_SelectionMesh[i].CombineMeshes(combine);
for (int k = 0; k < num6; k++)
{
combine[k].mesh = this.m_VertexMeshSelected;
}
this.m_SelectedMesh[i].CombineMeshes(combine);
}
this.SetupSelectionMeshColors();
}