Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
protected void PlaneSplit1() {
Mesh mesh = this.GetMesh();
Vector3[] vertices = mesh.vertices;
for (int pass = 0; pass < this.Passes; pass++) {
// Pick a random point in the Sphere
Vector3 splitVector = Random.insideUnitSphere;
for (int i = 0; i < mesh.vertices.Length; i++) {
// Get the DOT product of that random point
if (Vector3.Dot(splitVector, vertices[i].normalized - splitVector) > 0) {
// Move vertices out
vertices[i] *= (1 + this.Scale * 1.1f);
} else {
// Move vertices in
vertices[i] *= (1 - this.Scale);
}
}
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment