Zone.Update takes every previous position before placing any orbit

GetOrbitPosition places a parent as a side effect of placing its child, so with a child listed first the parent's previous position was already its new one and its Velocity came out zero. The constructor's unread PreviousPosition write is dropped; the first Update takes it from the placed Position. The velocity test now runs moon-first and planet-first packs over varying dt. Builds not verified yet (verify follows).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-14 21:19:09 +02:00
commit 205098ef93
2 changed files with 26 additions and 13 deletions

View file

@ -165,7 +165,7 @@ public class Zone
// when the zone is built, so each well, light and body pose read before the first Update is where the
// body is. Velocity stays zero until the first Update differences two placed positions.
foreach (var orbit in Orbits)
orbit.Value.PreviousPosition = GetOrbitPosition(orbit.Key);
GetOrbitPosition(orbit.Key);
foreach (var body in pack.Planets)
{
@ -276,9 +276,12 @@ public class Zone
{
_time += deltaTime;
_updatedOrbits.Clear();
// Every previous position is taken before any orbit is placed: GetOrbitPosition places a parent as a
// side effect of placing its child, so differencing inside one loop would depend on dictionary order.
foreach (var orbit in Orbits)
orbit.Value.PreviousPosition = orbit.Value.Position;
foreach (var orbit in Orbits)
{
orbit.Value.PreviousPosition = orbit.Value.Position;
orbit.Value.Position = GetOrbitPosition(orbit.Key);
orbit.Value.Velocity = (orbit.Value.Position - orbit.Value.PreviousPosition) / deltaTime;
}