Sim speed fix: scripted poses are not drawn ahead; a step cannot reset its clock; DrawAhead.Time deleted
DrawAhead leaves a ship in a wormhole animation where the step put it. The clock is one static instance; a zone entered inside a step ends that frame's stepping and the clock resets between frames (SimClock.Reset throws inside Advance). DrawAhead.Time had no consumer. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cff4e0ffa7
commit
257a8a4795
4 changed files with 68 additions and 14 deletions
|
|
@ -77,6 +77,18 @@ public sealed class SimClockTests
|
|||
Assert.Equal(6, clock.Steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AStepCannotResetItsClock()
|
||||
{
|
||||
var clock = new SimClock(1f / 60f);
|
||||
Assert.Throws<InvalidOperationException>(() => clock.Advance(1f / 60f, _ => clock.Reset()));
|
||||
clock.Advance(.005f, _ => { });
|
||||
Assert.True(clock.Lead > 0);
|
||||
clock.Reset();
|
||||
Assert.Equal(0f, clock.Lead);
|
||||
Assert.Equal(1, clock.Advance(1f / 60f, _ => { }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PauseFeedsNothing()
|
||||
{
|
||||
|
|
@ -252,10 +264,30 @@ public sealed partial class RunStartTests
|
|||
Assert.Equal(player.Position.x + player.Velocity.x * lead, ahead.x, 6);
|
||||
Assert.Equal(player.Position.y, ahead.y);
|
||||
Assert.Equal(player.Position.z + player.Velocity.y * lead, ahead.z, 6);
|
||||
Assert.Equal(arena.Time + lead, DrawAhead.Time(arena, lead));
|
||||
Assert.Equal(before, Snapshot(arena, new List<string>()));
|
||||
}
|
||||
|
||||
// A pose the step scripts (the wormhole animation) is drawn where the step put it, at any lead.
|
||||
[Fact]
|
||||
public void ScriptedPosesAreNotDrawnAhead()
|
||||
{
|
||||
var (arena, player) = LaunchDuel();
|
||||
for (var step = 0; step < 120; step++) arena.Update(ClockFrame);
|
||||
player.EnterWormhole(player.Position.xz + float2(50, 0));
|
||||
arena.Update(ClockFrame);
|
||||
Assert.True(player.WormholeAnimationInProgress);
|
||||
Assert.True(length(player.Velocity) > .01f, "the ship carries speed into the animation");
|
||||
var position = DrawAhead.Position(player, ClockFrame);
|
||||
Assert.Equal(player.Position.x, position.x);
|
||||
Assert.Equal(player.Position.y, position.y);
|
||||
Assert.Equal(player.Position.z, position.z);
|
||||
var rotation = DrawAhead.Rotation(player, ClockFrame);
|
||||
Assert.Equal(player.Rotation.x, rotation.x);
|
||||
Assert.Equal(player.Rotation.y, rotation.y);
|
||||
Assert.Equal(player.Rotation.z, rotation.z);
|
||||
Assert.Equal(player.Rotation.w, rotation.w);
|
||||
}
|
||||
|
||||
// The turn a presenter draws ahead is the turn the next step makes: a ship held in a steady turn, drawn one whole
|
||||
// step ahead of the pose it was last given, is where the sim puts that pose next.
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in a new issue