Instead of using cubes just use wall faces i.e. a single face of a cube.
Make a 2D or 3D array which holds the wall positions (1) and empty spaces (0) , for example
1111111111
1000000001
1000000011
1111100011
1000000001
1111111111
then loop through the array, if theres a (0) then add a floor and ceiling surface to the mesh.
If theres a (1) check the array above,below,left and right of the current position to see if you need to add a wall face to the mesh.
This way you use minimal surfaces/verts and triangles to build your level so theres no need to go back and delete faces after.
Make a 2D or 3D array which holds the wall positions (1) and empty spaces (0) , for example
1111111111
1000000001
1000000011
1111100011
1000000001
1111111111
then loop through the array, if theres a (0) then add a floor and ceiling surface to the mesh.
If theres a (1) check the array above,below,left and right of the current position to see if you need to add a wall face to the mesh.
This way you use minimal surfaces/verts and triangles to build your level so theres no need to go back and delete faces after.