Recover sphere response and correct Jimmy ceiling cancellation

This commit is contained in:
UnixNight committed 2026-10-26 16:09:19 -04:00
1 parent 6a7a53c90d
commit 57dfcc64bb
37 files changed
+1324 -18

No files matched your search

+69 -2
View File
@@ -12,6 +12,7 @@ var tests = new (string Name, Action Check)[]
("ordinary route load retains scalars independently of body/jump reset", RetainedLevelState),
("script preparation preserves queued work and uncontrolled physics consumes it", UncontrolledPhysics),
("uncontrolled fire ticks while movement and grounded-release reset are gated", UncontrolledFire),
("source root ceiling ray bounces and cancels before control ownership", CeilingWrapper),
("source camera query origin, hit adjustment, gain and one query per input", CameraQueryConsumer),
("debug noclip bypasses walls/gravity/camera and exits without queued motion", Noclip),
("turn-only speed, forward acceleration/cap and release", SpeedLimits),
@@ -191,6 +192,61 @@ static void RetainedLevelState()
Throws<ArgumentOutOfRangeException>(() => grounded.ApplyRetainedLevelState(state with { EffectRemaining = float.PositiveInfinity }));
}
static void CeilingWrapper()
{
var queries = 0;
var start = Vector3.Zero; var end = Vector3.Zero;
SupportHit? Ceiling(Vector3 a, Vector3 b)
{ queries++; start = a; end = b; return new((a + b) / 2, 1, 2, 75); }
var jump = new PlayerInput(false, false, false, false, true);
var simulation = FlatSimulation(ceilingRay: Ceiling);
simulation.Step(jump);
Check(queries == 0 && simulation.PendingImpulse.Y == 550, "Queued impulse is not upward velocity yet");
simulation.ApplyRetainedLevelState(new("LV1B", 3, 1, .625f, 6.125f));
var energy = simulation.Energy;
simulation.Step(jump, controlled: false);
NearVector(start, simulation.ActorRoot, .0001f, "Upward query uses post-physics actor root");
NearVector(end - start, Vector3.UnitY * 150, 0, "Upward ray uses authored150 span");
Check(simulation.Velocity.Y < -300 && simulation.CeilingHits == 1, "Original0.6 velocity reflection");
Check(simulation.ControllerSteps == 1 && simulation.MovementMode == 1 && simulation.JumpState == 0,
"Ceiling cancellation runs without controlled movement");
Near(simulation.JumpHoldSeconds, .625f, 0, "Cancellation preserves hold");
Near(simulation.JetpackRemaining, -FixedStepClock.Step, 0, "Fire ticks after cancellation zero");
Near(simulation.Energy, energy, 0, "Cancelled fire does not drain energy");
Check(simulation.Pose == PlayerPose.Fall && simulation.PendingImpulse == Vector3.Zero,
"FALL request and independent impulse consumption");
simulation.Step(default, controlled: false);
Check(queries == 1, "Non-upward velocity makes no ceiling query");
var otherMode = FlatSimulation(ceilingRay: Ceiling);
otherMode.Step(jump);
otherMode.ApplyRetainedLevelState(new("LV1B", 3, 0, .625f, 6.125f));
otherMode.Step(default, controlled: false);
Check(otherMode.Velocity.Y < 0 && otherMode.MovementMode == 0 && otherMode.JetpackRemaining > 6,
"Mode0 still reflects velocity but skips mode1 cancellation");
var hit = false;
var powered = FlatSimulation(ceilingRay: (a,b) => hit ? new SupportHit((a+b)/2, 1, 2, 75) : null);
powered.JetpackInventoryState = () => 1; powered.GadgetMode = 3;
for (var i = 0; i < 40; i++) powered.Step(jump);
Check(powered.JumpState == 3 && powered.JetpackRemaining > 0 && powered.Velocity.Y > 0,
"Powered ceiling fixture has active jump/fire");
hit = true; powered.Step(default, controlled: false);
Check(powered.Velocity.Y <= -85 && powered.JumpState == 0 && powered.JetpackRemaining < 0,
"Ceiling cancels an active powered burst while uncontrolled");
foreach (var retained in new[] { false, true })
{
var phases = new List<string>();
var ordered = FlatSimulation(cameraRay: (a,b) => { phases.Add("input"); return null; },
ceilingRay: (a,b) => { phases.Add("wrapper"); return null; });
ordered.InputAfterPlayerUpdate = retained;
ordered.Step(jump); phases.Clear(); ordered.Step(jump);
Check(phases.SequenceEqual(retained ? ["wrapper", "input"] : new[] { "input", "wrapper" }),
"Wrapper belongs to Jimmy callback between fresh/retained input boundaries");
}
}
static void CameraQueryConsumer()
{
var enabled = false;
@@ -584,9 +640,20 @@ static void OriginalLab(string project, string originals)
for (var i = 0; i < 120; i++) simulation.Step(default);
Check(simulation.Jumps == 1 && simulation.Landings == 1 && simulation.Grounded, "stationary original-lab jump lands once");
Near(simulation.Position.Y, .5486332f + SceneCollision.Skin, .03f, "original lab jump returns to floor");
var geometry = OriginalCameraRay.FromRouteScene(mesh, level.Code);
var overhead = new LabSimulation(collision, standing, start.Position, start.Rotation.Y,
(a,b) => geometry.Trace(a,b), (a,b) => geometry.TraceGeometry(a,b));
overhead.Step(new(false, false, false, false, true));
overhead.RestoreReturnRoot(overhead.ActorRoot + Vector3.UnitY * 300);
geometry.Enabled = false; // Modern camera-only switch must not suppress physical query.
overhead.Step(default, controlled: false);
Check(overhead.CeilingHits == 1 && overhead.Velocity.Y <= -85 && overhead.Pose == PlayerPose.Fall,
"Actual registered lab ceiling reverses upward motion with camera debug query disabled");
}
static LabSimulation FlatSimulation(float yaw = 0, Func<Vector3, Vector3, SupportHit?>? cameraRay = null)
static LabSimulation FlatSimulation(float yaw = 0, Func<Vector3, Vector3, SupportHit?>? cameraRay = null,
Func<Vector3, Vector3, SupportHit?>? ceilingRay = null)
{
var positions = new[]
{
@@ -596,7 +663,7 @@ static LabSimulation FlatSimulation(float yaw = 0, Func<Vector3, Vector3, Suppor
var floor = new Mesh(positions.Select(p => new MeshVertex(p, Vector2.Zero, Vector3.One)).ToArray(), [0, 1, 2, 3, 4, 5]);
var standing = new Mesh([new(new(-20, -20, -20), Vector2.Zero, Vector3.One),
new(new(20, 80, 20), Vector2.Zero, Vector3.One)], []);
return new LabSimulation(new SceneCollision(floor), standing, new Vector3(0, 25, 0), yaw, cameraRay);
return new LabSimulation(new SceneCollision(floor), standing, new Vector3(0, 25, 0), yaw, cameraRay, ceilingRay);
}
static void SameState(LabSimulation actual, LabSimulation expected, string message)