checkpoint: preserve user-gated FW closeout fixes

This commit is contained in:
Erik 2026-08-31 08:27:37 +02:00
parent a2f2eb7d78
commit b8befded8b
22 changed files with 1005 additions and 198 deletions

View file

@ -128,4 +128,49 @@ public sealed class WalkProductionFrameContextTests
new CellVisibility(), new WalkBuildingRegistry(), Vector3.Zero, Vector3.UnitY,
default, 1024f, 768f));
}
[Fact]
public void Reset_RebindsCameraValuesAndRetainsTheRayCaster()
{
Matrix4x4 firstProjection = SimpleViewProjection();
var ctx = new WalkProductionFrameContext(
new CellVisibility(), new WalkBuildingRegistry(), Vector3.Zero, Vector3.UnitY,
firstProjection, 1024f, 768f);
IWalkRayCaster retainedRays = ctx.Rays;
var eye = new Vector3(4f, 5f, 6f);
Vector3 forward = Vector3.UnitX;
Matrix4x4 secondProjection =
Matrix4x4.CreateLookAt(eye, eye + forward, Vector3.UnitZ)
* Matrix4x4.CreatePerspectiveFieldOfView(MathF.PI / 4f, 16f / 9f, 0.1f, 500f);
ctx.Reset(eye, forward, secondProjection, 1760f, 990f);
Assert.Same(retainedRays, ctx.Rays);
Assert.Equal(eye, ctx.WorldViewpoint);
Assert.Equal(1760f, ctx.ViewportWidth);
Assert.Equal(990f, ctx.ViewportHeight);
Assert.Equal(forward, ctx.CyPlane.Normal);
Assert.Equal(-Vector3.Dot(eye, forward) - WalkProductionFrameContext.ZNear, ctx.CyPlane.D);
}
[Fact]
public void Reset_WithBadProjectionLeavesThePreviousBindingUsable()
{
Matrix4x4 projection = SimpleViewProjection();
var eye = new Vector3(1f, 2f, 3f);
var ctx = new WalkProductionFrameContext(
new CellVisibility(), new WalkBuildingRegistry(), eye, Vector3.UnitY,
projection, 1024f, 768f);
Vector3 rayBeforeFailure = ctx.Rays.RayThrough(200f, 300f);
Assert.Throws<ArgumentException>(() =>
ctx.Reset(new Vector3(9f), Vector3.UnitX, default, 1f, 1f));
Assert.Equal(eye, ctx.WorldViewpoint);
Assert.Equal(1024f, ctx.ViewportWidth);
Assert.Equal(768f, ctx.ViewportHeight);
Assert.Equal(Vector3.UnitY, ctx.CyPlane.Normal);
Assert.Equal(rayBeforeFailure, ctx.Rays.RayThrough(200f, 300f));
}
}