Restore Goddard leveling and Scooter positional pitch processing

This commit is contained in:
UnixNight committed 2026-11-04 18:27:56 -05:00
1 parent 74be19eb15
commit fccc0b9d1b
24 files changed
+967 -8

No files matched your search

+31
View File
@@ -15,6 +15,8 @@ var tests=new(string,Action)[]{("copied-original drive/input/facing/terrain obse
("actual tutorial RETURN accepts the passenger and cleans vehicle",Return),
("original vehicle/wheel/rider geometry stays unit scale",Visuals),
("outside companion follows, freezes while summoned, and returns near Jimmy",Companion),
("tilted dismount preserves handoff then Goddard gradually levels",DismountTilt),
("copied-original Goddard leveling rates and seams",GoddardOriginal),
};
foreach(var(name,test)in tests){test();Console.WriteLine("PASS "+name);}Console.WriteLine($"Scooter integration: {tests.Length} groups passed.");
static void Original()
@@ -132,6 +134,35 @@ static void Companion()
NearV(dog.Position,jimmy.Position+RocketOrientation.Rotate(new(0,0,-800),jimmy.Rotation),"far follow warp");
f.D.EnsureCompanion(jimmy.Position,Vector3.Zero);NearV(dog.Position,jimmy.Position,"explicit reset placement updates existing actor");
}
static void DismountTilt()
{
using var f=new Fixture("VR05");var dog=f.D.FindActor("C3DGODDARD")!;
var patrol=new ActorPatrol(dog,f.D.FindActor,(b,_)=>b){FollowPlayer=true};
f.Summon();f.Mount();
for(int i=0;i<20;i++)f.Frame(new(true,false,true,false,false));
var rotation=f.S.Rotation;Check(Math.Abs(rotation.Z)>10,"actual steering produces vehicle lean");
f.I.Inventory.SelectGadget(-1);NearV(dog.Rotation,rotation,"cleanup copies full source Euler");
static float Tilt(float degrees)=>MathF.Abs((degrees+540)%360-180);
float before=Tilt(dog.Rotation.Z);patrol.Step(.1f);
Check(Tilt(dog.Rotation.Z)<before&&Tilt(dog.Rotation.Z)>before*.9f,"leveling is gradual in next AI phase");
for(int i=0;i<300;i++)patrol.Step(FixedStepClock.Step);
Check(Tilt(dog.Rotation.Z)<before*.25f,"companion does not retain scooter lean");
dog.MovementEnabled=false;rotation=dog.Rotation;patrol.Step(.1f);Check(dog.Rotation==rotation,"disabled companion does not update facing");
}
static void GoddardOriginal()
{
using var document=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-leveling-reference.json")));
int compared=0;
foreach(var c in document.RootElement.GetProperty("cases").EnumerateArray())
{
var p=c.GetProperty("input").EnumerateArray().Select(v=>v.GetSingle()).ToArray();
if(p[6]==0||p[7]==0)continue; //Native gate observations are guarded separately.
var o=c.GetProperty("observed").EnumerateArray().Select(v=>v.GetSingle()).ToArray();
var rotation=new Vector3(p[0],p[1],p[2]);for(int i=0;i<(int)p[5];i++)rotation=ActorPatrol.GoddardFacing(rotation,p[3],p[4]);
NearV(rotation,new(o[0],o[1],o[2]),c.GetProperty("name").GetString()!);compared++;
}
Check(compared==9,"nine active native leveling observations");
}
static void Check(bool ok,string name){if(!ok)throw new Exception(name);}
static void Near(float a,float b,string name)=>Check(float.IsFinite(a)&&Math.Abs(a-b)<.02f,$"{name}: {a} != {b}");
static void NearV(Vector3 a,Vector3 b,string name)=>Check(Vector3.Distance(a,b)<.04f,$"{name}: {a} != {b}");