Smash objects in pieces

Hi guys.

This is my very first post on this forum. I hope I’m not doing anything wrong. I’m trying to mess around with python scripting and I came up with a fun algorithm. What it technically does is slice the object up randomly with a specify number of times. So far it works fine with convex meshes. I still have no idea how to slice a mesh with a closed, inward loop. The algorithm is simple, it loops through the polygons in the mesh, find the intersections, then split the face in 2 halves. After that it searches through all the new edges it created and make a face there (the face that splits the mesh in 2 halves.) The only problem with that it doesn’t know whether a loop is inside of the mesh or outside.
Here’s the (undocumented D: ) code (it’s also the very first time I code in python so it may not be very efficient code. I should try and be more object oriented :spin:)

Here’s a cube that has been sliced 4 times


Here’s a failed sliced torus

And here’s a smashed up sphere (18 slices) that I applied some rigidbody physics on and dropped on the ground.

Attachments