Envelope from columns: Ship.RecalculateEnvelope sums the thruster columns' box extremes; Thruster.Manoeuvre and TorqueFloor deleted

Unverified at this commit (first build still to run); ceiling test not yet restored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-11 00:14:31 +02:00
commit db3103a026
5 changed files with 67 additions and 33 deletions

View file

@ -102,29 +102,6 @@ public class Thruster : Behavior, IPowerConsumer
// under brownout is an inconvenience, not the cascading failure a starved radiator or shield causes.
public int DefaultPowerTier => PowerTiers.Medium;
// What this thruster adds to the ship's manoeuvre envelope: Execute's own arithmetic at full input, read live.
// Its push is Thrust / Mass along its mount, into the matching body
// axis, even for a flank thruster that only turns (it pushes whenever it turns); its turn is |Torque| * Thrust *
// TorqueMultiplier / Mass into the side its Torque sign fires on, when |Torque| clears the floor. Zero when the
// item is offline or unpowered, the same gates Execute applies.
public ManoeuvreEnvelope Manoeuvre()
{
if (Item == null || !Item.Active.Value || Item.PowerSupply <= 1e-4f) return default;
var settings = ItemManager.GameplaySettings;
var thrust = Thrust;
var acceleration = thrust / Entity.Mass;
var forward = normalize(Entity.Direction);
var right = forward.Rotate(ItemRotation.Clockwise);
var push = -forward.Rotate(Item.EquippableItem.Rotation);
var along = dot(push, forward);
var across = dot(push, right);
var turn = abs(Torque) > settings.TorqueFloor ? abs(Torque) * thrust * settings.TorqueMultiplier / Entity.Mass : 0f;
return new ManoeuvreEnvelope(
max(along, 0f) * acceleration, max(-along, 0f) * acceleration,
max(-across, 0f) * acceleration, max(across, 0f) * acceleration,
Torque > 0f ? turn : 0f, Torque < 0f ? turn : 0f);
}
public override bool Execute(float dt)
{
Item.SetAudioParameter(SpecialAudioParameter.Intensity, _input);

View file

@ -211,7 +211,6 @@ public class GameplaySettings
public float LockIndicatorNoiseAmplitude = 50f;
public ExponentialLerp LockIndicatorFrequency;
public ExponentialLerp LockSpinSpeed;
public float TorqueFloor;
public float TorqueMultiplier;
public float VisibilityDecay;
public float TargetInfoDecay;

View file

@ -84,15 +84,25 @@ public class Ship : Entity
#region ThrustCalculation
// What this ship can do at this instant (see ManoeuvreEnvelope): the sum of what each live propulsor reports with
// its own Execute arithmetic; thrusters are its only propulsors. Derived each update, never saved.
// What this ship can do at this instant (see ManoeuvreEnvelope): the box extremes of the thrusters' columns at their
// live, granted thrust (zero when unpowered or not Active), the same columns the allocator solves with. Derived each
// update, never saved.
public ManoeuvreEnvelope Envelope { get; private set; }
private void RecalculateEnvelope()
{
var envelope = default(ManoeuvreEnvelope);
foreach (var thruster in _allThrusters) envelope += thruster.Manoeuvre();
Envelope = envelope;
float forward = 0, back = 0, left = 0, right = 0, clockwise = 0, counterClockwise = 0;
foreach (var thruster in _allThrusters)
{
var column = thruster.Column(thruster.Item != null && thruster.Item.PowerSupply > 1e-4f ? thruster.Thrust : 0f);
forward += max(column.y, 0f);
back += max(-column.y, 0f);
left += max(-column.x, 0f);
right += max(column.x, 0f);
clockwise += max(column.z, 0f);
counterClockwise += max(-column.z, 0f);
}
Envelope = new ManoeuvreEnvelope(forward, back, left, right, clockwise, counterClockwise);
}
#endregion