Wouldn’t it be easier to calculate the volume exactly? Simply take each triangle and calculate volume of the prism under the triangle. If normal points down, subtract it. If normal points up add it. So you get the total volume. The conditions for the body are similar as yours. The normals have to point outside the body and the body has to be closed. It does not need to be convex.
This would be great for softbodies, like gel and the suchlike. a force on each face proportional to the volume difference as well as gravity.
What kind of speeds could you get for this, anything apporaching usable for animations (not realtime, just for simulations)?
btw. Maya and co rather use simple tricks to get nice results. Having real volume preservation is something for FEM on high speed clusters.
True, but using volume calculation that is as fast as that, as well as surface calculation, a nice soft-body effect could be done. The volume need not be preserved, just the forces need to be calculated to low accuracy. To preserve the volume would require more accurate solutions after the volume calculation rather than this.
I’ve included it in my x86 Optimized build. Check the first post of this thread.
For the speed thingy again:
If i create a UV sphere with 32x32 and appliying several subdivison such that it got 256144 polygons and then clicking my Volume/Surface buttons i cannot recognize a lot of delay till the result shows up.
And i guess a single mesh with 256k polys is already considered “large”