I have a 3D array. In this array I want to find elements that can be combined in bigger elements. Rectangles cannot overlay each other. Preferably I would like to find the biggest rectangle first, but a first come first serve wouldn't be wrong either, especially if that increases performance.
E.g.
1 0 0 0 1
0 0 0 0 0
0 0 0 0 1
1 1 0 0 1
will yield (as 3x3 is the biggest rectangle that can be found; position 1, 0 to 3, 2 - zerobased):
0 0 0
0 0 0
0 0 0
and (as 1x2 is the next biggest rectangle that can be found; position 0, 1 to 0, 2):
0
0
and (as 2x1 is the next biggest rectangle that can be found; position 2, 3 to 3, 3):
0 0
and of course (left is position 4, 1; which is not bigger but still needs to be used)
0
as bigger elements (I only need to know about the zeros OR ones). The purpose is to lessen the amount of colliders for a voxelgrid.
I don't know the name for such an algorithm, possibly I could find out myself how to do this then.
If someone could provide me some viable information for this, that would be great!