From a response by Julio:
The single collision model of buoyancy is good for small regular bodies. Buoyancy in principle is very simple, but is one of those things that can be extremely numerical unstable.
In general this is how it works:
- You define the water plane in callback
- The collision geometry is clipped along the plane and the part on the positive side (the wetted area) is used to calculate volume and center of mass.
- Then with these values, the force is proportional to the volume on the positive side of the plane, and this is a very stable quantity, as the volume change very gradually.
The center of buoyancy (the geometric centre of the wetted area) on the other hand, is that part that is very unstable, because it's a point the reach equilibrium when is exactly aligned vertically with the center of mass of the solid. The problem is that the center of buoyancy is a quantity that changes very rapidly with irregular shape bodies, for example with a sphere or regular box the center will change very smoothly, for a flat box a very small movement will make the center of buoyancy translate a relatively large distance, creating larger torques.
The source of instability is that this is only one force, but this can be improved by splitting the collision shape using a compound collision, so the buoyancy force acts on each primitive.
You can create collision shapes with ID for buoyancy that are ignored for collision, and the ID for collision are ignored for buoyancy. You will get a callback for each primitive in the compound collision, and that way the forces will be applied in a more consolable way.
You could also pass different water planes at each callback.
By placing the collision shape strategically on the hull of the vessel it is possible to come up with a good representation. You can for example split the points cloud on the model into a grid say 2 x 2 x 3 and pass the points inside each grid to the convex hull to make the buoyancy hull, or you can even cheat by placing the pieces in different positions to make the vessel more stable.