A drawn ship rides the field at its drawn xz
DrawAhead moved xz ahead but carried the last step's y, so on a slope the ship's height stepped once per sim tick. Entity.RideHeight is the one owner of 'an unparented entity sits on the field'; the step and DrawAhead both call it. A child is drawn where its parent is drawn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8f491fd3c9
commit
105f0270eb
4 changed files with 40 additions and 8 deletions
|
|
@ -7,17 +7,22 @@ using static CultMath.math;
|
|||
|
||||
// Pure presentation statics over sim state, never called by ServerShared, with no state of their own: the sim owns every
|
||||
// pose and no presenter stores one, a previous state or a velocity of its own. Ships are drawn where the frame falls Lead
|
||||
// sim seconds after the last step, by their last step's velocity and turn. A ballistic round's flight is presentation
|
||||
// sim seconds after the last step, by their last step's velocity and turn, and ride the field at that drawn xz (a ship's height is the field's there, not
|
||||
// the last step's). A ballistic round's flight is presentation
|
||||
// (ruling projectile-flight-is-presentation), drawn from the sim's facts: its frozen line, the published outcome, the
|
||||
// commit tick, the impact cell on the target's drawn pose, the burst point.
|
||||
public static class DrawAhead
|
||||
{
|
||||
// A ship in a wormhole animation has its pose scripted by the step, not integrated from Velocity and TurnRate,
|
||||
// so it is drawn where the step put it: extrapolating a scripted pose draws a streak that resets every step.
|
||||
public static float3 Position(Entity entity, float lead) =>
|
||||
entity is Ship { WormholeAnimationInProgress: true }
|
||||
? entity.Position
|
||||
: entity.Position + float3(entity.Velocity.x, 0, entity.Velocity.y) * lead;
|
||||
// A child is drawn where its parent is drawn, as the step copies the parent's pose onto it.
|
||||
public static float3 Position(Entity entity, float lead)
|
||||
{
|
||||
if (entity is Ship { WormholeAnimationInProgress: true }) return entity.Position;
|
||||
if (entity.Parent != null) return Position(entity.Parent, lead);
|
||||
var planar = entity.Position.xz + entity.Velocity * lead;
|
||||
return float3(planar.x, entity.RideHeight(planar), planar.y);
|
||||
}
|
||||
|
||||
// A free body (a vapour cloud) drawn where the frame falls lead sim seconds after the last step, by the velocity
|
||||
// that step moved it with: the launch velocity and the drift together.
|
||||
|
|
|
|||
|
|
@ -1770,7 +1770,6 @@ public abstract class Entity
|
|||
|
||||
var velocityBefore = Velocity;
|
||||
LimitClamp = float2(0, 0);
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
|
||||
// Mining Cut 3: a chunk target is lost the moment this entity can no longer see it -- the lost-track rule
|
||||
// through the chunk path. One check of the one slot per tick, not a detection loop over chunks.
|
||||
|
|
@ -1890,12 +1889,16 @@ public abstract class Entity
|
|||
Position = Parent.Position;
|
||||
Velocity = Parent.Velocity;
|
||||
}
|
||||
else Position.y = Zone.GetHeight(Position.xz) + hullData.GridOffset;
|
||||
else Position.y = RideHeight(Position.xz);
|
||||
|
||||
Acceleration = delta > 0f ? (Velocity + LimitClamp - velocityBefore) / delta : float2(0, 0);
|
||||
Manoeuvre.Observe(Acceleration, delta, ItemManager.GameplaySettings.SolutionWindow);
|
||||
}
|
||||
|
||||
// Where an unparented entity sits on the field at a planar point: the zone's height there plus the hull's grid offset.
|
||||
// The step puts the entity here at its own xz, and the presenter at its drawn xz (DrawAhead).
|
||||
public float RideHeight(float2 planar) => Zone.GetHeight(planar) + (ItemManager.GetData(Hull) as HullData).GridOffset;
|
||||
|
||||
private void UpdateTemperature(float delta)
|
||||
{
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
|
|
|
|||
|
|
@ -380,6 +380,30 @@ public sealed class FireControlTests : IDisposable
|
|||
// height, so its distance in space is longer than its planar distance. A claim whose Range lies between the two, full
|
||||
// damage out to the planar distance, is in range on the plane and out of range in space: it (against Slug's 5) is the
|
||||
// chosen claim. Mutation: Combat measures the three-dimensional distance (the claim then reads 0).
|
||||
// B32: a ship drawn ahead rides the field at its drawn xz, not at the height of its last step (the per-step height
|
||||
// staircase that read as jitter on a steep slope). Mutation: DrawAhead's y back to entity.Position.y fails the first
|
||||
// assertion; reading the height at the last step's xz fails it too.
|
||||
[Fact]
|
||||
public void ADrawnShipRidesTheFieldAtItsDrawnPosition()
|
||||
{
|
||||
var (_, ship, _) = BuildShipWithHardpoints(true, new[] { (ItemRotation.None, 0f) });
|
||||
var zone = ship.Zone;
|
||||
ship.Position = float3(200, 0, 0);
|
||||
zone.Update(1f);
|
||||
ship.Velocity = float2(100, 0); // up the slope, away from the well
|
||||
const float lead = .1f;
|
||||
|
||||
var drawn = DrawAhead.Position(ship, lead);
|
||||
|
||||
Assert.Equal(ship.Position.x + 100 * lead, drawn.x, 4);
|
||||
Assert.Equal(zone.GetHeight(float2(drawn.x, drawn.z)) + ((HullData) ship.ItemManager.GetData(ship.Hull)).GridOffset, drawn.y, 4);
|
||||
Assert.True(abs(drawn.y - ship.Position.y) > .1f, "the slope is real: the drawn height differs from the last step's");
|
||||
var still = DrawAhead.Position(ship, 0f);
|
||||
Assert.Equal(ship.Position.x, still.x);
|
||||
Assert.Equal(ship.Position.y, still.y);
|
||||
Assert.Equal(ship.Position.z, still.z);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheAIMeasuresTheTargetOnTheGroundPlane()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ public sealed partial class RunStartTests
|
|||
const float lead = .007f;
|
||||
var ahead = DrawAhead.Position(player, lead);
|
||||
Assert.Equal(player.Position.x + player.Velocity.x * lead, ahead.x, 6);
|
||||
Assert.Equal(player.Position.y, ahead.y);
|
||||
Assert.Equal(player.RideHeight(float2(ahead.x, ahead.z)), ahead.y, 4);
|
||||
Assert.Equal(player.Position.z + player.Velocity.y * lead, ahead.z, 6);
|
||||
Assert.Equal(before, Snapshot(arena, new List<string>()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue