Update:
This problem was solved in the following way:
Introduce View and Edit modes.
View - allows viewing all objects as triangulated meshes (1 Mesh per object). For each object in the scene, create a Voxel 3D Grid.
Edit - allows editing objects as a grid of voxels, where an object is rendered as a group of triangulated chunks. (Up to 512 meshes per object)
For each object in the scene, we create a 256^3 grid of voxels, where each voxel is described by a 1 byte (Material -> [1, 255], the max memory usage per object = 256^3 bytes = 16Mb)
At the same time, you can edit only a single object.
When you go from the Edit mode to View mode, the 3D grid of chunks is saved to disk. In the opposite situation (going from View to Edit mode), the 3D grid is loaded from the disk.
On the screen, any object at any time, rendered as a triangulated mesh (Greedy meshing)
Pros:
- 3D grid can be replaced with Sparse Voxel Octree later.
- Objects can be moved which allows placing objects close to each other, creating seamless meshes in size greater than 256^3 voxels.
- Good memory usage, the Edited object takes 16Mb in RAM, and other objects (which are in view mode) took memory === memory that polygons (normals, etc.) took.
- Objects can change Visibility pretty easily.
- Objects can do bool operations between each other pretty well, such as subtraction, addition, etc. (Using their internal 3D grids)
Cons:
- Too many meshes per Edited object (8^3 chunks = 512 Meshes in a case if all the chunks are filled)
- Should save each object separately on the disk.
- Freeze between changing modes (During saving/loading chunks to/from the disk)
- Freeze when going from Edit to View (During combining all the chunks into a single mesh, to reduce meshes from 8^3 to 1)