I have a 3D grid of binary data values (either the point is solid or it's not). I need to generate a physics mesh from that grid, but it needs to be able to move, so I can't use triangle mesh, I must use a compound shape made of boxes. I need to find the largest boxes (or rather the least number of boxes) that the grid can be split into. Here's a 2D representation of what I want to do in 3D:
The first image shows each point as its own box - terribly inefficient (22 boxes). The second image shows what I would like the grid to become (4 boxes).
I realise there are convex decomposition libraries out there, but I need this to be exact, not approximate, and I thought there might be some easier method when the data is guaranteed to be in a grid. Also, I need boxes, not just convex shapes.
Any tips, pointers or help would be much appreciated :)