Restore tutorial return placement and source terrain collision eligibility

This commit is contained in:
UnixNight committed 2026-10-25 01:30:09 -04:00
1 parent ca08c468ba
commit 8d60a68511
36 files changed
+991 -69

No files matched your search

@@ -0,0 +1,12 @@
<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/Game/RuntimeCheckpoint.cs" Link="RuntimeCheckpoint.cs" />
<Compile Include="../../src/GamePort/Assets/OriginalSave.cs" Link="OriginalSave.cs" />
</ItemGroup>
</Project>
+85
View File
@@ -0,0 +1,85 @@
using System.Buffers.Binary;
using System.Numerics;
using GamePort.Assets;
using GamePort.Game;
var original = Path.GetFullPath(args.Length == 1 ? args[0] : "../Original");
var source = File.ReadAllBytes(Path.Combine(original, "Neutron.exe"));
void Bytes(int va, string hex)
{
var expected = Convert.FromHexString(hex);
Require(source.AsSpan(va - 0x400000, expected.Length).SequenceEqual(expected), $"Source instructions differ at0x{va:X}");
}
int Pointer(int va) => BinaryPrimitives.ReadInt32LittleEndian(source.AsSpan(va - 0x400000, 4));
Require(Pointer(0x4a3bdc + 0x168) == 0x43b5a0, "Jimmy transition vtable target");
Require(Pointer(0x4a3bdc + 0x1e8) == 0x42af00, "Separate Jimmy checkpoint vtable target");
Bytes(0x42af1b, "898E481E0000");
Bytes(0x42af30, "81C6381E0000");
Bytes(0x43b78e, "8A83A509000084C07537");
Bytes(0x43b7b1, "8D8BA80900008993A80900008B50048951048B50088951088B400C89410C");
Bytes(0x458014, "88905409000074088D8340FFFFFFEB0233C085DB8890A5090000");
Bytes(0x423a90, "8A85E508000084C00F8486000000C685E508000000");
Bytes(0x423abf, "FF926C010000");
Bytes(0x423ae3, "8B8DE80800008BC48964242089088B95EC0800008950048B8DF00800008948088B95F408000089500C");
Bytes(0x423b0c, "8B855C0900008D88C00000008B80C0000000FF9068010000");
Require(Pointer(0x49f480 + 0x168) == 0x471680 && Pointer(0x49f480 + 0x16c) == 0x471630,
"Goddard root setter retains unchanged XYZ");
Bytes(0x471680, "8B54240C8B01528B54240C528B54240C52FF906C010000C21000");
Bytes(0x4427f2, "8A905409000084D2741D85C9740F8D8140FFFFFFC6805409000000EB21");
Bytes(0x442887, "8A905409000084D2741C85C974108D8140FFFFFF5F5EC6805409000000");
Bytes(0x46008b, "8D87E80800008D4C241C50FFD58D8FEC080000518D4C2420FFD581C7F00800008D4C241C57FFD5");
Bytes(0x460ba3, "898DA80900008B5424688995AC0900008B44246C8B55008985B0090000");
Console.WriteLine("PASS source departure/RETURN root, start-trigger suppression and TSK vector identity");
var initial = OriginalSave.Load(Path.Combine(original, "NewGame.tsk"));
var departingRoot = new Vector3(3321.25f, 76.5f, -456.75f);
var tutorialRoot = new Vector3(-31, 211, 584);
var departure = RuntimeCheckpoint.Stage(initial.StoredVector, departingRoot, false);
Require(!departure.Returning && departure.ActivateStartTrigger, "Ordinary departure retains destination start trigger");
Require(departure.Root == departingRoot, "Departure captures live actor root, not STRT position");
var tutorialSave = initial with { LevelCode = "VR04", StartPoint = "PHONEBOOTH",
ReturnLevel = "level1b.gam", ReturnStart = "STARTEXP", StoredVector = departure.Root };
var reloaded = OriginalSave.Parse(tutorialSave.Encode());
var returning = RuntimeCheckpoint.Stage(reloaded.StoredVector, tutorialRoot, true);
Require(returning.Returning && !returning.ActivateStartTrigger, "RETURN suppresses destination start trigger");
Require(returning.Root == departingRoot && returning.Root != tutorialRoot, "RETURN preserves departure root across TSK encoding");
Require(reloaded.ReturnLevel == "level1b.gam" && reloaded.ReturnStart == "STARTEXP", "Return strings stay separate from captured root");
var nextDeparture = RuntimeCheckpoint.Stage(returning.Root, tutorialRoot, false);
Require(nextDeparture.Root == tutorialRoot && nextDeparture.ActivateStartTrigger, "RETURN suppression is per transition, not permanent");
Console.WriteLine("PASS lab departure -> serialized tutorial -> RETURN preserves root and suppresses intro once");
var saves = Directory.EnumerateFiles(original).Where(p => p.EndsWith(".tsk", StringComparison.OrdinalIgnoreCase)).ToArray();
Require(saves.Length == 12, "Expected all12 supplied saves");
foreach (var path in saves)
{
var bytes = File.ReadAllBytes(path);
var save = OriginalSave.Parse(bytes);
Require(save.Encode().SequenceEqual(bytes), $"Wire layout changed for {path}");
var returnStage = RuntimeCheckpoint.Stage(save.StoredVector, tutorialRoot, true);
Require(returnStage.Root == save.StoredVector, $"RETURN did not preserve original vector in {path}");
var freshLoad = RuntimeCheckpoint.Stage(save.StoredVector, tutorialRoot, false);
Require(!freshLoad.Returning && freshLoad.ActivateStartTrigger, "Loaded TSK vector alone does not imply pending RETURN");
}
Console.WriteLine("PASS all12 original TSK vectors remain byte-identical and distinct from pending RETURN state");
foreach (var bad in new[] { new Vector3(float.NaN, 0, 0), new Vector3(0, float.PositiveInfinity, 0), new Vector3(0, 0, float.NegativeInfinity) })
{
Reject(() => RuntimeCheckpoint.Stage(bad, departingRoot, true));
Reject(() => RuntimeCheckpoint.Stage(departingRoot, bad, false));
}
// Large but finite roots are valid serialized evidence; avoid inventing world bounds.
Require(RuntimeCheckpoint.Stage(Vector3.Zero, new(float.MaxValue, 0, -float.MaxValue), false).Root.X == float.MaxValue,
"Finite original coordinates must not be normalized or truncated");
Console.WriteLine("PASS nonfinite input rejection without invented coordinate bounds");
static void Require(bool condition, string message)
{
if (!condition) throw new InvalidOperationException(message);
}
static void Reject(Action action)
{
try { action(); }
catch (ArgumentOutOfRangeException) { return; }
throw new InvalidOperationException("Expected nonfinite root rejection");
}
+13 -2
View File
@@ -162,6 +162,12 @@ static void SourcePolicy()
var scene = new SceneCollision(mesh);
Check(scene.TriangleCount == 2, "unrendered source proxy retained");
Check(scene.Move(Vector3.Zero, new Vector3(100, 0, 0), 1, 4).HitWall, "proxy blocks under provisional policy");
var source = mesh with { CollisionPolygons = [new(1, 0, Vector3.UnitX, "wall", "NcWater"), new(1, 1, Vector3.UnitX, "wall", "NcWater")] };
var excluded = new SceneCollision(source);
Check(excluded.TriangleCount == 0 && !excluded.Move(Vector3.Zero, new(100, 0, 0), 1, 4).HitWall,
"NC shape is drawn separately but omitted from terrain registration");
var materialOnly = source with { CollisionPolygons = source.CollisionPolygons.Select(p => p with { ShapeName = "wall", MaterialName = "ncwater" }).ToArray() };
Check(new SceneCollision(materialOnly).TriangleCount == 2, "NC material name alone does not disable collision");
var degenerate = new SceneCollision(new Builder().Triangle(Vector3.Zero, Vector3.One, Vector3.One).Build());
Check(degenerate.TriangleCount == 0, "degenerate triangles skipped");
Throws<ArgumentOutOfRangeException>(() => scene.Move(Vector3.Zero, Vector3.Zero, 0, 4));
@@ -179,8 +185,13 @@ static void OriginalLab()
var root = FindRoot();
var file = Path.Combine(root, "artifacts/extracted/level1b/scene.json");
Check(File.Exists(file), "prepared original lab required (run extractors/prepare.py)");
var scene = new SceneCollision(Mesh.LoadSceneJson(file));
Check(scene.TriangleCount == 2869, "all original lab triangles included");
var mesh = Mesh.LoadSceneJson(file);
var scene = new SceneCollision(mesh);
Check(mesh.Indices.Length / 3 == 2869 && mesh.CollisionPolygons.Count(p => !p.TerrainCollision) == 18,
"NC registration exclusion preserves all render/source polygons");
Check(mesh.CollisionPolygons.Where(p => !p.TerrainCollision).All(p => p.ShapeId == 94 && p.ShapeName == "ncwater"),
"Actual shape names are recovered from prepared mesh records");
Check(scene.TriangleCount == 2851, "source terrain registration excludes18 NC-shape triangles while retaining proxies");
var originalRoot = new Vector3(5071.933105f, 26.661896f, 824.103943f);
var floor = scene.GroundHeight(originalRoot, 100)!.Value;
Near(floor, .5486332f, .001f, "actual lab floor below GAM root");
+15 -1
View File
@@ -42,6 +42,20 @@ Check(skipMusicPlaying,"Skipping must restore selected gameplay music");
Check(skip.FindActor("C3DGODDARD")!.Position==endGoddard,"Skip must preserve AI/toggle actions");
Console.WriteLine("PASS original intro skip preserves action sequence");
var returnDirector = new SceneDirector(level, new TaskStates(save.Tasks), (_, _) => 10);
var returnCues = 0;
returnDirector.Speech += (_, _) => returnCues++;
var sourceGoddard = returnDirector.FindActor("C3DGODDARD")!.Position;
returnDirector.Begin(level.FindStart()!, activateStartTrigger: false);
Check(returnDirector.Controlled && !returnDirector.Playing && returnCues == 0,
"RETURN suppresses the start trigger rather than replaying/skipping its dialogue");
Check(returnDirector.FindActor("C3DGODDARD")!.Position == sourceGoddard,
"Suppressing LABEXP must not execute its teleport/patrol actions");
returnDirector.Begin(level.FindStart()!);
Check(!returnDirector.Controlled && returnDirector.CurrentTag == "LABEXP1" && returnCues == 1,
"Return suppression does not persist into a later normal start");
Console.WriteLine("PASS RETURN suppresses STRT actions once and preserves normal start behavior");
foreach (var finishBySkip in new[] { false, true })
{
var carlScene = new SceneDirector(level, new TaskStates(save.Tasks), (_, _) => .1);
@@ -191,7 +205,7 @@ var restoredDirector=new SceneDirector(vr,new TaskStates(save.Tasks),(_,_)=>1);v
Check(restoredDirector.Actors.Where(a=>a.Kind=="3PIC").All(a=>!a.Visible && !a.Active),"Loaded acquired stars must hide before contact");
var transitions=0;LevelTransition? returned=null;interactions.Transition += request=>{transitions++;returned=request;};
var returnGate=vr.Entities.First(e=>e.Kind=="LOAD");interactions.Update(returnGate.Position);interactions.Update(returnGate.Position);
Check(transitions==1 && returned!.LevelFile==save.ReturnLevel && returned.StartPoint==save.ReturnStart,"RETURN uses stored destination and contact-enter gating");
Check(transitions==1 && returned!.Returning && returned.LevelFile==save.ReturnLevel && returned.StartPoint==save.ReturnStart,"RETURN uses stored destination, restore flag and contact-enter gating");
Console.WriteLine("PASS original VR01 star/trophy score, strict contact entry, acquired-state save/reload and RETURN request");
static GamEntity Entity(string kind,string tag,params (string Name,object Value)[] values)
+1 -1
View File
@@ -66,7 +66,7 @@ var snapshot = interactions.Snapshot();
var decoded = OriginalSave.Parse(snapshot.Encode());
Check(decoded.InventoryStates[3] == 1 && decoded.ItemStates[301] == 1 && decoded.Score == 150 && decoded.OtherCounter == 3,
"Original TSK serializes acquired gadget, score and objective selector");
Check(decoded.StoredVector == original.StoredVector, "Unknown saved vector is not overwritten by inferred checkpoint data");
Check(decoded.StoredVector == original.StoredVector, "Pickup42AF00 does not overwrite the separate saved transition root");
var restoredTasks = new TaskStates(decoded.Tasks);
var restoredDirector = new SceneDirector(lab, restoredTasks, (_, _) => 5);
var restored = new SceneInteractions(restoredDirector, restoredTasks, decoded, lab.Code);
+18
View File
@@ -21,6 +21,7 @@ var tests = new (string Name, Action Check)[]
("powered steering remains independent of presentation rate", JetpackReplayRates),
("landing clears residual air turn before ground steering", LandingTurn),
("reset restores spawn, camera and counters", Reset),
("RETURN restores exact root with authored start yaw", ReturnRoot),
("ten-minute simulation remains finite and supported", LongRun),
("original lab placement, floor, walking and jump checkpoint", () => OriginalLab(project, originals)),
};
@@ -274,6 +275,23 @@ static void LandingTurn()
}
}
static void ReturnRoot()
{
var simulation = FlatSimulation();
var destination = simulation.ActorRoot + new Vector3(450, 100, -250);
var yaw = simulation.Yaw;
simulation.RestoreReturnRoot(destination);
NearVector(simulation.ActorRoot, destination, .0001f, "restore stored XYZ without floor snapping");
Near(simulation.Yaw, yaw, 0, "RETURN has no stored rotation; retain STRT yaw");
Check(simulation.Velocity == Vector3.Zero && simulation.Steps == 0, "fresh destination keeps initial motion state");
Check(Vector3.Distance(simulation.CameraEye, simulation.ActorRoot) < 500, "camera follows restored root");
Throws<ArgumentOutOfRangeException>(() => simulation.RestoreReturnRoot(new(float.NaN, 0, 0)));
simulation.Step(default);
Check(simulation.ActorRoot.Y < destination.Y && !simulation.Grounded, "restored unsupported root settles through physics");
simulation.Reset();
Check(Vector3.Distance(simulation.ActorRoot, destination) > 100, "ordinary reset still uses the source start");
}
static void JumpRepress()
{
var simulation = FlatSimulation();
@@ -0,0 +1,9 @@
<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/StaticSceneVisuals.cs"/>
</ItemGroup>
</Project>
@@ -0,0 +1,159 @@
using System.Numerics;
using GamePort.Assets;
using GamePort.Game;
using GamePort.Application;
// Modern input replay using original geometry/actors, not recovered navigation.
// SCENE65 is an explicit initial fixture, not an award or proof that the prior
// game progression reaches65. The player starts only at authored STRT riverlab.
var original = Path.GetFullPath(args.Length == 1 ? args[0] : "../Original");
var prepared = Path.GetFullPath("artifacts/extracted");
var level = GamLevel.Load(AssetPath.Resolve(original, "gam/level1b.gam"));
var start = level.FindStart("riverlab")!;
var world = Mesh.LoadSceneJson(Path.Combine(prepared, "level1b/scene.json"));
var save = OriginalSave.Load(AssetPath.Resolve(original, "NewGame.tsk"));
var tasks = new TaskStates(save.Tasks);
tasks.SetExisting("SCENE", 65);
var resources = new PreparedEntityResources(Path.Combine(prepared, "level1b/entities/entities.json"));
var director = new SceneDirector(level, tasks, resources.Duration);
var interactions = new SceneInteractions(director, tasks, save, level.Code);
var mechanisms = new SceneMechanisms(director);
var visuals = new StaticSceneVisuals(world, director, original, Path.Combine(prepared, "level1b/models"));
var simulation = new LabSimulation(new SceneCollision(world), AseMesh.Load(AssetPath.Resolve(original, "ASE/jimstop.ase")),
start.Position, start.Rotation.Y) { JetpackInventoryState = () => interactions.Inventory.State(0, 3) };
var resolverCalls = 0;
simulation.DynamicRootResolver = (before, after, radius) =>
{
resolverCalls++;
return DynamicBodyResponse.Resolve(visuals.DoorColliders(), before, after, radius);
};
var patrols = new List<ActorPatrol>();
foreach (var actor in director.Actors.Where(a => a.Kind is "3DOG" or "3CAR"))
{
var physics = new OriginalScenePhysics(world);
var grounded = false;
var patrol = new ActorPatrol(actor, director.FindActor, (body, dt) =>
{
var step = physics.Step(body.Position, body.Velocity, actor.Kind == "3DOG" ? 130 : 100,
actor.Kind == "3DOG" ? .3f : .75f, grounded, dt);
grounded = step.Supported;
return new(step.Body.Position, step.Body.Velocity);
});
patrols.Add(patrol);
director.RegisterPatrolConsumer(actor.Tag);
director.ActorChanged += changed => { if (ReferenceEquals(changed, actor)) patrol.SynchronizeAuthoredState(); };
}
LevelTransition? destination = null;
interactions.Transition += request => destination ??= request;
director.Begin(start);
interactions.Reset(); mechanisms.Reset();
Require(director.Controlled && !director.Playing, "Authored underground start must grant control without the lab intro");
var bars = director.FindActor("bars")!;
var closedY = bars.SourceGam!.Position.Y;
var amount = bars.SourceGam.Number("OpenAmount");
var buttons = director.Actors.Where(a => a.Kind == "3BUT").ToArray();
Require(buttons.Length == 2 && buttons[0].Position.Y > buttons[1].Position.Y && buttons[0].Position.Z > buttons[1].Position.Z,
"Source switch ordering/door sides changed");
Require(bars.Position.Y == closedY && buttons.All(b => b.Animation == "UP"), "Authored bars/switches must begin closed/available");
var pressed = new bool[2];
var sawFullyOpen = false;
var openingLoops = 0;
var stoppedLoops = 0;
var crossings = 0;
mechanisms.Sound += (_, id, loop) => { if (id == 59 && loop) openingLoops++; };
mechanisms.StopSound += _ => stoppedLoops++;
// Explicit center approaches keep the capsule away from the arched entrance's
// masonry. These waypoint coordinates are test input policy, not source AI.
Walk("lower switch", new(buttons[1].Position.X, buttons[1].Position.Z));
Require(pressed[1] && bars.Position.Y > closedY, "Lower switch contact did not start opening the original bars");
Walk("lower center approach", new(bars.Position.X, -1900));
Walk("lower gate approach", new(bars.Position.X, bars.Position.Z - 200));
Walk("upper passage", new(bars.Position.X, bars.Position.Z + 300));
Require(crossings == 1 && sawFullyOpen, "Lower-to-upper passage did not cross the open source doorway");
Walk("upper switch approach", new(3500, -900));
Require(pressed[0], "Upper switch was not pressed through live player contact");
Walk("upper center approach", new(bars.Position.X, -900));
Walk("lower return passage", new(bars.Position.X, -1450));
Require(crossings == 2, "Upper-to-lower passage did not cross the source doorway");
Walk("lower return", new(bars.Position.X, -2000));
for (var i = 0; i < 1200; i++) Tick(default);
Require(MathF.Abs(bars.Position.Y - closedY) < .01f && buttons.All(b => b.Animation == "UP"),
"Timed bars and both switches did not return to their authored resting states");
// A separate negative collision query uses the replay's actual standing root
// height. It never assigns the player position or bypasses a button during play.
// Correct NC-water exclusion leaves this body inside the source broadphase;
// treating water as solid raised it85.89 units and incorrectly skipped the bars.
var probeBefore = new Vector3(bars.Position.X, simulation.ActorRoot.Y, bars.Position.Z - 100);
var probeAfter = probeBefore + new Vector3(0, 0, 80);
var probeBox = visuals.DoorColliders().Single();
Require(DynamicSceneCollision.BroadPhase(probeBox, new(probeBefore, probeAfter, 60)),
"Closed source gate must receive the actual standing-height body sweep");
var liveRoot = simulation.ActorRoot;
var blocked = DynamicBodyResponse.Resolve([probeBox], probeBefore, probeAfter, 60);
Require(blocked.Z < bars.Position.Z - 76 && simulation.ActorRoot == liveRoot,
"Closed bars failed the negative sweep, or the query moved the live player");
Require(tasks.Get("SCENE") == 65 && interactions.Score == save.Score && destination == null,
"Walking the button route must not invent task/score or enter the separate river LOAD");
Require(simulation.Steps > 1200 && simulation.Travel > 3500 && simulation.Jumps == 0 && simulation.Grounded,
"Replay did not exercise actual grounded movement");
Require(resolverCalls == simulation.Steps && openingLoops >= 1 && stoppedLoops >= 1,
"Live dynamic collision or door-loop lifetime was not exercised");
Require(!director.Blocked && mechanisms.Unsupported.Count == 0, "Route encountered unsupported director/mechanism behavior");
Console.WriteLine($"PASS input-only underground passage both ways, both switches, timed reclose, {crossings} clear crossings. {simulation.Report}");
Console.WriteLine("Initial fixture is original riverlab/SCENE65. Original collision, timing, water and prior progression fidelity remain separate evidence.");
void Walk(string name, Vector2 target)
{
for (var tick = 0; tick < 1800; tick++)
{
var difference = target - new Vector2(simulation.Position.X, simulation.Position.Z);
if (difference.Length() < 30)
{
// Release before turning for the next leg. Source steering changes
// yaw while decelerating, rather than snapping the heading or root.
for (var pause = 0; pause < 90; pause++) Tick(default);
Console.WriteLine($"PASS walked {name}: root={simulation.ActorRoot}, barsY={bars.Position.Y:F2}");
return;
}
var desiredYaw = MathF.Atan2(-difference.X, difference.Y) * 180 / MathF.PI;
var error = MathF.IEEERemainder(desiredYaw - simulation.Yaw, 360);
Tick(new(MathF.Abs(error) < 6, false, error > 1, error < -1, false));
}
throw new InvalidOperationException($"Input route blocked at {name}: {simulation.ActorRoot}");
}
void Tick(PlayerInput input)
{
Require(director.Controlled, "Underground route unexpectedly lost player control");
var previous = simulation.ActorRoot;
simulation.Step(input);
Require(Vector3.Distance(previous, simulation.ActorRoot) < 100, "Player warped during input replay");
if (simulation.Steps == 1)
Require(MathF.Abs(previous.Y - simulation.ActorRoot.Y) < 1,
"Authored riverlab spawn popped onto an excluded NC water surface");
director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, new(0, simulation.Yaw, 0));
director.Touch(level.Player.Tag!, simulation.ActorRoot);
interactions.Update(simulation.ActorRoot, simulation.InteractionRadius);
mechanisms.Update(simulation.ActorRoot, simulation.InteractionRadius);
// Test actual aperture clearance when crossing the gate plane, before this
// frame's mechanism movement. The resolver uses this same current transform.
if ((previous.Z - bars.Position.Z) * (simulation.ActorRoot.Z - bars.Position.Z) < 0)
{
var box = visuals.DoorColliders().Single();
var minimumY = DynamicSceneCollision.Corners(box).Min(p => p.Y);
Require(minimumY > simulation.Position.Y + simulation.BodyHeight,
"Replay crossed the bars before the moving doorway cleared the player");
crossings++;
}
mechanisms.Step(FixedStepClock.Step);
foreach (var patrol in patrols) patrol.Step(FixedStepClock.Step);
director.Step(FixedStepClock.Step);
for (var i = 0; i < buttons.Length; i++) pressed[i] |= buttons[i].Animation == "DOWN";
sawFullyOpen |= MathF.Abs(bars.Position.Y - closedY - amount) < .01f;
}
static void Require(bool condition, string message)
{
if (!condition) throw new InvalidOperationException(message);
}
+33
View File
@@ -0,0 +1,33 @@
"""Original NC-shape registration and source corpus regression."""
from pathlib import Path
import sys
import unittest
PROJECT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(PROJECT / 'tools/binary'))
from water_collision_evidence import evidence, static_shape_enabled
class WaterCollisionTests(unittest.TestCase):
def test_original_instructions_and_lab_shape_count(self):
result = evidence()
self.assertEqual(result['instruction_checks'], 9)
self.assertEqual(result['vtable_checks'], 2)
lab = result['scenes']['level1b']
self.assertEqual(lab['excluded_shapes'], [dict(id=94, name='ncwater', triangles=18)])
self.assertEqual(lab['source_triangles'], 2869)
self.assertEqual(lab['registered_triangles'], 2851)
self.assertEqual(lab['registered_null_material_triangles'], 325)
self.assertEqual(result['scenes']['VR04']['excluded_shapes'], [])
outside = result['scenes']['level1']
self.assertEqual(outside['source_triangles'] - outside['registered_triangles'], 24)
def test_rule_is_shape_prefix_not_material_or_substring(self):
for name in ('ncwater', 'NCwater', 'Ncwater', 'nCwater', 'nc', 'NC'):
self.assertFalse(static_shape_enabled(name), name)
for name in ('', 'n', 'c', 'water', 'waternc', 'wall_nc', 'Box06', 'phoneblock'):
self.assertTrue(static_shape_enabled(name), name)
if __name__ == '__main__':
unittest.main()