I'm using Farseer 3.5 which is a pretty one-to-one C# port of Box2D, so expertise with either is relevant.
I have a planet (pink) and I'm using a GravityController so it has gravity. This is working great. I want to add an ocean to its surface using a BuoyancyController in a similar fashion. For example, center BuoyancyController on the center of the planet and make its radius 100m larger than the planet's radius to cover the entire planet evenly with 100m of "water." Once I have this in place, I'll refactor the BuoyancyController to use the vector of the planet's gravity at any given point for the buoyancy direction, so you can float atop the ocean at any angle.
Unfortunately, as far as I can tell the BuoyancyController only allows for specifying an AABB. See here:
// create southern ocean
var testOcean1 = new BuoyancyController(
new AABB(
new Vector2(100, -200), // position
100, // width
50), // height
0.5f, // density
2.0f, // linear drag
1.0f, // angular drag
new Vector2(1.0f, 0) // gravity direction
);
this.World.AddController(testOcean1);
// create northern ocean
var testOcean2 = new BuoyancyController(
new AABB(
new Vector2(100, 0), // position
100, // width
50), // height
0.5f, // density
2.0f, // linear drag
1.0f, // angular drag
new Vector2(1.0f, 0) // gravity direction
);
this.World.AddController(testOcean2);
Here's a fork of Farseer which illustrates this class: https://github.com/tinco/Farseer-Physics/blob/master/SourceFiles/Controllers/BuoyancyController.cs
Does anyone know of a custom controller or way to bend this to my needs? The physics math gets a little heavy for something like this, so ideally I can use a pre-packaged solution. There are many Box2D ports in many languages and if ANY of them have this solution, then I can port it myself, no problem.
This is what it looks like now. Buoyance regions are always an AABB -- can't rotate or make any shape beyond a basic rectangle.

Some illustrations:
If I could merely rotate the AABB, I could probably make it work, but it's not ideal.

What I really need is a way to make it a circle (center with radius) rather than AABBs. This would be very similar to how the GravityController works.

EDIT: 6/2/2018 Unfortunately, there have been no replies to this, so I'm confronting the possibility I may need to write it myself. I'm fine using just polygons for body shapes, no circles or other shapes, so if I can refactor the ComputeSubmergedArea() method for PolygonShape to compare with any other polygon, rather than just an AABB region, that may be the trick. Anyone?
EDIT 6/3/2018: I've been looking at the code more and ComputeSubmergedArea seems to calculate submerged area below a line. That line is typically one edge of the AABB, but perhaps I can pass in any line. If so, I could refactor the BuoyancyController to use a circle as its area rather than an AABB and when something enters it, pass in the tangent line to the edge of the circle into the ComputeSubmergedArea method. This may do it! It would break down if the Buoyancy area was very small, as this is treating any given point on its perimeter as a straight line, but this will be acceptable in my case, as the planet and ocean are so large that they appear effectively flat when viewed as a player. Some promising leads: 1. http://www.box2d.org/forum/viewtopic.php?t=6250 2. http://box2d.org/forum/viewtopic.php?t=4068

