Gravity: one potential per zone owns acceleration and height

GravityField is the law of one well (logarithmic tail, softened core).
Zone.GetForce and GetHeight sum it over the bodies; GetNormal derives from
the force for ship tilt; Flow and Ship read GetForce. Well strength, core
radius and Roche limit are PlanetSettings curves of mass, height
exaggeration K one global. Deletes GravityAcceleration, GravityReferenceRate,
GravityStrength, the PowerPulse well, GetNormal's finite differences and
BodyData.GravityDepthExponent. Settings.asset carries the calibrated curves.
Tests: PotentialOwnerTests, the moon's moon placement, retired keys over every
BodyData type, a body-derived giant sweep. Not yet built or run (verify job
follows); this commit may not build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-15 04:36:28 +02:00
commit 021c4cbcbf
16 changed files with 433 additions and 171 deletions

View file

@ -1,20 +1,21 @@
using CultMath;
using GameCult.Caching;
// The one fixture that gives a test zone a slope: a single body on a parentless orbit at the origin, with
// the curves a body needs. Gravity height is the sum of body wells, so a test that wants ground to slide on
// digs it here and nowhere else. `radius` is the zone radius the well is sized to (its well reaches 2 x radius,
// as the former bowl did); the well is deepest at the centre and zero at and beyond half its radius.
// The one fixture that gives a test zone a slope: a body on a parentless orbit (the origin unless `at` says otherwise; call again for more bodies), with the
// curves a body needs. Gravity is the sum of body wells (GravityField), so a test that wants ground to slide on
// digs it here and nowhere else. `strength` is the well's c (u^2/s^2) and `coreRadius` its softened core in u; the
// Roche limit curve sits at 2.5 cores so the body is a valid well.
internal static class WellFixture
{
public static void Dig(CultCache cache, ZonePack pack, PlanetSettings settings, float radius, float depth, float exponent)
public static void Dig(CultCache cache, ZonePack pack, PlanetSettings settings, float strength, float coreRadius, float2 at = default)
{
settings.BodyRadius = new ExponentialCurve();
settings.OrbitPeriod = new ExponentialCurve();
settings.GravityRadius = new ExponentialCurve { Constant = 2f * radius };
settings.GravityDepth = new ExponentialCurve { Constant = depth };
var orbit = cache.Upsert(new OrbitData { FixedPosition = float2.zero }).Key;
var body = cache.Upsert(new PlanetData { Orbit = new CultRecordRef<OrbitData>(orbit), GravityDepthExponent = exponent }).Key;
settings.WellStrength = new ExponentialCurve { Constant = strength };
settings.CoreRadius = new ExponentialCurve { Constant = coreRadius };
settings.RocheLimit = new ExponentialCurve { Constant = 2.5f * coreRadius };
var orbit = cache.Upsert(new OrbitData { FixedPosition = at }).Key;
var body = cache.Upsert(new PlanetData { Name = $"Well {at.x},{at.y}", Orbit = new CultRecordRef<OrbitData>(orbit) }).Key;
pack.Orbits.Add(new CultRecordRef<OrbitData>(orbit));
pack.Planets.Add(new CultRecordRef<BodyData>(body));
}