Vixen
c7401864
csharp
public struct BuoyancyBody

What a scene says about a floating body: its pontoons, and how they float.

Read the guide page for this →

Remarks

[35 § D10](../../docs/plan/35-water.md#d10-buoyancy-is-pontoons-over-jolt-evaluated-at-the-fixed-steps-water-time), the world-facing half. The arithmetic is Buoyancy's and is tested against an analytic rest displacement; what this adds is an entity, a rigid body and a fixed step.

⚠ The pontoons are a displacement volume and not the collision shape. A barge is four large spheres and a canoe is six small ones along its keel; matching them to the hull mesh is how a boat ends up floating a hand's width too high, and matching them to the collider is how it ends up floating on its bounding box.

⚠ An array makes this a managed component, on WaterBodyComponent's terms: its values live in the world's store and the chunk holds handles, so BuoyancySystem reads it an entity at a time. A fixed inline list would be a cap on how many pontoons a hull may have, chosen here, for every game.

⚠ A body with no pontoons floats nowhere and is not an error. It is what an entity part-way through being authored looks like, and it costs one length check per step.

Fields and properties (8)

  • public BuoyancyPontoon[] Pontoons

    The spheres, in the body's own frame.

  • public float Coefficient

    A multiplier on the displaced weight. One is Archimedes.

  • public float Damping

    First-order damping on the submerged part's velocity, per second.

  • public float QuadraticDamping

    Second-order damping, which is what gives a boat a top speed.

  • public float MaximumForce

    The most upward force one pontoon may produce, in newtons. Zero for no limit.

  • public float FlowDrag

    How hard a current drags a submerged pontoon along with it, per second.

  • public static BuoyancyBody Default

    A crate: Archimedes exactly, damped enough to settle in a couple of seconds.

  • public readonly BuoyancySettings Settings

    This component as the kernel's own description.

Methods (2)

  • public static BuoyancyBody Sphere(float radius)

    A single sphere of a radius, which is what a crate or a barrel is.

  • public static BuoyancyBody Raft(float halfLength, float halfWidth, float radius, float height = 0)

    Four pontoons at the corners of a hull, which is what a raft is.

Used by (11)

  • BuoyancyDebugDrawVixen.Water.Physics
  • BuoyancyDebugDrawTestsVixen.Water.Physics.Tests
  • BuoyancySystemVixen.Water.Physics
  • BuoyancySystemTestsVixen.Water.Physics.Tests
  • ComponentRegistrationVixen.Water.Physics
  • TypeRegistrationVixen.Water.Physics
  • Vixen_Water_Physics_BuoyancyBodySerializerVixen.Water.Physics
  • EditorApplicationVixen.Editor.App
  • MaterialIconsVixen.Editor.App
  • SceneWaterComponentTestsVixen.Editor.Assets.Tests
  • WaterSceneRunsTestsVixen.Editor.Assets.Tests