Vixen
caa30e12
csharp
public sealed class WaterQuery

The surface, as everything outside this assembly asks about it.

Read the guide page for this →

Remarks

One object a buoyancy solver, a movement mode and a gameplay script all hold. WaterEvaluator is a ref struct over borrowed spans — which is what makes it free to construct and impossible to store — so this is the thing with a lifetime: it owns the sea state, points at a field, and hands out an evaluator per call.

This is what a dedicated server runs ([35 § D1](../../docs/plan/35-water.md#d1-three-assemblies-and-the-kernel-touches-no-device)). A headless build has no device and still has to answer how deep the water is for every swimming character and every boat it simulates, and [§ D2](../../docs/plan/35-water.md#d2-one-evaluator-two-hosts-and-the-seam-is-a-test) makes that answer the same one the client draws.

⚠ Every entry point takes an explicit water time. There is no clock in here and there will not be one: the fixed step and the render pass values derived from the same source, the render interpolating within the step, and a solver that reached for a frame time would be a force that changes when the frame rate does — which in a networked game is a client and a server disagreeing about where a boat is.

Fields and properties (7)

  • public IWaterFieldSource? FieldSource

    Where the field is read from when it can be replaced, or null to stand on Field alone.

  • public WaterField? Field

    The field this reads bodies and ground from, or null for open water everywhere.

  • public WaterAttenuation Attenuation

    How the sea state falls off as the ground rises.

  • public WaterWaveSpectrum Spectrum

    The spectrum the waves were summed from.

  • public ReadOnlySpan<GerstnerWave> Waves

    The sea state, as the evaluator reads it.

  • public float MaximumAmplitude

    The tallest the surface can be above its rest height, in metres.

  • public IWaterRipples? Ripples

    A simulation whose displacement is added, or null.

Methods (7)

  • public WaterQuery(WaterField? field, in WaterWaveSpectrum spectrum, WaterAttenuation attenuation = default(WaterAttenuation))

    Creates a query over a field and a sea state.

  • public void SetSpectrum(in WaterWaveSpectrum spectrum)

    Re-sums the waves from a spectrum.

  • public WaterSample Sample(Vector2 position, float waterTime)

    What the surface is like at a place and a time.

  • public WaterSample ClosedForm(Vector2 position, float waterTime)

    What the surface is like, ignoring any ripple simulation.

  • public float Height(Vector2 position, float waterTime)

    Where the surface is, and nothing else.

  • public float Immersion(Vector2 position, float bottom, float height, float waterTime)

    How much of a capsule is under the surface, 0…1.

  • public WaterEvaluator Evaluator()

    An evaluator over what this query holds.

Used by (14)

  • BuoyancySystemVixen.Water.Physics
  • IWaterSurfaceVixen.Water
  • LakeVixen.Water.Physics.Tests
  • StillVixen.Water.Physics.Tests
  • SwellVixen.Water.Physics.Tests
  • UnderwaterRendererVixen.Rendering.Water
  • UnderwaterShapeVixen.Rendering.Water
  • WaterEvaluatorTestsVixen.Water.Tests
  • WaterZoneStateVixen.Water
  • WaterZoneSystemVixen.Rendering.Water
  • WaterZoneSystemTestsVixen.Rendering.Water.Tests
  • WaterZoneTestsVixen.Water.Tests
  • WaterPresenterVixen.Editor.App
  • WaterSceneRunsTestsVixen.Editor.Assets.Tests