Vector3[] newVertices() { Mesh mesh = MeshGetters.getMesh(this.gameObject); int[] triangles = mesh.triangles; Vector3[] triangleA = new Vector3[3];//Lets not allocate new vector3s so much Vector3[] triangleB = new Vector3[3]; bool verticesUpdatedSuccessfully; Vector3[] newVertices; do { newVertices = mesh.vertices; verticesUpdatedSuccessfully = true; //Modify the vertices for (int i = 0; i < newVertices.Length; i++) { wiggleVector3(ref newVertices[i]); } //Check the triangles for collisions for (int i = 0; i < triangles.Length; i += 3) { triangleA[0] = newVertices[triangles[i]]; triangleA[1] = newVertices[triangles[i + 1]]; triangleA[2] = newVertices[triangles[i + 2]]; for (int j = i + 3; j < triangles.Length; j += 3) { triangleB[0] = newVertices[triangles[j]]; triangleB[1] = newVertices[triangles[j + 1]]; triangleB[2] = newVertices[triangles[j + 2]]; if (!GeometryFunctions.triangleNonintersectCheck(triangleA, triangleB)) { verticesUpdatedSuccessfully = false; break; } } } } while (!verticesUpdatedSuccessfully); if (this.saveModel) { MeshSerializer.serializeMesh(mesh, this.name); } return(newVertices); }