Contacts: hull contact is between ships only; orbitals take no part

Step pairs OfType<Ship>; stations and turrets sit on the orbital layer above the ship plane
(ruling aetheria-gravity:orbitals-above-floaters-below). Tests: a ship flies through a station and a turret;
two ships still bounce beside an orbital. Not yet compile-verified (verified once at the cut's head).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-16 02:27:58 +02:00
commit 624d5420e9
2 changed files with 58 additions and 11 deletions

View file

@ -7,8 +7,9 @@ using CultMath;
using static CultMath.math;
using float2 = CultMath.float2;
// A hull touching a hull (aetheria-release cut sim-contact; ruling unity-presents-only-r3): the simulation owns
// contact between entities. Each hull is a disc about its centre of mass that bounds every occupied cell, and
// A ship touching a ship (aetheria-release cut sim-contact; ruling unity-presents-only-r3): the simulation owns
// contact between ships. Orbital entities (stations, turrets) sit on the orbital layer above the ship plane and floaters
// below it, so neither touches a ship (ruling aetheria-gravity:orbitals-above-floaters-below). Each hull is a disc about its centre of mass that bounds every occupied cell, and
// two discs that touch while closing along the line between their centres take the normal impulse
// j = -(1 + e)(v_rel . n) / (1/m1 + 1/m2) (ruling ship-bounce-restitution-setting): momentum is conserved, the
// result is frame-independent, and a pair that has separated is not bounced again. e is
@ -47,7 +48,7 @@ public static class Contacts
return far * e.ItemManager.GameplaySettings.SchematicCellSize;
}
// For each unordered pair of the zone's entities, in list order: if their discs touch and are closing along
// For each unordered pair of the zone's ships, in list order: if their discs touch and are closing along
// the normal, the impulse moves each one's velocity along the normal only (the tangent components are
// untouched), and the contact is published. Pairs resolve one after another in list order, each from the
// velocities the earlier pairs left, so a body touching two others in one tick depends on that order; the
@ -55,7 +56,7 @@ public static class Contacts
// are not hulls in the zone. No positional push-out.
public static void Step(Zone zone)
{
var entities = zone.Entities.Where(e => e.Active && e.Parent == null).ToArray();
var entities = zone.Entities.OfType<Ship>().Where(e => e.Active && e.Parent == null).ToArray();
var radii = entities.Select(Radius).ToArray();
for (var i = 0; i < entities.Length; i++)
for (var j = i + 1; j < entities.Length; j++)