Skip to main content

crcbl_phys/
wind.rs

1//! The seam physics reads moving air through.
2//!
3//! `docs/plan/56-wind.md`'s decision 6: "`crcbl-phys` defines a [`WindQuery`]
4//! trait that `crcbl-wind` implements, the same arrangement as
5//! `docs/plan/55-water.md`'s `WaterQuery`, **so physics does not depend on the
6//! wind crate**." The arrow runs the other way round from the one a reader
7//! expects, and that is the whole point: the crate with the bodies in it must
8//! not have to link the crate with the weather in it, or a server simulating a
9//! room ends up carrying two authored texture layers to answer a question it
10//! never asks.
11//!
12//! # Why the trait is here and empty of implementations
13//!
14//! There is no implementation in this crate, and there is not going to be a
15//! `StillAir` one either: still air is what every force provider in
16//! [`crate::forces`] and [`crate::atmosphere`] already assumes, so a type that
17//! answers zero would be a second way of saying what "no wind provider" says.
18//!
19//! # What reads it
20//!
21//! Nothing yet. `docs/plan/56-wind.md`'s rung W4 is the rigid-body wind drag —
22//! quadratic drag on `v_rel = w − v` with a per-body drag coefficient and
23//! projected area, limited to the linearised implicit update so it never
24//! reverses the relative velocity — and it needs two `crcbl-phys` prerequisites
25//! that do not exist yet: rigid-body rotation, and per-body medium properties.
26//! W1 builds the seam and the field; the provider that joins them is W4's.
27
28use glam::DVec3;
29
30/// What the air is doing at a point, right now.
31///
32/// The one question physics asks the wind. It is a **velocity**, in metres per
33/// second, in world space — not a force and not a direction-and-speed pair,
34/// because what a drag model needs is `w − v` and every other shape would have
35/// the caller rebuild that.
36///
37/// Implementations are expected to be pure: the same position at the same tick
38/// answers the same velocity, bit for bit. `crcbl-wind`'s field is, and its
39/// determinism test is what says so.
40pub trait WindQuery: std::fmt::Debug {
41    /// The wind velocity at a world-space position, in m/s.
42    fn wind_at(&self, position: DVec3) -> DVec3;
43}