Reset cutscene facing destination with original camera rotation handoff
This commit is contained in:
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>
|
||||
@@ -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
@@ -3,5 +3,6 @@
|
||||
<ItemGroup><Compile Include="Program.cs"/><Compile Include="../../src/GamePort/Assets/*.cs"/>
|
||||
<Compile Include="../../src/GamePort/Game/*.cs"/>
|
||||
<None Include="original-ground-reference.json" CopyToOutputDirectory="PreserveNewest"/>
|
||||
<None Include="../../tools/binary/jimmy_landing_rotation_reference.json" Link="original-landing-rotation-reference.json" CopyToOutputDirectory="PreserveNewest"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -25,5 +25,45 @@ var idle=JimmyGroundMotion.Input(new(100,130),90,default);Check(idle.State.Targe
|
||||
var fire=JimmyGroundMotion.Input(new(100,90),90,new(false,true,false,false,false,Fire:true),blockBackward:true);
|
||||
Check(fire.State.Speed==65&&!fire.HeadingUpdated,"source parent fire acceptance gate suppresses backward");
|
||||
Console.WriteLine("PASS heading publication and caller-owned backward/fire gate");
|
||||
using var landing = JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-landing-rotation-reference.json")));
|
||||
int trajectories = 0;
|
||||
foreach (var c in landing.RootElement.GetProperty("cases").EnumerateArray())
|
||||
{
|
||||
var initial = c.GetProperty("before");
|
||||
var current = Euler(initial,"current");
|
||||
var target = Euler(initial,"target");
|
||||
var dirty = initial.GetProperty("dirty").GetInt32()!=0;
|
||||
var input = new PlayerInput(c.GetProperty("up").GetInt32()!=0,false,c.GetProperty("left").GetInt32()!=0,false,false);
|
||||
var state = new JimmyGroundState(0,target.Y);
|
||||
for (var tick=0;tick<300;tick++)
|
||||
{
|
||||
var ground = JimmyGroundMotion.Input(state,current.Y,input);
|
||||
state = ground.State;
|
||||
if (ground.HeadingUpdated) { target=new(0,state.TargetYaw,0);dirty=true; }
|
||||
if (tick==0) Compare("after_input");
|
||||
var prior = current;
|
||||
current = JimmyOrientation.Step(current,target,1f/60,dirty:dirty);
|
||||
if (dirty) dirty=prior!=target;
|
||||
if (tick==0) Compare("after_facing");
|
||||
}
|
||||
Compare("after_300");
|
||||
trajectories++;
|
||||
|
||||
void Compare(string stage)
|
||||
{
|
||||
var expected=c.GetProperty(stage);
|
||||
var e=Euler(expected,"current");var t=Euler(expected,"target");
|
||||
Near(current.X,e.X,stage+" pitch");Near(current.Y,e.Y,stage+" yaw");Near(current.Z,e.Z,stage+" roll");
|
||||
Near(target.X,t.X,stage+" target pitch");Near(target.Y,t.Y,stage+" target yaw");Near(target.Z,t.Z,stage+" target roll");
|
||||
Check(dirty==(expected.GetProperty("dirty").GetInt32()!=0),stage+" dirty");
|
||||
}
|
||||
}
|
||||
Check(trajectories==7,"complete seven original grounded-input/facing trajectories");
|
||||
Console.WriteLine("PASS7 original grounded-input/facing trajectories: neutral destination retention, dirty ownership and active steering leveling");
|
||||
static Vector3 Euler(JsonElement state,string key)
|
||||
{
|
||||
var values=state.GetProperty(key).EnumerateArray().Select(v=>v.GetSingle()).ToArray();
|
||||
return new(values[0],values[1],values[2]);
|
||||
}
|
||||
static void Check(bool condition,string name){if(!condition)throw new Exception(name);}
|
||||
static void Near(float value,float expected,string name)=>Check(float.IsFinite(value)&&Math.Abs(value-expected)<.02f,$"{name}: {value} != {expected}");
|
||||
@@ -0,0 +1,43 @@
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools/binary'))
|
||||
from jimmy_cutscene_rotation import collect, REA_ID
|
||||
|
||||
|
||||
class JimmyCutsceneRotationTests(unittest.TestCase):
|
||||
def test_original_ranges_and_native_fixture_identity(self):
|
||||
source = collect(ROOT.parent / 'Original')
|
||||
reference = json.loads((ROOT / 'tests/GamePort.DirectorTests/original-camera-rotation-reference.json').read_text())
|
||||
self.assertEqual(source['source_sha256'], reference['source_sha256'])
|
||||
self.assertEqual(source['ranges'], reference['ranges'])
|
||||
self.assertEqual(reference['rea_evidence_id'], REA_ID)
|
||||
self.assertEqual(len(reference['cases']), 20)
|
||||
for rel, expected in reference['provenance_sha256'].items():
|
||||
if not rel.startswith('artifacts/'):
|
||||
self.assertEqual(hashlib.sha256((ROOT / rel).read_bytes()).hexdigest(), expected, rel)
|
||||
|
||||
def test_native_observations_cover_both_cameras_and_dirty_states(self):
|
||||
reference = json.loads((ROOT / 'tests/GamePort.DirectorTests/original-camera-rotation-reference.json').read_text())
|
||||
for kind in ('CAM', 'MCA'):
|
||||
for dirty in (0, 1):
|
||||
cases = [c for c in reference['cases'] if c['kind'] == kind and c['before']['dirty'] == dirty]
|
||||
self.assertEqual(len(cases), 5)
|
||||
for case in cases:
|
||||
before = case['before']
|
||||
prepared = case['prepared']
|
||||
self.assertNotEqual(before['current'], before['target'])
|
||||
self.assertNotEqual(before['current'][3], before['target'][3])
|
||||
self.assertEqual(prepared['dirty'], dirty)
|
||||
self.assertEqual(prepared['current'], prepared['target'])
|
||||
self.assertEqual(prepared['current'][1::2], before['current'][1::2])
|
||||
self.assertEqual(case['after_facing']['dirty'], 0)
|
||||
self.assertEqual(case['after_30'], case['after_facing'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,31 @@
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / 'tools/binary'))
|
||||
from jimmy_landing_rotation import collect
|
||||
|
||||
|
||||
class JimmyLandingRotationTests(unittest.TestCase):
|
||||
def test_source_and_saved_native_trajectory_provenance(self):
|
||||
reference = json.loads((ROOT / 'tools/binary/jimmy_landing_rotation_reference.json').read_text())
|
||||
for key, value in collect(ROOT.parent / 'Original').items():
|
||||
self.assertEqual(reference['source'][key], value, key)
|
||||
self.assertEqual(hashlib.sha256((ROOT / 'tools/binary/grappler_scalar_probe.c').read_bytes()).hexdigest(),
|
||||
reference['shared_harness_sha256'])
|
||||
self.assertEqual(reference['capture']['captures'][0]['wineExit'], 0)
|
||||
self.assertEqual(len(reference['cases']), 7)
|
||||
cases = {c['name']: c for c in reference['cases']}
|
||||
residual = cases['neutral_last_air_roll']
|
||||
self.assertEqual(residual['after_input']['target'], residual['before']['target'])
|
||||
self.assertEqual(residual['after_300']['current'][2], 355)
|
||||
for name in ('forward_levels', 'left_levels'):
|
||||
self.assertEqual(cases[name]['after_input']['target'][0::2], [0, 0])
|
||||
self.assertEqual(cases['clean_tilt_retained']['before'], cases['clean_tilt_retained']['after_300'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user