Recover actor normal callbacks and late collision reads
This commit is contained in:
1 parent
bf876e9c3c
commit
bdca29d3aa
19 files changed
+963
-1
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<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" />
|
||||
<None Include="expected.json" CopyToOutputDirectory="PreserveNewest" Condition="Exists('expected.json')" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,219 @@
|
||||
using System.Numerics;
|
||||
using System.Text.Json;
|
||||
using GamePort.Game;
|
||||
|
||||
// Original normal callback component over synthetic state/accessors. Derived
|
||||
// Soldier174 and Jimmy204 are recorded endpoints, not full policy emulation.
|
||||
var fixture = new Fixture();
|
||||
var rows = new List<JsonElement>();
|
||||
void Direct(string name,bool ceiling = false) => rows.Add(fixture.Direct(name,ceiling));
|
||||
void Dynamic(string name) => rows.Add(fixture.Dynamic(name));
|
||||
fixture.Reset(0); Direct("jimmy_null");
|
||||
fixture.Reset(0); fixture.Selection = 3; Direct("jimmy_jetpack");
|
||||
fixture.Reset(0); Direct("jimmy_ordinary_polygon");
|
||||
fixture.Reset(0); fixture.Elapsed = 3; Direct("jimmy_elapsed_gate");
|
||||
fixture.Reset(0); fixture.MovementMode = 1; Direct("jimmy_mode1");
|
||||
fixture.Reset(0); fixture.MovementMode = 2; Direct("jimmy_mode2");
|
||||
fixture.Reset(0); Direct("jimmy_uncontrolled");
|
||||
fixture.Reset(0); fixture.Selection = 7; Direct("jimmy_gadget7_inactive");
|
||||
fixture.Reset(0); fixture.Selection = 7; fixture.Grappling = true; Direct("jimmy_gadget7_equal");
|
||||
fixture.Reset(0); fixture.Selection = 7; fixture.Grappling = true; fixture.Tether.Y = 49; Direct("jimmy_gadget7_large");
|
||||
fixture.Reset(0); Direct("ceiling_positive",true);
|
||||
fixture.Reset(0); fixture.Velocity.Y = -7; fixture.Acceleration.Y = -13; Direct("ceiling_negative",true);
|
||||
fixture.Reset(0); fixture.Acceleration.Y = -13; Direct("ceiling_velocity_only",true);
|
||||
fixture.Reset(0); fixture.Velocity.Y = -7; Direct("ceiling_acceleration_only",true);
|
||||
fixture.Reset(1); fixture.Reflection = false; Direct("generic_disabled");
|
||||
fixture.Reset(1); Direct("generic_axis");
|
||||
fixture.Reset(1); fixture.Damping = 0; Direct("generic_no_damping");
|
||||
fixture.Reset(1); fixture.Damping = 1.25f; Direct("generic_excess_damping");
|
||||
fixture.Reset(1); fixture.Velocity.X = 30; Direct("generic_oblique");
|
||||
fixture.Reset(1); fixture.FreshY = true; Direct("generic_fresh_y");
|
||||
fixture.Reset(2); Direct("soldier_mode0");
|
||||
fixture.Reset(2); fixture.ActorMode = 10; Direct("soldier_mode10");
|
||||
fixture.Reset(2); fixture.ActorMode = 10; fixture.Reflection = false; Direct("soldier_mode10_disabled");
|
||||
fixture.Reset(0); Dynamic("dynamic_jimmy");
|
||||
fixture.Reset(1); Dynamic("dynamic_generic");
|
||||
fixture.Reset(2); fixture.ActorMode = 10; Dynamic("dynamic_soldier");
|
||||
fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 1; Dynamic("late_inhibition");
|
||||
fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 2; fixture.Wall(); Dynamic("late_radius");
|
||||
fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 3; fixture.Wall(true); Dynamic("late_geometry");
|
||||
fixture.Reset(2); fixture.ActorMode = 10; fixture.Mutation = 4; fixture.Wall(); Dynamic("late_force");
|
||||
|
||||
if(args is ["--dump"])
|
||||
{
|
||||
Console.WriteLine(JsonSerializer.Serialize(new {cases = rows}));
|
||||
return;
|
||||
}
|
||||
var native = args is ["--native", _];
|
||||
if(args.Length != 0 && !native) throw new ArgumentException("Use --native <observations.json> or --dump");
|
||||
using var expected = JsonDocument.Parse(File.ReadAllText(native ? args[1] : Path.Combine(AppContext.BaseDirectory,"expected.json")));
|
||||
var cases = expected.RootElement.GetProperty("cases").EnumerateArray().ToArray();
|
||||
if(cases.Length != rows.Count) throw new Exception("Case count differs");
|
||||
for(var i = 0; i < rows.Count; i++) Compare(cases[i],rows[i],cases[i].GetProperty("name").GetString()!);
|
||||
fixture.Reset(1); fixture.Velocity = Vector4.Zero; fixture.Reflection = false;
|
||||
OriginalNormalContacts.GenericWall(fixture,Vector3.UnitZ);
|
||||
fixture.Reflection = true;
|
||||
try
|
||||
{
|
||||
OriginalNormalContacts.GenericWall(fixture,Vector3.UnitZ);
|
||||
throw new Exception("Undefined original zero-horizontal path was silently admitted");
|
||||
}
|
||||
catch(NotSupportedException) { }
|
||||
Console.WriteLine($"PASS {rows.Count} original actor-contact snapshots, live getter order and bounded derived endpoints; exact float32.");
|
||||
|
||||
static void Compare(JsonElement expected,JsonElement actual,string path)
|
||||
{
|
||||
if(expected.ValueKind != actual.ValueKind) throw new Exception($"{path}: kind differs");
|
||||
if(expected.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
if(expected.EnumerateObject().Count() != actual.EnumerateObject().Count()) throw new Exception($"{path}: field count differs");
|
||||
foreach(var p in expected.EnumerateObject()) Compare(p.Value,actual.GetProperty(p.Name),path+"."+p.Name);
|
||||
}
|
||||
else if(expected.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
if(expected.GetArrayLength() != actual.GetArrayLength()) throw new Exception($"{path}: array length differs");
|
||||
for(var i = 0; i < expected.GetArrayLength(); i++) Compare(expected[i],actual[i],$"{path}[{i}]");
|
||||
}
|
||||
else if(expected.ValueKind == JsonValueKind.Number)
|
||||
{
|
||||
if(expected.GetSingle() != actual.GetSingle()) throw new Exception($"{path}: {actual} != original {expected}");
|
||||
}
|
||||
else if(!JsonElement.DeepEquals(expected,actual)) throw new Exception($"{path}: {actual} != original {expected}");
|
||||
}
|
||||
|
||||
sealed class Fixture : IOriginalNormalBody
|
||||
{
|
||||
public Vector4 Root,Velocity,Acceleration,Angular;
|
||||
public Vector2 Tether;
|
||||
public int Selection,MovementMode,ActorMode,Mutation;
|
||||
public bool Grappling,Reflection,FreshY,Inhibited,ForceStatic,Geometry;
|
||||
public float Elapsed,Damping,Radius;
|
||||
private int profile,knocks,cleanups,marker,velocityGets;
|
||||
private float knockForce;
|
||||
private Vector4 knockNormal;
|
||||
private StaticCollisionContext context = null!;
|
||||
private readonly List<string> events = [];
|
||||
private readonly List<float> radii = [];
|
||||
private readonly List<object> angles = [];
|
||||
private CameraRayPolygon? wall;
|
||||
|
||||
public void Reset(int kind)
|
||||
{
|
||||
profile = kind; Root = new(0,0,15,1); Velocity = new(0,7,-40,0);
|
||||
Acceleration = new(11,13,17,0); Angular = new(1,2,3,0);
|
||||
Tether = new(36,48); Selection = -1; MovementMode = ActorMode = Mutation = 0;
|
||||
Grappling = FreshY = Inhibited = ForceStatic = false; Reflection = Geometry = true;
|
||||
Elapsed = 4; Damping = .25f; Radius = 10;
|
||||
knocks = cleanups = marker = velocityGets = 0; knockForce = 0; knockNormal = default;
|
||||
events.Clear(); radii.Clear(); angles.Clear(); wall = null;
|
||||
context = new(88,77){Nearest = new(77,88,new(111,222,333))};
|
||||
}
|
||||
public void Wall(bool seedLast = false)
|
||||
{
|
||||
wall = new(new(new(-100,-100,35),new(-100,100,35),new(100,100,35)),Vector3.UnitZ);
|
||||
if(seedLast) context.LastPolygon = wall;
|
||||
}
|
||||
public Vector4 ReadVelocity()
|
||||
{
|
||||
events.Add("Gv"); velocityGets++;
|
||||
if(FreshY && velocityGets == 2) Velocity.Y = 99;
|
||||
return Velocity;
|
||||
}
|
||||
public void WriteVelocity(Vector4 value) { events.Add("Sv4"); Velocity = value; }
|
||||
public void WriteVelocityXYZ(Vector3 value) { events.Add("Sv3"); Velocity = new(value,Velocity.W); }
|
||||
public Vector4 ReadAcceleration() { events.Add("Ga"); return Acceleration; }
|
||||
public void WriteAcceleration(Vector4 value) { events.Add("Sa4"); Acceleration = value; }
|
||||
public bool ReflectWalls { get { events.Add("Gate"); return Reflection; } }
|
||||
public float WallDamping { get { events.Add("F"); return Damping; } }
|
||||
public void AddAngularVelocity(Vector3 value) { events.Add("Aw"); Angular += new Vector4(value,0); }
|
||||
private int Heading(Vector4 vector)
|
||||
{
|
||||
var result = OriginalHeading.Angles(new(vector.X,vector.Y,vector.Z));
|
||||
var pitch = result.Pitch & 16383; var yaw = result.Yaw & 16383;
|
||||
angles.Add(new {vector = Values(vector),pitch,yaw}); events.Add("Angles");
|
||||
return yaw;
|
||||
}
|
||||
private void Knock(Vector3 normal)
|
||||
{
|
||||
events.Add("K174"); knocks++; knockForce = 500; knockNormal = new(normal,0);
|
||||
if(Mutation == 1) Inhibited = true;
|
||||
if(Mutation == 2) Radius = 20;
|
||||
if(Mutation == 3) Geometry = false;
|
||||
if(Mutation == 4) ForceStatic = true;
|
||||
}
|
||||
private void WallContact(Vector3 normal)
|
||||
{
|
||||
if(profile == 0)
|
||||
{
|
||||
// Only tested null/ordinary/elapsed-rejected Player material paths.
|
||||
// Complete204 is recorded, not the actual grappler cleanup policy.
|
||||
if(Selection == 7 && Grappling)
|
||||
{
|
||||
var length = Math.Sqrt((double)Tether.X*Tether.X+(double)Tether.Y*Tether.Y);
|
||||
Tether = default;
|
||||
if(length > 60) { events.Add("C204"); cleanups++; marker = 1; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OriginalNormalContacts.GenericWall(this,normal,Heading);
|
||||
if(profile == 2 && ActorMode == 10) Knock(normal);
|
||||
}
|
||||
}
|
||||
public JsonElement Direct(string name,bool ceiling)
|
||||
{
|
||||
if(ceiling) OriginalNormalContacts.Ceiling(this); else WallContact(Vector3.UnitZ);
|
||||
return Snapshot(name,-1);
|
||||
}
|
||||
private float ReadRadius() { events.Add("Radius"); radii.Add(Radius); return Radius; }
|
||||
public JsonElement Dynamic(string name)
|
||||
{
|
||||
var previous = new Vector3(0,0,50);
|
||||
var candidate = new Vector3(Root.X,Root.Y,Root.Z);
|
||||
var radius = ReadRadius();
|
||||
context.Nearest = context.Nearest with {FaceDistance = -1,EdgeDistance = radius};
|
||||
var box = new DynamicBoxCollider(1,Vector3.Zero,new(-50,-50,-10),new(50,50,10),Matrix4x4.Identity,40);
|
||||
foreach(var triangle in DynamicSceneCollision.Triangles(box))
|
||||
{
|
||||
var cross = Vector3.Cross(triangle.B-triangle.A,triangle.C-triangle.A);
|
||||
var normal = cross/OriginalBodySupport.QuickMagnitude(cross);
|
||||
var response = OriginalSphereResponse.Resolve(new(triangle.A,triangle.C,triangle.B),normal,
|
||||
previous,candidate,radius,context.Nearest);
|
||||
if(response.Contact == SphereContact.None) continue;
|
||||
candidate = response.Position; context.Nearest = response.State;
|
||||
WallContact(normal);
|
||||
}
|
||||
var contact = context.Nearest.FaceDistance != -1 || context.Nearest.EdgeDistance < radius;
|
||||
if(contact)
|
||||
{
|
||||
events.Add("Inhibit");
|
||||
if(!Inhibited)
|
||||
{
|
||||
var world = new OriginalStaticCollision(wall is {} polygon ? [polygon] : []);
|
||||
var initialPasses = context.Passes;
|
||||
var clipped = world.Move(previous,candidate-previous,ReadRadius(),context,edges:false,
|
||||
lowerEdges:ForceStatic,geometryEnabled:Geometry);
|
||||
// Fixed primitive getters: recursive source calls read the same
|
||||
// radius before their sole terminal callback. No actor callback
|
||||
// occurs between these bounded passes in this composition.
|
||||
for(var pass = 1; pass < context.Passes-initialPasses; pass++) ReadRadius();
|
||||
if(clipped.CallbackPolygon is {} last)
|
||||
{
|
||||
if(last.StoredNormal.Y <= -.7f) OriginalNormalContacts.Ceiling(this);
|
||||
else WallContact(last.StoredNormal);
|
||||
}
|
||||
events.Add("Root"); Root = new(clipped.Position,1);
|
||||
}
|
||||
}
|
||||
return Snapshot(name,contact ? 1 : 0);
|
||||
}
|
||||
private JsonElement Snapshot(string name,int contact) => JsonSerializer.SerializeToElement(new {
|
||||
name,contact,root = Values(Root),velocity = Values(Velocity),acceleration = Values(Acceleration),
|
||||
angular = Values(Angular),movementMode = MovementMode,actorMode = ActorMode,marker,
|
||||
tether = new[]{Tether.X,Tether.Y},knocks,force = knockForce,knockNormal = Values(knockNormal),cleanups,
|
||||
radius = Radius,forceStatic = ForceStatic ? 1 : 0,geometry = Geometry ? 1 : 0,inhibited = Inhibited ? 1 : 0,
|
||||
radii,angles,passes = context.Passes,visits = context.NodeVisits,face = context.Nearest.FaceDistance,
|
||||
edge = context.Nearest.EdgeDistance,events = string.Join(',',events)
|
||||
});
|
||||
private static float[] Values(Vector4 v) => [v.X,v.Y,v.Z,v.W];
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"cases": [
|
||||
{"name":"jimmy_null","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_jetpack","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_ordinary_polygon","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_elapsed_gate","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_mode1","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":1,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_mode2","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":2,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_uncontrolled","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_gadget7_inactive","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_gadget7_equal","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[0,0],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":""},
|
||||
{"name":"jimmy_gadget7_large","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":1,"tether":[0,0],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":1,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"C204"},
|
||||
{"name":"ceiling_positive","contact":-1,"root":[0,0,15,1],"velocity":[0,0,-40,0],"acceleration":[11,0,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Sv4,Ga,Sa4"},
|
||||
{"name":"ceiling_negative","contact":-1,"root":[0,0,15,1],"velocity":[0,-7,-40,0],"acceleration":[11,-13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Ga"},
|
||||
{"name":"ceiling_velocity_only","contact":-1,"root":[0,0,15,1],"velocity":[0,0,-40,0],"acceleration":[11,-13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Sv4,Ga"},
|
||||
{"name":"ceiling_acceleration_only","contact":-1,"root":[0,0,15,1],"velocity":[0,-7,-40,0],"acceleration":[11,0,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gv,Ga,Sa4"},
|
||||
{"name":"generic_disabled","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate"},
|
||||
{"name":"generic_axis","contact":-1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"},
|
||||
{"name":"generic_no_damping","contact":-1,"root":[0,0,15,1],"velocity":[0,7,40,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"},
|
||||
{"name":"generic_excess_damping","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-10,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"},
|
||||
{"name":"generic_oblique","contact":-1,"root":[0,0,15,1],"velocity":[22.5000019,7,30,0],"acceleration":[11,13,17,0],"angular":[1,-3.31300402,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0.599998295,0,-0.799997687,0],"pitch":0,"yaw":9870},{"vector":[0.599998295,0,0.799997687,0],"pitch":0,"yaw":14706}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"},
|
||||
{"name":"generic_fresh_y","contact":-1,"root":[0,0,15,1],"velocity":[0,99,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"},
|
||||
{"name":"soldier_mode0","contact":-1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw"},
|
||||
{"name":"soldier_mode10","contact":-1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174"},
|
||||
{"name":"soldier_mode10_disabled","contact":-1,"root":[0,0,15,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[],"angles":[],"passes":0,"visits":0,"face":77,"edge":88,"events":"Gate,K174"},
|
||||
{"name":"dynamic_jimmy","contact":1,"root":[0,0,20,1],"velocity":[0,7,-40,0],"acceleration":[11,13,17,0],"angular":[1,2,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,10],"angles":[],"passes":1,"visits":0,"face":40,"edge":10,"events":"Radius,Inhibit,Radius,Root"},
|
||||
{"name":"dynamic_generic","contact":1,"root":[0,0,20,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":0,"marker":0,"tether":[36,48],"knocks":0,"force":0,"knockNormal":[0,0,0,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":1,"visits":0,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,Inhibit,Radius,Root"},
|
||||
{"name":"dynamic_soldier","contact":1,"root":[0,0,20,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":1,"visits":0,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Root"},
|
||||
{"name":"late_inhibition","contact":1,"root":[0,0,15,1],"velocity":[0,7,30,0],"acceleration":[11,13,17,0],"angular":[1,9.20000076,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":1,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":1,"inhibited":1,"radii":[10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0}],"passes":0,"visits":0,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit"},
|
||||
{"name":"late_radius","contact":1,"root":[0,0,55,1],"velocity":[0,7,-22.5,0],"acceleration":[11,13,17,0],"angular":[1,3.80000067,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":2,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":20,"forceStatic":0,"geometry":1,"inhibited":0,"radii":[10,20,20],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,-1,0],"pitch":0,"yaw":8192}],"passes":2,"visits":4,"face":15,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Root"},
|
||||
{"name":"late_geometry","contact":1,"root":[0,0,20,1],"velocity":[0,7,-22.5,0],"acceleration":[11,13,17,0],"angular":[1,3.80000067,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":2,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":0,"geometry":0,"inhibited":0,"radii":[10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,-1,0],"pitch":0,"yaw":8192}],"passes":1,"visits":2,"face":40,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Root"},
|
||||
{"name":"late_force","contact":1,"root":[0,0,45,1],"velocity":[0,7,-22.5,0],"acceleration":[11,13,17,0],"angular":[1,3.80000067,3,0],"movementMode":0,"actorMode":10,"marker":0,"tether":[36,48],"knocks":2,"force":500,"knockNormal":[0,0,1,0],"cleanups":0,"radius":10,"forceStatic":1,"geometry":1,"inhibited":0,"radii":[10,10,10],"angles":[{"vector":[0,0,-1,0],"pitch":0,"yaw":8192},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,1,0],"pitch":0,"yaw":0},{"vector":[0,0,-1,0],"pitch":0,"yaw":8192}],"passes":2,"visits":4,"face":15,"edge":10,"events":"Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Inhibit,Radius,Radius,Gate,Gv,Gv,F,Sv3,Angles,Angles,Aw,K174,Root"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
from pathlib import Path
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0,str(ROOT/'tools/binary'))
|
||||
from actor_contact import CALLBACK_OPERANDS,CASES,collect,generate
|
||||
from checkpoint_script_state import find_case,read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
|
||||
class ActorContactTests(unittest.TestCase):
|
||||
def test_complete_bodies_and_reviewed_relocations(self):
|
||||
source=collect(ROOT.parent/'Original')
|
||||
self.assertEqual(len(source['bodies']),17)
|
||||
self.assertEqual(len(source['probe_operands']),139)
|
||||
self.assertEqual(len(CALLBACK_OPERANDS),37)
|
||||
addresses=[p['va'] for p in source['probe_operands']]
|
||||
self.assertEqual(len(addresses),len(set(addresses)))
|
||||
self.assertNotIn(0x4095be,addresses)
|
||||
pe=PE(find_case(ROOT.parent/'Original','Neutron.exe'))
|
||||
self.assertEqual(read_va(pe,0x4095be,7).hex(),'8bc4680000fa43')
|
||||
|
||||
def test_real_class_overrides_and_pure_scalar_getters(self):
|
||||
source=collect(ROOT.parent/'Original')
|
||||
classes={c['kind']:c for c in source['normal_bindings']}
|
||||
self.assertEqual(len(classes),13)
|
||||
self.assertTrue(all(len(c['methods'])==14 for c in classes.values()))
|
||||
self.assertEqual(classes['3JIM']['methods']['0x374'],'0x42a660')
|
||||
self.assertEqual(classes['3SOL']['methods']['0x374'],'0x409590')
|
||||
self.assertEqual(classes['3ROC']['methods']['0x374'],'0x43e8d0')
|
||||
self.assertEqual(classes['3TRO']['methods']['0x374'],'0x458890')
|
||||
self.assertEqual([g['field'] for g in source['scalar_getters']],['0x13c','0x13d','0x137','0x150','0x15c'])
|
||||
|
||||
def test_generation_rejects_original_and_symlink_outputs(self):
|
||||
original=ROOT.parent/'Original'
|
||||
with self.assertRaisesRegex(ValueError,'Separate output'):
|
||||
generate(original,original/'forbidden-generated-probe')
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
output=Path(temporary)
|
||||
(output/'probe.exe').symlink_to(find_case(original,'Neutron.exe'))
|
||||
with self.assertRaisesRegex(ValueError,'symlinks'):generate(original,output)
|
||||
|
||||
def test_saved_reference_covers_all_bounded_profiles_and_late_reads(self):
|
||||
cases=json.loads((ROOT/'tests/GamePort.ActorContactTests/expected.json').read_text())['cases']
|
||||
self.assertEqual(tuple(c['name'] for c in cases),CASES)
|
||||
by_name={c['name']:c for c in cases}
|
||||
self.assertEqual(by_name['late_radius']['radii'],[10,20,20])
|
||||
self.assertEqual(by_name['late_radius']['root'],[0,0,55,1])
|
||||
self.assertEqual(by_name['late_inhibition']['radii'],[10])
|
||||
self.assertEqual(by_name['soldier_mode10_disabled']['force'],500)
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in new issue
Block a user