Earlier quoted context omitted.
The code must somehow compute bouyancy in a way that reflects the object's arbitrarily complex shape. It's likely carving the object up into some number of smaller primitive objects whose equations for bouyancy are known. In order to make the whole object move as one rigid body, though, it's probably computing force vectors for each primitive, and then summing them together based on the overall object's center of mas…
If you look at the source, you'll see that it doesn't really try to split the path into smaller primitives at all. It uses a simple algorithm ( https://stackoverflow.com/a/33852627 ) to calculate the center of mass, and another algorithm to calculate the area ( https://stackoverflow.com/a/33670691 ). Both of these algorithms basically sum up the "signed area" of the polygons. This means that if you circle something t…
Good catch with the discrepancy between the physics and the visualization. I wonder if there's a way to engineer a cool structure with a lot of invisible mass.
Do you have a notion of how the code actually computes bouyancy? Does it somehow slice the polygon into two at the water line and then compute center and area of both? Once again, it would be interesting to engineer an object that leverages any non-linear behaviors at the water line, perhaps like an object whose mass changes depending on its position and orientation.