uzik wrote:I was perusing the code today and read through the reference paper
on marching cubes. The table based implementation should be very
quick.
Yeah, it's pretty fast

I'm sure it could get faster though, I haven't really profiled to see where the bottle necks are.
uzik wrote:I assume you intended to optimize by only subdividing a surface as it's
struck by a bullet, and not applying it to every mesh in the scene?
I'm not quite sure what you mean... The way it works is the volume (currently 256x256x256) is divided into blocks (say 32x32x32) and I generate a mesh for each block. If the data in the block changes the I regenerate only that mesh. So yes, changes to the data only affect the mesh 'locally'.
uzik wrote:The rubble falling out would come easily if you have a physics
simulation hooked into your code. Instead of deleting the subdivided
cubes inside the spherical damage area just apply a spherical outward
force and you're good.
Yes, actually I've already half done this. When the voxels are deleted they are replaced by a particle system which sends pieces flying out. Need to see if I can use meshes for the particles though - haven't tried this yet.
The real problem with the physics I think will be detecting the 'floating' regions which result from cutting out supporting material. I haven't thought about this much but it's pretty tough.
uzik wrote:What was your problem with the result? Since you're
subdividing into square or cubic regions you'd have to make them
pretty small before the jaggy appearance disappeared.
The mesh smooth would probably help a lot. Is it computationally intensive
to do?
You mean with the mesh smoothing? Actually that was a lie - I'm not really smoothing the
mesh at the moment, I'm just averaging the normals of several adjacent voxels so it looks smoother.
The mesh smoothing needs some thought. If I do it on the CPU then it may be slow but only gets done once. If it is done with GPU shaders then it's fast (and can be done per-material) but has to be done every frame.
I heard something about next-gen hardware allowing the results of the geometry shader to be written back to a Vertex Buffer. Sounds great, this might solve the problems.
uzik wrote:Perhaps you can reference the LOD settings and recursively
subdivide just at the edge until you reach cubes of a size
set as the next the level of detail? This would give the edge
smoothness without generating a lot of geometry that doesn't
contribute anything.
The system definatly needs LOD. Actually It's quite easy to get from marching cubes - I just take a group of 8 cubes and consider them to be 1 cube, then just generate the mesh for that. Generating the mesh for each LOD should be 8 times faster than generating the previous LOD.
But there are other options - I could ditch Marching Cubes directly and use a different algorithm. There are some which start with a crude approximation and successively improve it. One of the problems with marching cubes it that it generates loads of triangles even for a large flat surface. Other approaches avoid this because they only subdivide a surface if it is curved.
I have a lot of research to do here...