Expand description
Spatial force fields (gravity wells, vortex, wind, explosion). Spatial force-field system for applying continuous forces to rigid bodies.
Force fields generate a force vector as a function of world-space position
and simulation time. Multiple fields can be stacked; the
ForceFieldSystem accumulates them and applies the result to any body
that lies within each field’s optional bounding region.
§Available field kinds
| Kind | Description |
|---|---|
Uniform | Constant force independent of position |
RadialAttract | Inverse-power attraction toward a point |
RadialRepel | Inverse-power repulsion away from a point |
Vortex | Tangential rotation around an axis |
Wind | Directional wind with optional drag scaling |
Explosion | Expanding pressure wave from an origin point |
Turbulent | Deterministic pseudo-random perturbation |
§Example
use oxiphysics::force_field::{ForceFieldKind, ForceFieldSystem};
let mut sys = ForceFieldSystem::new();
// Gravity-like field pulling toward origin
sys.add(ForceFieldKind::RadialAttract {
center: [0.0, 0.0, 0.0],
strength: 9.81,
falloff_exp: 2.0,
});
// Wind pushing in +X
sys.add(ForceFieldKind::Wind {
direction: [1.0, 0.0, 0.0],
base_speed: 5.0,
});
let f = sys.force_at([1.0, 1.0, 1.0], 0.0);
assert!(f[0].is_finite()); // wind contributionStructs§
- Aabb
Region - Axis-aligned bounding box that restricts a field to a region.
- Force
Field Entry - A single registered force field with its metadata.
- Force
Field System - Manages a collection of
ForceFieldEntryinstances and computes the combined force at any world-space position.
Enums§
- Force
Field Kind - Describes the mathematical model of a force field.