Reset cutscene facing destination with original camera rotation handoff

This commit is contained in:
UnixNight committed 2026-11-05 15:44:25 -05:00
1 parent 7818cc8d64
commit dae13ace73
24 files changed
+2864 -9

No files matched your search

@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><EnableDefaultCompileItems>false</EnableDefaultCompileItems></PropertyGroup>
<ItemGroup><Compile Include="Program.cs"/><Compile Include="../../src/GamePort/Assets/*.cs"/><Compile Include="../../src/GamePort/Game/*.cs"/><Compile Include="../../src/GamePort/Application/PreviewCharacterPlacement.cs"/><Compile Include="../../src/GamePort/Application/SceneActorVisuals.cs"/><Compile Include="../../src/GamePort/Application/SceneSpriteVisuals.cs"/><Compile Include="../../src/GamePort/Application/StaticSceneVisuals.cs"/></ItemGroup>
<ItemGroup><None Include="original-camera-rotation-reference.json" CopyToOutputDirectory="PreserveNewest"/></ItemGroup>
</Project>
+80
View File
@@ -1,5 +1,6 @@
using System.Buffers.Binary;
using System.Numerics;
using System.Text.Json;
using GamePort.Assets;
using GamePort.Game;
using GamePort.Application;
@@ -200,6 +201,79 @@ foreach (var kind in new[] { "3CAM", "3MCA", "3AIT" })
}
Console.WriteLine("PASS ordered CAM/MCA/AI preparations, body continuation, raw-owner force override and held-input restoration");
foreach (var retained in new[] { false, true })
foreach (var dirty in new[] { false, true })
foreach (var kind in new[] { "3CAM", "3MCA" })
{
var scene = kind == "3MCA"
? new SceneDirector(level, new TaskStates(save.Tasks), (_, _) => 10)
: new SceneDirector(new("LV1B", [Entity("3JIM", "JIM1"),
Entity("3CAM", "camera", ("PlayerControlled", "NULL"), ("CameraTarget", "JIM1"),
("SoundDatabase", "voice"), ("SoundIndex", 1))]), new TaskStates([]), (_, _) => 10);
var body = ControlBody();
body.InputAfterPlayerUpdate = retained;
using var binding = new PlayerSceneBinding(scene, body, new SceneInventory(new int[19]), "JIM1");
if (dirty)
{
for (var tick = 0; tick < 8; tick++) binding.Step(new(true, false, true, false, true));
Check(!body.Grounded && body.FacingDirty && body.FacingTarget.X < 0 && body.FacingTarget.Z < 0,
"Cutscene regression enters with a real banked jump and pending airborne destination");
}
// A direct authored yaw must replace the old destination Y at preparation too.
body.ApplyAuthoredTransform(body.ActorRoot, new Vector3(345, body.Yaw + 37, 12));
scene.SyncActor("JIM1", body.ActorRoot, body.Rotation);
var yaw = body.Yaw;
var controllers = body.ControllerSteps;
var physics = body.PhysicsSteps;
var impulse = body.PendingImpulse;
scene.Trigger(kind == "3MCA" ? "neutron1a" : "camera");
Near(body.Rotation, new(0, yaw, 0), "Camera preparation levels current Euler immediately");
Near(body.FacingTarget, new(0, yaw, 0), "Camera preparation also replaces every pending destination axis");
Check(body.FacingDirty == dirty && body.PendingImpulse == impulse && !scene.Controlled,
"Direct destination copy preserves facing dirty, queued impulse and source control lock");
for (var tick = 0; tick < 120; tick++)
{
binding.Step(new(true, false, true, false, true));
Near(body.Rotation, new(0, yaw, 0), "Uncontrolled facing cannot restore the old jump tilt or yaw");
Near(scene.FindActor("JIM1")!.Rotation, body.Rotation, "Director and rendered player share the prepared rotation");
}
Check(!body.FacingDirty && body.ControllerSteps == controllers && body.PhysicsSteps == physics + 120,
"Facing clears equal targets while locked body updates continue without player input");
}
Console.WriteLine("PASS CAM and original Carl MCA banked-jump preparation, destination yaw/dirty ownership and sustained control lock");
using (var reference = JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "original-camera-rotation-reference.json"))))
{
var cases = 0;
foreach (var observation in reference.RootElement.GetProperty("cases").EnumerateArray())
{
var initialOrientation = observation.GetProperty("before");
var dirty = initialOrientation.GetProperty("dirty").GetInt32() != 0;
var body = ControlBody();
if (dirty) body.Step(new(true, false, true, false, false));
//Camera preparation ignores the old target; actual banked-target
//ownership and the full scene callback chain are exercised above.
body.ApplyAuthoredTransform(body.ActorRoot, Euler(initialOrientation, "current"));
body.FlattenOrientation();
Compare("prepared");
body.Step(default, controlled: false);
Compare("after_facing");
for (var tick = 1; tick < 30; tick++) body.Step(default, controlled: false);
Compare("after_30");
cases++;
void Compare(string stage)
{
var expected = observation.GetProperty(stage);
Near(body.Rotation, Euler(expected, "current"), "Copied-original camera current XYZ: " + stage);
Near(body.FacingTarget, Euler(expected, "target"), "Copied-original camera destination XYZ: " + stage);
Check(body.FacingDirty == (expected.GetProperty("dirty").GetInt32() != 0), "Copied-original camera dirty: " + stage);
}
}
Check(cases == 20, "Complete original CAM/MCA camera rotation reference");
}
Console.WriteLine("PASS 20 copied-original camera preparation/facing XYZ and dirty outputs, including wrapped and negative Euler");
{
var jim = Entity("3JIM", "JIM1");
var command = Entity("3AIT", "move", ("PlayerControlled", "NULL"), ("AITarget", "JIM1"),
@@ -371,6 +445,12 @@ static LabSimulation ControlBody()
return new(new SceneCollision(floor), standing, new(0, 25, 0), 0);
}
static Vector3 Euler(JsonElement state, string property)
{
var values = state.GetProperty(property).EnumerateArray().Select(v => v.GetSingle()).ToArray();
return new(values[0], values[1], values[2]);
}
static GamEntity Entity(string kind,string tag,params (string Name,object Value)[] values)
{
var properties=new Dictionary<string,GamProperty>();
File diff suppressed because it is too large. Load diff