I am working on a voxel-based game world. Every exposed voxel is getting a box or convexMesh shape (if not cubic) at the moment, which is quite ok when dealing with static actors. The thing is, I want my voxel environments to be dynamic. Once a couple of thousands of box shapes start moving, it’s getting pretty bad performance-wise. Now before I spend many hours experimenting, I would like to hear from people more experienced with the engine.
I’ve thought of 2 approaches. One is pretty simple: just look for neighboring boxes - maybe divided by sectors (like 5x5x5 voxels in size) - to group them into larger boxes and reduce the number of shapes. The problem here is that only boxes can be grouped, and only those that can be described by a bigger box. Writing algorithms to find the best way of grouping could be a pain. Also, I want to make much use of “half-boxes” - divided diagonally - to make the world less “edgy”. But for grouping these I would need convex meshes.
That’s the other approach: create convex meshes to put several shapes into a single one. It would allow me to remove unneeded vertices as well. The question is, are convex meshes good for performance or should I stick with primitive shapes? And would re-cooking a mesh every time a voxel is added or removed from a buffer/sector have a big impact on performance?
Or maybe there’s something else I haven’t thought of?