public static class BuoyancyPontoons floating on the one surface everything else reads.
Remarks
[35 § D10](../../docs/plan/35-water.md#d10-buoyancy-is-pontoons-over-jolt-evaluated-at-the-fixed-steps-water-time). Per fixed step, per pontoon: ask the evaluator where the surface is, work out how much of the sphere is under it, and produce an upward force at the pontoon's world position, a drag opposing its relative velocity, and a pull towards the flow.
⚠ It reads the simulation's water time and never a frame time. A buoyancy force computed from an interpolated render-time surface is a force that changes when the frame rate does, and in a networked game that is a client and a server disagreeing about where a boat is. That is [16](../../docs/plan/16-networking.md)'s determinism requirement applied to a force, and it is why the evaluator's explicit waterTime is not a stylistic choice.
⚠ Jolt has a buoyancy impulse of its own and it is deliberately not used. It takes a plane, which is exactly the approximation a wave surface is not — and using it would put a second definition of the water surface inside the physics engine, where the seam test cannot reach it.
Zero-allocation and pure, because the answer to "how many floating crates" should be "as many as you like" — and because a rollback re-simulating six ticks needs this to be a function of its arguments and nothing else.
Fields and properties (1)
public const float DensityFresh water, in kilograms per cubic metre.
Methods (4)
public static float SubmergedFraction(float radius, float centre, float surface)How much of a sphere is under a surface, 0…1.
public static BuoyancyForce Evaluate(in WaterEvaluator evaluator, in BuoyancyPontoon pontoon, Vector3 centre, Vector3 velocity, float gravity, in BuoyancySettings settings, float waterTime, IWaterRipples? ripples = null)What one pontoon does to a body this step.
public static int Solve(in WaterEvaluator evaluator, ReadOnlySpan<BuoyancyPontoon> pontoons, in Matrix4x4 placement, Vector3 velocity, float gravity, in BuoyancySettings settings, float waterTime, Span<BuoyancyForce> into, IWaterRipples? ripples = null)Every pontoon of one body, in one pass.
public static float RestDisplacement(ReadOnlySpan<BuoyancyPontoon> pontoons, float mass, in BuoyancySettings settings)Where a body of a given mass floats, given its pontoons, in metres of submersion.
Used by (4)
- BuoyancyDebugDrawVixen.Water.Physics
- BuoyancySystemVixen.Water.Physics
- BuoyancySystemTestsVixen.Water.Physics.Tests
- BuoyancyTestsVixen.Water.Tests