Recover Grappler aim gating and implement verified ray constraint components

This commit is contained in:
UnixNight committed 2026-11-03 22:22:45 -05:00
1 parent 0c913d15aa
commit ffea678e90
21 files changed
+1604 -16

No files matched your search

+9 -5
View File
@@ -46,11 +46,15 @@ changes. Current gadget controls/resources/primary-fire findings belong in
docs/gameplay/. Distinguish static recovery, implementation, port tests and original docs/gameplay/. Distinguish static recovery, implementation, port tests and original
runtime evidence. Main owns integration/runtime; gadget investigators have runtime evidence. Main owns integration/runtime; gadget investigators have
exclusive named files, not shared directories. exclusive named files, not shared directories.
Latest gadget continuation: docs/gameplay/grappler-component.md. GrapplerMotion Latest gadget continuation: docs/gameplay/grappler-query.md. GrapplerMotion,
is isolated:30 copied-original scalar observations,5 managed/14 Python groups, GrapplerGeometry and boundedVR08 GrapplerRay remain outside live simulation:
existing25 movement/15 gadget groups and main build pass. Ray/body/camera/helper 72 copied-original observations,10 managed/18 Python groups,11 camera groups,
gates remain before liveVR08. Source and REA artifacts are retained under 13 Rocketship groups and main build pass. ActualVR08 ray/material tests pass;
artifacts/grappler-{ray,motion,resources,scalars}/; all ownership returned after lab GPU readback unchanged and VR08 preview validates. Aim rejection ends active
input before the attachment leaf; do not implement a hidden-cursor bypass.
Shared body context/base contact, camera and helper presentation/lifetime
remain gates before liveVR08. Source and REA artifacts are retained under
artifacts/grappler-{ray,motion,resources,scalars,query}/; all ownership returned after
investigator usage limits. No approximate hook/pull mechanic is enabled. investigator usage limits. No approximate hook/pull mechanic is enabled.
The user clarified orbit's remaining issue was inverted Left/Right; Left/A and The user clarified orbit's remaining issue was inverted Left/Right; Left/A and
Right/D azimuth mappings are corrected, Up/Down unchanged. Playable packages Right/D azimuth mappings are corrected, Up/Down unchanged. Playable packages
+8
View File
@@ -290,3 +290,11 @@ GrapplerMotion implements the isolated attachment/reel/damping arithmetic and
independent fire/jump detach predicate, compared with30 copied-original cases. independent fire/jump detach predicate, compared with30 copied-original cases.
It owns no body/ray/camera/helper lifetime and is not called by live simulation; It owns no body/ray/camera/helper lifetime and is not called by live simulation;
integration gates and retained source/REA findings are in gameplay/grappler-component.md. integration gates and retained source/REA findings are in gameplay/grappler-component.md.
GrapplerGeometry adds source aim early-return/rope-constraint/post-base contact
rules. GrapplerRay binds the verifiedVR08 static profile and captures selected
polygon/material with the hit via OriginalCameraRay.TraceSelectedGeometry, which
is independent of camera debug disabling. No live simulation calls these yet.
The active-input return must gate later primary dispatch while normal Jimmy frame
publication continues. Shared collision context/base contact and helper/camera
ownership remain integration work; see gameplay/grappler-query.md.
+8
View File
@@ -3,6 +3,14 @@
Compilation, native runtime, original behavior and full feature completion are Compilation, native runtime, original behavior and full feature completion are
separate evidence categories. **The game is not fully reconstructed/playable yet.** separate evidence categories. **The game is not fully reconstructed/playable yet.**
Grappler query/constraint checkpoint:42 new copied-original observations (72
total),10 managed/18 Python groups,11 camera/13 Rocketship groups and main build
pass. ActualVR08 ray/filter/material integration works in tests. Lab gameplay
readback is byte-identical; lab and VR08 geometry preview render with enabled
Vulkan validation, zero errors.539 original hashes verify. Attached world-body/
base-contact composition, camera and helper presentation/lifetime remain open;
Grappler is not live and playable packages remain70cba65. See gameplay/grappler-query.md.
Grappler scalar checkpoint:30 copied-original Wine32 observations match5 managed Grappler scalar checkpoint:30 copied-original Wine32 observations match5 managed
groups,14 Python source/projection checks,25 movement/15 gadget groups and main groups,14 Python source/projection checks,25 movement/15 gadget groups and main
build pass. No live Grappler, new Vulkan path or original/native Windows gameplay build pass. No live Grappler, new Vulkan path or original/native Windows gameplay
+9 -2
View File
@@ -270,9 +270,16 @@
left-handed view/projection; apply the shared Vulkan Y correction only once. left-handed view/projection; apply the shared Vulkan Y correction only once.
Regress screen right/up and depth across camera poses, not frame presence Regress screen right/up and depth across camera poses, not frame presence
alone. The modern inspector is separate from recovered original camera logic. alone. The modern inspector is separate from recovered original camera logic.
46. **Keep Grappler cursor/attachment and input/normal gates distinct.** Cursor 46. **Keep Grappler cursor/attachment and input/normal gates distinct.** The leaf
distance/material rejection does not prevent attachment on a ray hit. attachment helper lacks cursor filters, but aim's earlier true return ends
active input before that helper. Do not interpret it as a rejection bypass.
Attached input may return early while ordinary Jimmy frame publication still Attached input may return early while ordinary Jimmy frame publication still
runs. Compare isolated sqrt/first-scale/reel/damping with original snippets runs. Compare isolated sqrt/first-scale/reel/damping with original snippets
before composing body/camera/helper ownership; do not invent250 clamps or a before composing body/camera/helper ownership; do not invent250 clamps or a
detach impulse. GrapplerMotion remains isolated until those gates close. detach impulse. GrapplerMotion remains isolated until those gates close.
47. **Keep Grappler query metadata and component boundaries explicit.** Capture
the actual first selected polygon/material with its hit. Preserve root versus
swing-pivot origins, quick-magnitude constraint order and strict>60 contact
detach. Native aim/constraint/post-base suffix probes do not establish the
full body context, base contact, camera or helper lifecycle; close those
contracts before liveVR08. See gameplay/grappler-query.md.
+4
View File
@@ -1,5 +1,9 @@
# Grappler scalar checkpoint # Grappler scalar checkpoint
Continuation: [aim/constraint/contact checkpoint](grappler-query.md) adds42
original component observations and corrects the enclosing aim→primary gate.
The attachment leaf's broad acceptance does not bypass aim's earlier return.
2026-11-03. Continues user-requested gadgets after the Rocketship/orbit fixes. 2026-11-03. Continues user-requested gadgets after the Rocketship/orbit fixes.
The latest playable packages include the orbit Left/Right correction70cba65. The latest playable packages include the orbit Left/Right correction70cba65.
GrapplerMotion is an isolated component; no live equip/ray/swing/camera path is GrapplerMotion is an isolated component; no live equip/ray/swing/camera path is
+120
View File
@@ -0,0 +1,120 @@
# Grappler aim, constraint and contact checkpoint
2026-11-03. Continues [scalar checkpoint](grappler-component.md). Adds a bounded
VR08 ray/material adapter and isolated aim/rope-constraint/post-base contact
implementation. **Grappler is not enabled in live gameplay yet.** The next gates
are shared body collision state, camera and helper presentation/lifetime.
## Corrected active-input ownership
The attachment leaf426A70 accepts a ray hit without repeating the cursor filter.
That does not mean ordinary input can attach to every hidden-cursor surface:
- 426084 calls438A60 input, then426098 calls complete188→429D00.
- 42609E tests AL;4260A0 branches to4269C3 on true.4269C3..4269CD is a direct
epilogue/return, before later primary1C0→426A70 at4266C8.
- Aim distance<450 hides the cursor and returns true; rejected material does
the same. Both therefore end the remaining active-input pass. Ordinary Jimmy
normal/frame publication still runs separately, as previously recovered.
- The rejected-material branch42A4F8..42A535 may subtract250*dt when held fire
or consuming Enter46A3E0(13) accepts and old rope length>250. The close-distance
branch does not execute that reeling. Neither adds a final length clamp.
- 42A7A0 already polls Enter among primary inputs; the extra consuming Enter path
is separate and short-circuited when the primary predicate is true. The managed
component receives those predicates; keyboard state consumption belongs to its
future caller, not this pure geometry API.
This corrects the earlier interpretation that cursor rejection could simply be
bypassed by held primary. No live behavior had been connected to that assumption.
GrapplerAim.EndsActiveInput records the enclosing return, rather than only whether
a fire button happened to be held.
## Source evidence and implemented scope
Authoritative EXE f5281076…1aea8 and OMT2.dll3ec41ead…54943 are required by
`tools/binary/grappler_query.py`. Full hashes, each span hash/file offset and the
native generator/executable/log identities are in the committed numeric fixture.
Text file offsets below are VA−400000. Runtime globals are not file offsets.
| Source span, exclusive end | File offset | Contract |
| --- | --- | --- |
|42A406..42A652|2A406|Aim hit/miss, strict450 threshold, selected polygon/material/definition distinction, blocked ranges, cursor point and early return.|
|429EA0..429FA4|29EA0|Anchor minus root+116, X/Z perturbation by swing*dt*30, original DLL quick-magnitude normalization, rope-length constraint and desired root before body clipping.|
|42A69B..42A6F1|2A69B|After base contact, zero swing X/Z; only sqrt(X²+Z²)>60 dispatches detach and sets Jimmy action latch1E25.|
|426030..4260A6,4269C3..4269CD|26030,269C3|Input→aim→true-return gate, separate from later primary helper.|
|42A7A0..42A7D6,46A3E0..46A3FB|2A7A0,6A3E0|Primary held predicate and consuming key-array read.|
Selected polygon global695D54 points to material+4, definition+0C, ID+8; global
5CFC60 holds the hit point. Missing polygon or definition passes the material
gate; present polygon without a material blocks. IDs60..69,80..89,210..219,−1,170
block. Visible cursor position uses hit−100*normalized(full ray), not normalized
hit offset. Normalization uses the original quantized quick_magnitude.
VR08 constructor's game table4D00D0 has slot134 at4D0204→475CD0, whose exact
bytes32C0C21800 return false while popping its24-byte arguments. Therefore the
existing NC/checkpoint admission and wall-first/grid/FIFO query are valid there.
Actual VR08 has240 polygons and only collision material IDs0/2/3/4, all ordinary.
GrapplerRay rejects other levels/profiles instead of inventing material context.
It queries the actual root and full-Euler local(0,2400,2400), not root+116.
OriginalCameraRay.TraceSelectedGeometry captures hit plus original polygon
metadata together. It uses the existing traversal and is independent of the
modern camera query toggle. Camera-only disabling must not disable gadget rays.
Tests retain a farther first-hit blocked material instead of silently selecting a
nearer allowed material. No global source state is manufactured from cursor art.
The source constraint stores normalized X/Y before scaling, while Z retains its
unrounded intermediate. Managed code preserves that order with double arithmetic;
general x87 identity remains unclaimed. Zero-vector normalization is explicitly
outside the finite modern component boundary (the source produces nonfinite
geometry); it is not silently repaired with a new position.
## Original-code and port verification
`grappler_query_probe.c` copies three bounded EXE slices into private memory,
relocates whitelisted operands, calls our copied original DLL quick_magnitude,
and supplies synthetic ray/material/cursor/primary/detach accessors. It never
runs the game entrypoint, actual world ray traversal, body dispatcher, base
contact43AA40, camera, rope renderer or full detach lifecycle. The constraint
exits before47B4B0; impact starts after43AA40. These bounds matter.
42 observations complete in the isolated copied Wine32 environment with no
network or Original mount:23 aim,10 constraint and9 post-base impact cases.
Combined with the previous30 scalar observations,72 copied-original observations are
checked by10 managed groups. New vector tolerance is.004 units (including large
coordinates); scalar checkpoint retains.0002. Flags and owner/gate states compare
exactly. The actual VR08 authored start yields two cardinal aiming hits with
retained material identities. No original gameplay/render comparison is claimed.
18 Python Grappler source/projection/evidence groups,11 existing camera groups,
13 Rocketship groups and main .NET10 build pass. Final two-frame lab gameplay
readback is byte-identical to the prior corrected-camera baseline. Actual VR08
geometry preview also renders two frames; both runs enable Vulkan validation and
report zero errors.539 original files verify unchanged. No new gameplay package
was needed; playable packages remain70cba65.
Logs: artifacts/grappler-query/{probe/wine.log,probe/capture.json,managed-final.log,
python.log,camera.log,rocketship.log,build-final.log,gameplay.log,vr08.log,
originals.log}. One synthetic first-hit test initially used the opposite of the
source winding; its failed log is retained and the fixture winding was corrected.
The first leaf guard expected a plain return, then was corrected to the actual
stdcall24-byte return before importing references.
REA's existing47C210 evidence
ev_ff5aab3bdc275e6626753743a3567a556f698209ad9f65689cf49a4b5f56107d
and43AA40/47B4B0 evidence in grappler-component.md remain supporting static
records. A new local REA/Ghidra426030 pseudocode query was not recognized; the
complete error/export/closed snapshot are retained in
artifacts/grappler-live/rea-input/. No repeated selector/config repair or
successful pseudocode is claimed. Exact guarded caller bytes plus the copied
aim execution establish the early-return correction.
## Next integration
Carry the original shared sphere/selected-contact context across ordinary
physics and the attached47B4B0 call, including42A660→43AA40. Do not treat the
post-base contact suffix alone as full collision integration. Then finish helper
rope/cursor material/transforms, follow-camera fields and equip/detach/control
loss/RETURN persistence. The cursor's retainedsprites Canv8 is already exported
for Baseball; rope HIROPE→rope01.ASE still needs a verified runtime binding.
Only then enable boundedVR08 with input-driven attach/reel/swing/detach checks.
+5
View File
@@ -2,6 +2,9 @@
Continuation: [scalar implementation and30 copied-original cases](grappler-component.md). Continuation: [scalar implementation and30 copied-original cases](grappler-component.md).
The component remains isolated; live ray/body/camera/helper gates below still apply. The component remains isolated; live ray/body/camera/helper gates below still apply.
Later [aim/constraint checkpoint](grappler-query.md) proves the enclosing input
gate:429D00 returning true prevents later primary attachment dispatch. The leaf
helper's lack of duplicate material checks must not be read as a bypass.
2026-11-03. Item7/raw7, using the supplied target6 decompiler bodies as leads, 2026-11-03. Item7/raw7, using the supplied target6 decompiler bodies as leads,
then independently reading the hashed EXE instructions. No friend gameplay code then independently reading the hashed EXE instructions. No friend gameplay code
@@ -79,6 +82,8 @@ precedes that shared zero-energy reject. Do not add an energy cost from menu ind
Polygon without material blocks; material without definition passes this test; Polygon without material blocks; material without definition passes this test;
absent selected polygon passes it. A valid cursor is placed100 back from the absent selected polygon passes it. A valid cursor is placed100 back from the
hit along ray direction. This is not a query for the nearest3GRA entity. hit along ray direction. This is not a query for the nearest3GRA entity.
Its true return at close/rejected surfaces ends426030 before primary dispatch;
rejected-material held fire/consuming Enter may still reel the existing length.
- **Attach / held primary:**426A70 returns false outside raw7; otherwise consumes - **Attach / held primary:**426A70 returns false outside raw7; otherwise consumes
primary even on a miss. While unattached it stops+A3C, repeats the root/local primary even on a miss. While unattached it stops+A3C, repeats the root/local
point ray, stores hit anchor, sets current length=distance(root,hit)−100. point ray, stores hit anchor, sets current length=distance(root,hit)−100.
+24 -2
View File
@@ -1,5 +1,27 @@
# Progress — 2026-11-03 # Progress — 2026-11-03
## Grappler ray, constraint and contact checkpoint
Added boundedVR08 GrapplerRay and first-hit polygon/material capture, plus aim
gating, quick-magnitude rope constraint and post-base contact response.42 new
copied-original cases (23 aim/10 constraint/9 impact) match; with earlier30,
10 managed groups cover72 observations.18 Python,11 camera/13 Rocketship groups
and .NET10 build pass. ActualVR08 authored-start rays hit with correct metadata;
lab gameplay readback remains byte-identical and actualVR08 preview renders with
enabled Vulkan validation, zero errors.539 originals unchanged.
Important correction: the attach leaf's lack of duplicate material filters does
not bypass aim rejection.426098..4260A0 ends active input on429D00's true return;
close/rejected surfaces therefore prevent later primary dispatch. Rejected
material may reel before returning; close distance does not. Strict>60 post-base
contact detach and normalized source rope offsets are independently probed.
Source/evidence/limits: [grappler-query.md](gameplay/grappler-query.md).
No live Grappler or package update is claimed. Next: shared47B4B0 collision state
and43AA40 composition, follow camera, rope/cursor render+reset/lifetime, then
boundedVR08 live attach/reel/swing/detach/control-loss/RETURN. Pure constraint and
post-base suffixes do not establish those integrations. Playable70cba65 retained.
## Grappler scalar checkpoint ## Grappler scalar checkpoint
Implemented isolated GrapplerMotion attachment length/first-scale, held/fast reel, Implemented isolated GrapplerMotion attachment length/first-scale, held/fast reel,
@@ -26,8 +48,8 @@ Build/package validation follows in orbit-camera.md.
Grappler is the next gadget. Independent investigations retained REA/source Grappler is the next gadget. Independent investigations retained REA/source
artifacts before reaching usage limits; primary owns all files again. Preserve artifacts before reaching usage limits; primary owns all files again. Preserve
artifacts/grappler-{ray,motion,resources}/. Important recovered leads: attach uses artifacts/grappler-{ray,motion,resources}/. Important recovered leads: the attach
any ray hit and does not repeat cursor distance/material rejection; VR08 slot134 leaf uses any ray hit, but earlier aim rejection can prevent its dispatch; VR08 slot134
returns false through475CD0; root-local ray discards the swing pivot+116. Attach returns false through475CD0; root-local ray discards the swing pivot+116. Attach
uses x87 sqrt, swing normalization uses OMTquick magnitude; ordinary437940 frame uses x87 sqrt, swing normalization uses OMTquick magnitude; ordinary437940 frame
still runs after the swing input short-circuit. Rope is HIROPE→rope01.ASE with still runs after the swing input short-circuit. Rope is HIROPE→rope01.ASE with
+6
View File
@@ -5,6 +5,12 @@ offsets, virtual addresses, API symbols or observed behavior. Decompiled output
evidence, not original source. Original gameplay has not yet been observed successfully; isolated original DLL evidence, not original source. Original gameplay has not yet been observed successfully; isolated original DLL
probes and modern runtime checks are recorded separately. probes and modern runtime checks are recorded separately.
- `gameplay/grappler-query.md`: enclosing426030 early-return correction,
VR08 static filter/selected-material metadata,42 copied-original aim/constraint/
post-base contact cases and corresponding managed components. The attachment
leaf's broad acceptance does not bypass earlier aim rejection. Full attached
body/base-contact, camera and helper presentation/lifetime remain separate.
- `gameplay/grappler-component.md`:30 copied-original attachment/reel/damping - `gameplay/grappler-component.md`:30 copied-original attachment/reel/damping
observations, isolated managed component and retained ray/body/resource REA observations, isolated managed component and retained ray/body/resource REA
evidence. Cursor rejection differs from attach acceptance, and input swing evidence. Cursor rejection differs from attach acceptance, and input swing
+7
View File
@@ -46,6 +46,13 @@ compile, runtime and original-fidelity verification are separate.
## Immediate continuation ## Immediate continuation
- [x] Grappler aim/root-Euler ray/first-hit material, normalized constraint and
post-base contact:42 additional original cases,72 total/10 managed/18 Python;
actualVR08 query and existing camera/Rocketship/GPU regressions pass.
- [ ] Grappler live gates: carry shared sphere/contact context through attached
47B4B0 and43AA40; complete follow camera and rope/cursor presentation/lifetime,
then actualVR08 attach/reel/swing/detach/control-loss/RETURN. See grappler-query.md.
- [x] User-clarified orbit Left/Right inversion: reverse horizontal azimuth - [x] User-clarified orbit Left/Right inversion: reverse horizontal azimuth
mapping while preserving correct Up/Down and gameplay controls. mapping while preserving correct Up/Down and gameplay controls.
- [x] Grappler isolated attachment/reel/damping component:30 copied-original - [x] Grappler isolated attachment/reel/damping component:30 copied-original
+69
View File
@@ -0,0 +1,69 @@
using System.Numerics;
namespace GamePort.Game;
public readonly record struct GrapplerSurface(bool PolygonPresent,bool MaterialPresent,bool DefinitionPresent,int MaterialId)
{
public bool BlocksCursor=>PolygonPresent&&(!MaterialPresent||DefinitionPresent&&
(MaterialId is >=60 and <=69 or >=80 and <=89 or >=210 and <=219 or -1 or 170));
}
public readonly record struct GrapplerAim(bool CursorVisible,bool EndsActiveInput,Vector3 CursorPosition,float Length);
public readonly record struct GrapplerConstraint(Vector3 Offset,Vector3 DesiredRoot);
public readonly record struct GrapplerContact(GrapplerSwing Swing,bool Detach);
/// <summary>429D00 aim/constraint and42A69B post-base contact contracts.
/// Caller still owns registry phases, actual body callbacks, camera and helpers.</summary>
public static class GrapplerGeometry
{
public static GrapplerAim Aim(Vector3 root,Vector3 endpoint,Vector3? hit,GrapplerSurface surface,
bool fire,bool enter,float length,float seconds)
{
Finite(root);Finite(endpoint);
GrapplerMotion.Finite(length);GrapplerMotion.Time(seconds);
if(hit is not{} point)return new(false,false,default,length);
Finite(point);
double x=(double)point.X-root.X,y=(double)point.Y-root.Y,z=(double)point.Z-root.Z;
if(Math.Sqrt(x*x+y*y+z*z)<450)return new(false,true,default,length);
if(surface.BlocksCursor)
return new(false,true,default,fire||enter?GrapplerMotion.HeldReel(length,seconds):length);
var delta=endpoint-root;
double inverse=InverseMagnitude(delta);
var offset=new Vector3((float)((double)(float)(delta.X*inverse)*100),
(float)((double)(float)(delta.Y*inverse)*100),(float)(delta.Z*inverse*100));
return new(true,false,point-offset,length);
}
public static GrapplerConstraint Constrain(Vector3 root,Vector3 anchor,GrapplerSwing swing,float length,float seconds)
{
Finite(root);Finite(anchor);
Validate(swing);GrapplerMotion.Finite(length);GrapplerMotion.Time(seconds);
var pivot=root+Vector3.UnitY*116;
var delta=new Vector3((float)((float)(anchor.X-pivot.X)+(double)swing.X*seconds*30),
anchor.Y-pivot.Y,(float)(((double)anchor.Z-pivot.Z)+(double)swing.Z*seconds*30));
double inverse=InverseMagnitude(delta);
var offset=new Vector3((float)((double)(float)(delta.X*inverse)*length),
(float)((double)(float)(delta.Y*inverse)*length),(float)(delta.Z*inverse*length));
return new(offset,new(anchor.X-offset.X,(float)(anchor.Y-((double)offset.Y+116)),anchor.Z-offset.Z));
}
public static GrapplerContact Contact(GrapplerSwing swing)
{
Validate(swing);
double x=swing.X,z=swing.Z;
return new(new(0,0,swing.Elapsed),Math.Sqrt(x*x+z*z)>60);
}
private static double InverseMagnitude(Vector3 vector)
{
var magnitude=OriginalBodySupport.QuickMagnitude(vector);
if(magnitude<=0)throw new NotSupportedException("Source zero-vector normalization produces nonfinite geometry");
return 1d/magnitude;
}
private static void Finite(Vector3 vector)
{
if(!float.IsFinite(vector.X)||!float.IsFinite(vector.Y)||!float.IsFinite(vector.Z))
throw new ArgumentOutOfRangeException(nameof(vector));
}
private static void Validate(GrapplerSwing swing)
{GrapplerMotion.Finite(swing.X);GrapplerMotion.Finite(swing.Z);GrapplerMotion.Finite(swing.Elapsed);}
}
+3 -3
View File
@@ -52,13 +52,13 @@ public static class GrapplerMotion
public static bool JumpDetaches(bool jumpHeld,bool fireHeld,bool attached)=>jumpHeld&&!fireHeld&&attached; public static bool JumpDetaches(bool jumpHeld,bool fireHeld,bool attached)=>jumpHeld&&!fireHeld&&attached;
private static void Time(float value) internal static void Time(float value)
{ {
if(!float.IsFinite(value)||value<0||value>=1)throw new ArgumentOutOfRangeException(nameof(value)); if(!float.IsFinite(value)||value<0||value>=1)throw new ArgumentOutOfRangeException(nameof(value));
} }
private static void Finite(float value) internal static void Finite(float value)
{ {
if(!float.IsFinite(value))throw new ArgumentOutOfRangeException(nameof(value)); if(!float.IsFinite(value))throw new ArgumentOutOfRangeException(nameof(value));
} }
private static void Finite(Vector3 value){Finite(value.X);Finite(value.Y);Finite(value.Z);} internal static void Finite(Vector3 value){Finite(value.X);Finite(value.Y);Finite(value.Z);}
} }
+30
View File
@@ -0,0 +1,30 @@
using System.Numerics;
using GamePort.Assets;
namespace GamePort.Game;
/// <summary>Bounded VR08 root/full-Euler ray and first-hit material snapshot.
/// Aiming's early return must gate later primary-fire attachment dispatch.</summary>
public sealed class GrapplerRay
{
private readonly OriginalCameraRay geometry;
public GrapplerRay(Mesh world,string level)
{
ArgumentNullException.ThrowIfNull(world);
if(level!="VR08")throw new NotSupportedException("Grappler ray admission currently covers VR08");
if(!world.HasCollisionMaterialIds||world.CollisionPolygons.Any(p=>p.MaterialId is not(0 or 2 or 3 or 4)))
throw new NotSupportedException("VR08 requires its verified material/definition profile");
geometry=OriginalCameraRay.FromRouteScene(world,level);
}
public Vector3 Endpoint(Vector3 root,Vector3 rotation)=>root+RocketOrientation.Rotate(new(0,2400,2400),rotation);
public CameraRaySelection? Trace(Vector3 root,Vector3 rotation)=>geometry.TraceSelectedGeometry(root,Endpoint(root,rotation));
public GrapplerAim Aim(Vector3 root,Vector3 rotation,bool fire,bool enter,float length,float seconds)
{
var endpoint=Endpoint(root,rotation);
var selection=geometry.TraceSelectedGeometry(root,endpoint);
var surface=selection is{} s?new GrapplerSurface(true,true,true,s.Polygon.MaterialId!.Value):default;
return GrapplerGeometry.Aim(root,endpoint,selection?.Hit.Position,surface,fire,enter,length,seconds);
}
}
+14 -3
View File
@@ -6,6 +6,7 @@ namespace GamePort.Game;
public readonly record struct CameraRayPolygon(SupportTriangle Triangle, Vector3 StoredNormal, public readonly record struct CameraRayPolygon(SupportTriangle Triangle, Vector3 StoredNormal,
string? ShapeName = null, string? MaterialName = null, int? MaterialId = null); string? ShapeName = null, string? MaterialName = null, int? MaterialId = null);
public readonly record struct CameraRayResult(Vector3 Eye, float Gain, SupportHit? Hit); public readonly record struct CameraRayResult(Vector3 Eye, float Gain, SupportHit? Hit);
public readonly record struct CameraRaySelection(SupportHit Hit, CameraRayPolygon Polygon);
/// <summary> /// <summary>
/// Source47C210 static camera predicate: first accepted wall-grid polygon, then /// Source47C210 static camera predicate: first accepted wall-grid polygon, then
@@ -20,6 +21,7 @@ public sealed class OriginalCameraRay
public const float CellOrigin = 130; //49B1FC. public const float CellOrigin = 130; //49B1FC.
private readonly Dictionary<int, List<SupportTriangle>> walls = []; private readonly Dictionary<int, List<SupportTriangle>> walls = [];
private readonly Dictionary<int, List<SupportTriangle>> all = []; private readonly Dictionary<int, List<SupportTriangle>> all = [];
private readonly Dictionary<(int Shape,int Polygon),CameraRayPolygon> sources = [];
public bool Enabled { get; set; } = true; // Modern camera-only debug override. public bool Enabled { get; set; } = true; // Modern camera-only debug override.
public int PolygonCount { get; } public int PolygonCount { get; }
public int WallPolygonCount { get; } public int WallPolygonCount { get; }
@@ -44,6 +46,7 @@ public sealed class OriginalCameraRay
RequireFinite(polygon.StoredNormal); RequireFinite(polygon.StoredNormal);
if (!identities.Add((triangle.ShapeId, triangle.PolygonId))) if (!identities.Add((triangle.ShapeId, triangle.PolygonId)))
throw new InvalidDataException("Camera query needs one source triangle per polygon; fan-triangulated polygons are unsupported"); throw new InvalidDataException("Camera query needs one source triangle per polygon; fan-triangulated polygons are unsupported");
sources.Add((triangle.ShapeId,triangle.PolygonId),polygon);
var wall = polygon.StoredNormal.Y < .7f; //4798B3; equality excluded. var wall = polygon.StoredNormal.Y < .7f; //4798B3; equality excluded.
var min = Vector3.Min(triangle.A, Vector3.Min(triangle.B, triangle.C)); var min = Vector3.Min(triangle.A, Vector3.Min(triangle.B, triangle.C));
var max = Vector3.Max(triangle.A, Vector3.Max(triangle.B, triangle.C)); var max = Vector3.Max(triangle.A, Vector3.Max(triangle.B, triangle.C));
@@ -59,15 +62,15 @@ public sealed class OriginalCameraRay
/// <summary> /// <summary>
/// Route/tutorial complete game slot134 is475CD0 (false), including VR02's /// Route/tutorial complete game slot134 is475CD0 (false), including VR02's
///4CDD30 table (rocketship.md), so only the proven ///4CDD30 and VR08's4D00D0 tables, so only the proven
/// NC/checkpoint gates apply. Reject other levels rather than inventing masks. /// NC/checkpoint gates apply. Reject other levels rather than inventing masks.
/// Prepared source metadata is required; raw render visibility is irrelevant. /// Prepared source metadata is required; raw render visibility is irrelevant.
/// </summary> /// </summary>
public static OriginalCameraRay FromRouteScene(Mesh mesh, string levelCode) public static OriginalCameraRay FromRouteScene(Mesh mesh, string levelCode)
{ {
ArgumentNullException.ThrowIfNull(mesh); ArgumentNullException.ThrowIfNull(mesh);
if (levelCode is not ("LV1B" or "VR01" or "VR02" or "VR04" or "VR07" or "LEV1")) if (levelCode is not ("LV1B" or "VR01" or "VR02" or "VR04" or "VR07" or "VR08" or "LEV1"))
throw new NotSupportedException("Static camera game-filter recovery covers the route and VR01"); throw new NotSupportedException("Static camera game-filter recovery covers only selected route/tutorial scenes");
if (mesh.Indices.Length % 3 != 0 || mesh.CollisionPolygons.Length != mesh.Indices.Length / 3) if (mesh.Indices.Length % 3 != 0 || mesh.CollisionPolygons.Length != mesh.Indices.Length / 3)
throw new InvalidDataException("Original camera query requires source polygon metadata"); throw new InvalidDataException("Original camera query requires source polygon metadata");
var polygons = new CameraRayPolygon[mesh.CollisionPolygons.Length]; var polygons = new CameraRayPolygon[mesh.CollisionPolygons.Length];
@@ -100,6 +103,14 @@ public sealed class OriginalCameraRay
return TraceCore(start, end, twoSided, diagnostic: false); return TraceCore(start, end, twoSided, diagnostic: false);
} }
/// <summary>Capture47C210's hit and selected polygon/material together.
/// This geometry query is independent of the modern camera debug toggle.</summary>
public CameraRaySelection? TraceSelectedGeometry(Vector3 start,Vector3 end,bool twoSided=false)
{
var hit=TraceGeometry(start,end,twoSided);
return hit is{} h?new(h,sources[(h.ShapeId,h.PolygonId)]):null;
}
private SupportHit? TraceCore(Vector3 start, Vector3 end, bool twoSided, bool diagnostic) private SupportHit? TraceCore(Vector3 start, Vector3 end, bool twoSided, bool diagnostic)
{ {
foreach (var grid in new[] { walls, all }) foreach (var grid in new[] { walls, all })
@@ -3,7 +3,15 @@
<ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><EnableDefaultCompileItems>false</EnableDefaultCompileItems></PropertyGroup> <ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><EnableDefaultCompileItems>false</EnableDefaultCompileItems></PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs"/> <Compile Include="Program.cs"/>
<Compile Include="QueryReferences.cs"/>
<Compile Include="../../src/GamePort/Game/GrapplerMotion.cs"/> <Compile Include="../../src/GamePort/Game/GrapplerMotion.cs"/>
<Compile Include="../../src/GamePort/Game/GrapplerGeometry.cs"/>
<Compile Include="../../src/GamePort/Game/GrapplerRay.cs"/>
<Compile Include="../../src/GamePort/Game/OriginalCameraRay.cs"/>
<Compile Include="../../src/GamePort/Game/OriginalBodySupport.cs"/>
<Compile Include="../../src/GamePort/Game/RocketOrientation.cs"/>
<Compile Include="../../src/GamePort/Assets/*.cs"/>
<None Include="original-scalar-reference.json" CopyToOutputDirectory="PreserveNewest"/> <None Include="original-scalar-reference.json" CopyToOutputDirectory="PreserveNewest"/>
<None Include="original-query-reference.json" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup> </ItemGroup>
</Project> </Project>
+2 -1
View File
@@ -52,7 +52,8 @@ Reject(()=>GrapplerMotion.HeldReel(300,-.1f));Reject(()=>GrapplerMotion.FastReel
Reject(()=>GrapplerMotion.Attach(new(float.PositiveInfinity,0,0),Vector3.Zero,Vector3.Zero)); Reject(()=>GrapplerMotion.Attach(new(float.PositiveInfinity,0,0),Vector3.Zero,Vector3.Zero));
Reject(()=>GrapplerMotion.Swing(new(0,0,float.NaN),.1f,0,0,400)); Reject(()=>GrapplerMotion.Swing(new(0,0,float.NaN),.1f,0,0,400));
Console.WriteLine("PASS nonfinite and unsupported timestep boundaries"); Console.WriteLine("PASS nonfinite and unsupported timestep boundaries");
Console.WriteLine("Grappler:5 scalar groups; ray/body/camera/lifetime and live VR08 integration remain separate gates."); QueryReferences.Run();
Console.WriteLine("Grappler:10 groups,72 original component observations; body composition/camera/lifetime and live VR08 integration remain separate gates.");
static void Check(bool ok,string message){if(!ok)throw new Exception(message);} static void Check(bool ok,string message){if(!ok)throw new Exception(message);}
static void Near(float actual,float expected,string message)=>Check(float.IsFinite(actual)&&MathF.Abs(actual-expected)<.0002f,$"{message}: {actual} != {expected}"); static void Near(float actual,float expected,string message)=>Check(float.IsFinite(actual)&&MathF.Abs(actual-expected)<.0002f,$"{message}: {actual} != {expected}");
@@ -0,0 +1,76 @@
using System.Numerics;
using System.Text.Json;
using GamePort.Assets;
using GamePort.Game;
static class QueryReferences
{
public static void Run()
{
using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-query-reference.json")));
var cases=doc.RootElement.GetProperty("cases").EnumerateArray().ToArray();Check(cases.Length==42,"42 query/constraint/contact cases");
foreach(var c in cases)
{
var p=c.GetProperty("input").EnumerateArray().Select(x=>x.GetSingle()).ToArray();
var o=c.GetProperty("observed").EnumerateArray().Select(x=>x.GetSingle()).ToArray();
var name=c.GetProperty("kind").GetString()+"/"+c.GetProperty("name").GetString();
switch(c.GetProperty("kind").GetString())
{
case "aim":
var a=GrapplerGeometry.Aim(Vector3.Zero,new(0,2400,2400),p[0]!=0?new Vector3(0,p[1],0):null,
new(p[2]!=1,p[2]!=2,p[2]!=3,(int)p[3]),p[4]!=0,p[5]!=0,p[6],p[7]);
Check(a.EndsActiveInput==(o[0]!=0)&&a.CursorVisible==(o[1]==0),name+" caller/visibility");
if(a.CursorVisible)Near(a.CursorPosition,new(o[3],o[4],o[5]),name+" cursor");
Near(a.Length,o[6],name+" length");break;
case "constraint":
var constraint=GrapplerGeometry.Constrain(new(p[0],p[1],p[2]),new(p[3],p[4],p[5]),new(p[6],p[7],0),p[8],p[9]);
Near(constraint.Offset,new(o[0],o[1],o[2]),name+" offset");
Near(constraint.DesiredRoot,new(o[3],o[4],o[5]),name+" root");break;
case "impact":
var impact=GrapplerGeometry.Contact(new(p[0],p[1],.75f));
Check(impact.Swing==new GrapplerSwing(o[0],o[1],.75f)&&impact.Detach==(o[2]!=0)
&&o[2]==o[3],name+" post-base clear/detach/latch");break;
default:throw new Exception("Unknown original query reference");
}
}
Console.WriteLine("PASS42 copied-original aim/constraint/post-base contact observations");
var blocked=GrapplerGeometry.Aim(Vector3.Zero,new(0,2400,2400),new(0,700,0),new(true,true,true,60),true,false,300,.1f);
Check(blocked.EndsActiveInput&&!blocked.CursorVisible&&blocked.Length==275,"blocked aim reels then skips later primary attachment");
var near=GrapplerGeometry.Aim(Vector3.Zero,new(0,2400,2400),new(0,449,0),new(true,true,true,0),true,false,300,.1f);
Check(near.EndsActiveInput&&near.Length==300,"close aim skips primary without blocked-material reel");
Console.WriteLine("PASS enclosing input gate distinguishes close/blocked aim from attachment helper acceptance");
CameraRayPolygon Wall(int shape,float z,int material)=>new(new(new(-100,-100,z),new(200,0,z),new(-100,100,z),shape,0),-Vector3.UnitZ,"wall","wall",material);
var query=new OriginalCameraRay([Wall(1,300,170),Wall(2,200,0)]);
var selected=query.TraceSelectedGeometry(Vector3.Zero,new(0,0,450));
Check(selected is{Polygon.MaterialId:170,Hit.ShapeId:1},"selected metadata follows first source hit, not nearer/allowed polygon");
query.Enabled=false;
Check(query.Trace(Vector3.Zero,new(0,0,450))==null&&query.TraceSelectedGeometry(Vector3.Zero,new(0,0,450))==selected,
"gameplay ray remains active when camera debug query is disabled");
Console.WriteLine("PASS first-hit material snapshot and camera-debug separation");
var world=Mesh.LoadSceneJson("artifacts/extracted/VR08/scene.json");
var level=GamLevel.Load("../Original/gam/VR08.gam");var root=level.FindStart()!.Position;var ray=new GrapplerRay(world,level.Code);
Check(ray.Endpoint(root,Vector3.Zero)==root+new Vector3(0,2400,2400),"aim uses actual root, not swing pivot+116");
int hits=0;
foreach(float yaw in new[]{0,90,180,270})
{
var rotation=new Vector3(0,yaw,0);var hit=ray.Trace(root,rotation);if(hit is not{} h)continue;
hits++;Check(h.Polygon.MaterialId is 0 or 2 or 3 or 4,"actual VR08 material context");
var aim=ray.Aim(root,rotation,true,false,0,1f/60);
Check(aim.CursorVisible||aim.EndsActiveInput,"actual ray reaches valid or close-surface gate");
}
Check(hits>0,"actual VR08 geometry produces authored-start aiming hits");
Console.WriteLine($"PASS actual VR08 root/Euler ray/filter/material integration ({hits} cardinal hits)");
Reject(()=>GrapplerGeometry.Constrain(Vector3.Zero,new(0,116,0),default,100,.1f));
Reject(()=>new GrapplerRay(world,"LV1B"));
Reject(()=>new GrapplerRay(world with{HasCollisionMaterialIds=false},"VR08"));
Console.WriteLine("PASS explicit zero-normalization and unsupported scene/profile boundaries");
}
static void Check(bool ok,string message){if(!ok)throw new Exception(message);}
static void Near(float a,float b,string name)=>Check(float.IsFinite(a)&&MathF.Abs(a-b)<.004f,$"{name}: {a} != {b}");
static void Near(Vector3 a,Vector3 b,string name){Near(a.X,b.X,name+" X");Near(a.Y,b.Y,name+" Y");Near(a.Z,b.Z,name+" Z");}
static void Reject(Action action){try{action();throw new Exception("Unsupported boundary accepted");}catch(NotSupportedException){}}
}
@@ -0,0 +1,971 @@
{
"source_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8",
"dll_sha256": "3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943",
"vr08_filter": {
"table": "0x4d00d0",
"slot": "0x134",
"target": "0x475cd0"
},
"ranges": [
{
"kind": "aim",
"va": "0x42a406",
"end_va": "0x42a652",
"file_offset": "0x2a406",
"sha256": "d0b7a01bce82ef7c94141f852a1886afe491953cbbf3d332382516fed58b6d79"
},
{
"kind": "constraint",
"va": "0x429ea0",
"end_va": "0x429fa4",
"file_offset": "0x29ea0",
"sha256": "ba61e38497f86c45071284b983e3709ea0ba9112b49d04295566ef8d58996097"
},
{
"kind": "impact_post_base",
"va": "0x42a69b",
"end_va": "0x42a6f1",
"file_offset": "0x2a69b",
"sha256": "14a425d42ab7cfe4c9fb754dc1c149dd0d91101a8d29ca568fbf3e5b89e1c1aa"
},
{
"kind": "input_gate",
"va": "0x426030",
"end_va": "0x4260a6",
"file_offset": "0x26030",
"sha256": "bf3bcca296c7fc5d3c7dd5e79bdd9311b5fcee7606842978346706dbdab9d1b7"
},
{
"kind": "input_return",
"va": "0x4269c3",
"end_va": "0x4269cd",
"file_offset": "0x269c3",
"sha256": "4602fb15bfda7c8828f0eb9f79612ce3fa9171720ad9b6751b2e982ead958c8a"
},
{
"kind": "primary_poll",
"va": "0x42a7a0",
"end_va": "0x42a7d6",
"file_offset": "0x2a7a0",
"sha256": "c8fa10f42eefe68a195d9980f1a57558a240cd7877bfeab567e7868c0ddf419f"
},
{
"kind": "consuming_enter",
"va": "0x46a3e0",
"end_va": "0x46a3fb",
"file_offset": "0x6a3e0",
"sha256": "3ed68398af88462b66579038c4687d79d2b00a0486babd28f8a5bdc33533a060"
},
{
"kind": "aim_return",
"va": "0x42a652",
"end_va": "0x42a660",
"file_offset": "0x2a652",
"sha256": "4c01c1dfa18487526b9b74e484c24ac294b19d80a8bcb403c12978c5965a99ba"
}
],
"scope": "Synthetic ray/material/cursor accessors; original DLL magnitude; constraint before body and contact after stubbed base; no game entrypoint",
"cases": [
{
"kind": "aim",
"name": "miss",
"input": [
0.0,
700.0,
0.0,
0.0,
1.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "near",
"input": [
1.0,
449.0,
0.0,
0.0,
1.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "equal",
"input": [
1.0,
450.0,
0.0,
0.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
0.0,
1.0,
0.0,
379.289307,
-70.7106781,
300.0
]
},
{
"kind": "aim",
"name": "far",
"input": [
1.0,
700.0,
0.0,
0.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
0.0,
1.0,
0.0,
629.289307,
-70.7106781,
300.0
]
},
{
"kind": "aim",
"name": "material_60",
"input": [
1.0,
700.0,
0.0,
60.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "material_69",
"input": [
1.0,
700.0,
0.0,
69.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "material_70",
"input": [
1.0,
700.0,
0.0,
70.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
0.0,
1.0,
0.0,
629.289307,
-70.7106781,
300.0
]
},
{
"kind": "aim",
"name": "material_80",
"input": [
1.0,
700.0,
0.0,
80.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "material_89",
"input": [
1.0,
700.0,
0.0,
89.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "material_90",
"input": [
1.0,
700.0,
0.0,
90.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
0.0,
1.0,
0.0,
629.289307,
-70.7106781,
300.0
]
},
{
"kind": "aim",
"name": "material_210",
"input": [
1.0,
700.0,
0.0,
210.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "material_219",
"input": [
1.0,
700.0,
0.0,
219.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "material_220",
"input": [
1.0,
700.0,
0.0,
220.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
0.0,
1.0,
0.0,
629.289307,
-70.7106781,
300.0
]
},
{
"kind": "aim",
"name": "material_-1",
"input": [
1.0,
700.0,
0.0,
-1.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "material_170",
"input": [
1.0,
700.0,
0.0,
170.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "no_polygon",
"input": [
1.0,
700.0,
1.0,
60.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
0.0,
1.0,
0.0,
629.289307,
-70.7106781,
300.0
]
},
{
"kind": "aim",
"name": "no_material",
"input": [
1.0,
700.0,
2.0,
0.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "no_definition",
"input": [
1.0,
700.0,
3.0,
60.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
0.0,
0.0,
1.0,
0.0,
629.289307,
-70.7106781,
300.0
]
},
{
"kind": "aim",
"name": "blocked_fire",
"input": [
1.0,
700.0,
0.0,
60.0,
1.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
275.0
]
},
{
"kind": "aim",
"name": "blocked_enter",
"input": [
1.0,
700.0,
0.0,
60.0,
0.0,
1.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
275.0
]
},
{
"kind": "aim",
"name": "blocked_idle",
"input": [
1.0,
700.0,
0.0,
60.0,
0.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "aim",
"name": "blocked_equal",
"input": [
1.0,
700.0,
0.0,
60.0,
1.0,
0.0,
250.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
250.0
]
},
{
"kind": "aim",
"name": "near_fire",
"input": [
1.0,
449.0,
0.0,
60.0,
1.0,
0.0,
300.0,
0.100000001
],
"observed": [
1.0,
1.0,
1.0,
12345.0,
12345.0,
12345.0,
300.0
]
},
{
"kind": "constraint",
"name": "vertical",
"input": [
0.0,
0.0,
0.0,
0.0,
1000.0,
0.0,
0.0,
0.0,
600.0,
0.0166666675
],
"observed": [
0.0,
600.0,
0.0,
0.0,
284.0,
0.0
]
},
{
"kind": "constraint",
"name": "diagonal",
"input": [
0.0,
0.0,
0.0,
300.0,
800.0,
400.0,
0.0,
0.0,
600.0,
0.0166666675
],
"observed": [
212.447495,
484.38028,
283.263306,
87.5525055,
199.61972,
116.736694
]
},
{
"kind": "constraint",
"name": "perturbed",
"input": [
125.0,
320.0,
-210.0,
-150.0,
1200.0,
450.0,
12.0,
-23.0,
700.0,
0.0166666675
],
"observed": [
-181.472336,
515.408447,
437.490021,
31.4723358,
568.591553,
12.5099792
]
},
{
"kind": "constraint",
"name": "long_tick",
"input": [
0.0,
0.0,
0.0,
300.0,
800.0,
400.0,
50.0,
-50.0,
350.0,
0.600000024
],
"observed": [
285.845215,
162.931763,
-119.102173,
14.1547852,
521.068237,
519.102173
]
},
{
"kind": "constraint",
"name": "short",
"input": [
-40.0,
300.0,
15.0,
280.0,
500.0,
-120.0,
-20.0,
35.0,
125.0,
0.100000001
],
"observed": [
118.232071,
38.1980553,
-13.6421614,
161.767929,
345.801941,
-106.357841
]
},
{
"kind": "constraint",
"name": "negative",
"input": [
0.0,
0.0,
0.0,
300.0,
800.0,
400.0,
10.0,
20.0,
-50.0,
0.100000001
],
"observed": [
-18.5824604,
-38.5163727,
-25.9028244,
318.582458,
722.516357,
425.902832
]
},
{
"kind": "constraint",
"name": "fraction",
"input": [
12.125,
-37.25,
89.625,
317.875,
982.125,
-211.375,
3.25,
-1.75,
463.125,
0.0170000009
],
"observed": [
142.231491,
417.974121,
-139.67981,
175.643509,
448.150879,
-71.6951904
]
},
{
"kind": "constraint",
"name": "horizontal",
"input": [
0.0,
0.0,
0.0,
600.0,
116.0,
0.0,
0.0,
0.0,
400.0,
0.100000001
],
"observed": [
400.0,
0.0,
0.0,
200.0,
0.0,
0.0
]
},
{
"kind": "constraint",
"name": "zero_length",
"input": [
0.0,
0.0,
0.0,
300.0,
800.0,
400.0,
1.0,
2.0,
0.0,
0.100000001
],
"observed": [
0.0,
0.0,
0.0,
300.0,
684.0,
400.0
]
},
{
"kind": "constraint",
"name": "large",
"input": [
-13000.0,
900.0,
-12000.0,
14000.0,
19000.0,
18000.0,
-40.0,
20.0,
23000.0,
0.0166666675
],
"observed": [
14044.2402,
9361.43848,
15621.4834,
-44.2402344,
9522.56152,
2378.5166
]
},
{
"kind": "impact",
"name": "zero",
"input": [
0.0,
0.0
],
"observed": [
0.0,
0.0,
0.0,
0.0
]
},
{
"kind": "impact",
"name": "below",
"input": [
59.9000015,
0.0
],
"observed": [
0.0,
0.0,
0.0,
0.0
]
},
{
"kind": "impact",
"name": "equal_x",
"input": [
60.0,
0.0
],
"observed": [
0.0,
0.0,
0.0,
0.0
]
},
{
"kind": "impact",
"name": "equal_z",
"input": [
0.0,
60.0
],
"observed": [
0.0,
0.0,
0.0,
0.0
]
},
{
"kind": "impact",
"name": "pythagoras",
"input": [
36.0,
48.0
],
"observed": [
0.0,
0.0,
0.0,
0.0
]
},
{
"kind": "impact",
"name": "above",
"input": [
36.0,
48.0000992
],
"observed": [
0.0,
0.0,
1.0,
1.0
]
},
{
"kind": "impact",
"name": "diagonal",
"input": [
45.0,
45.0
],
"observed": [
0.0,
0.0,
1.0,
1.0
]
},
{
"kind": "impact",
"name": "negative",
"input": [
-60.0,
0.0
],
"observed": [
0.0,
0.0,
0.0,
0.0
]
},
{
"kind": "impact",
"name": "negative_above",
"input": [
0.0,
-60.0999985
],
"observed": [
0.0,
0.0,
1.0,
1.0
]
}
],
"generators": {
"grappler_query_probe.c": "c712653e89d506e622e77240b4fd0e3368d34c6c1ceb3f24093645fed8bf6741",
"grappler_scalar_probe.c": "c51cc1ecefaf7a90e69a40624fd0e8cd7e01500359c4e67aee6213bb36f4a810"
},
"executable_sha256": "5387d7523c6ff717e1c2f3587ec9e7adc53be63c184c664f8ac7e3ca4ba3b7ec",
"log_sha256": "9219572b31ff2b784d85aa964b876cc564d9238c3e9a67de70ba37505868b031"
}
+47
View File
@@ -0,0 +1,47 @@
"""Original source gates and retained native component observations."""
from collections import Counter
import json
from pathlib import Path
import sys
import unittest
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'tools/binary'))
from grappler_query import collect
class GrapplerQueryEvidence(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.source=collect(ROOT.parent/'Original')
cls.fixture=json.loads((ROOT/'tests/GamePort.GrapplerTests/original-query-reference.json').read_text())
cls.cases={(c['kind'],c['name']):c for c in cls.fixture['cases']}
def test_hashes_ranges_caller_return_and_vr08_filter(self):
for key in ('source_sha256','dll_sha256','ranges','vr08_filter'):
self.assertEqual(self.source[key],self.fixture[key])
self.assertEqual(self.source['vr08_filter']['target'],'0x475cd0')
self.assertEqual(len(self.source['ranges']),8)
self.assertEqual(Counter(c['kind'] for c in self.fixture['cases']),dict(aim=23,constraint=10,impact=9))
def test_native_close_and_blocked_paths_consume_input_with_distinct_reel_behavior(self):
close=self.cases['aim','near']['observed'];blocked=self.cases['aim','blocked_fire']['observed']
self.assertEqual(close[:3],[1,1,1]);self.assertEqual(close[-1],300)
self.assertEqual(blocked[:3],[1,1,1]);self.assertEqual(blocked[-1],275)
self.assertEqual(self.cases['aim','blocked_enter']['observed'][-1],275)
self.assertEqual(self.cases['aim','blocked_equal']['observed'][-1],250)
def test_native_selected_polygon_material_and_definition_are_distinct(self):
for name in ('no_polygon','no_definition'):
self.assertEqual(self.cases['aim',name]['observed'][:3],[0,0,1])
self.assertEqual(self.cases['aim','no_material']['observed'][:3],[1,1,1])
self.assertEqual(self.cases['aim','equal']['observed'][:3],[0,0,1])
def test_native_contact_equality_stays_attached_and_above60_detaches(self):
for name in ('zero','below','equal_x','equal_z','pythagoras','negative'):
self.assertEqual(self.cases['impact',name]['observed'],[0,0,0,0])
for name in ('above','diagonal','negative_above'):
self.assertEqual(self.cases['impact',name]['observed'],[0,0,1,1])
if __name__=='__main__':unittest.main()
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""Guarded VR08 ray/caller context and imported original-code probe results."""
import argparse
from collections import Counter
import hashlib
import json
from pathlib import Path
import re
import struct
from grappler import collect as source_contract
from checkpoint_script_state import find_case,read_va
from pe_inspect import PE
from shrink_heading import DLL_SHA256
RANGES=(('aim',0x42a406,0x42a652),('constraint',0x429ea0,0x429fa4),
('impact_post_base',0x42a69b,0x42a6f1),('input_gate',0x426030,0x4260a6),
('input_return',0x4269c3,0x4269cd),('primary_poll',0x42a7a0,0x42a7d6),
('consuming_enter',0x46a3e0,0x46a3fb),('aim_return',0x42a652,0x42a660))
def collect(original):
contract=source_contract(original);original=Path(original)
pe=PE(find_case(original,'Neutron.exe'))
if struct.unpack('<I',read_va(pe,0x4d0204,4))[0]!=0x475cd0:
raise ValueError('Changed VR08 polygon filter virtual')
if read_va(pe,0x475cd0,5)!=bytes.fromhex('32c0c21800'):
raise ValueError('Changed false polygon filter leaf')
if read_va(pe,0x426098,14)!=bytes.fromhex('ff908801000084c00f851d090000'):
raise ValueError('Changed aim-to-active-input return gate')
dll_hash=hashlib.sha256(find_case(original,'OMT2.dll').read_bytes()).hexdigest()
if dll_hash!=DLL_SHA256:raise ValueError('Unexpected original DLL')
return dict(source_sha256=contract['sha256'],dll_sha256=dll_hash,
vr08_filter=dict(table='0x4d00d0',slot='0x134',target='0x475cd0'),
ranges=[dict(kind=k,va=hex(a),end_va=hex(b),file_offset=hex(pe.offset(a-pe.base)),
sha256=hashlib.sha256(read_va(pe,a,b-a)).hexdigest()) for k,a,b in RANGES],
scope='Synthetic ray/material/cursor accessors; original DLL magnitude; constraint before body and contact after stubbed base; no game entrypoint')
def reference(original,log,executable):
report=collect(original);log=Path(log);text=log.read_text()
if 'GRAPPLER_QUERY_CONSTRAINT_COMPLETE' not in text:raise ValueError('Probe incomplete')
cases=[]
for line in text.splitlines():
match=re.fullmatch(r'CASE (aim|constraint|impact) ([\w-]+) in=([^ ]+) out=([^ ]+)',line)
if match:
kind,name,p,o=match.groups();cases.append(dict(kind=kind,name=name,
input=[float(x) for x in p.split(',')],observed=[float(x) for x in o.split(',')]))
if Counter(c['kind'] for c in cases)!=dict(aim=23,constraint=10,impact=9):raise ValueError('Expected42 complete cases')
root=Path(__file__).parent
report.update(cases=cases,generators={name:hashlib.sha256((root/name).read_bytes()).hexdigest()
for name in ('grappler_query_probe.c','grappler_scalar_probe.c')},
executable_sha256=hashlib.sha256(Path(executable).read_bytes()).hexdigest(),
log_sha256=hashlib.sha256(log.read_bytes()).hexdigest())
return report
if __name__=='__main__':
cli=argparse.ArgumentParser(description=__doc__);cli.add_argument('original',type=Path)
cli.add_argument('--log',type=Path);cli.add_argument('--executable',type=Path);cli.add_argument('--output',type=Path)
args=cli.parse_args()
if bool(args.log)!=bool(args.executable):cli.error('--log and --executable are required together')
if args.output and (args.output.resolve().is_relative_to(args.original.resolve())
or args.original.resolve().is_relative_to(args.output.resolve())):cli.error('Output must be separate from originals')
result=reference(args.original,args.log,args.executable) if args.log else collect(args.original)
text=json.dumps(result,indent=2)+'\n'
if args.output:args.output.parent.mkdir(parents=True,exist_ok=True);args.output.write_text(text)
else:print(text,end='')
+117
View File
@@ -0,0 +1,117 @@
/* Copied aim suffix, constraint math and post-base impact suffix.
Synthetic ray result/material/cursor/body accessors; no game entrypoint. */
#define main scalar_probe_unused_main
#include "grappler_scalar_probe.c"
#undef main
static unsigned char cursor[0x700],polygon[32],material[32],definition[32];
static uintptr_t cursor_table[0x60/4],cursor_game_table[0x320/4],jimmy_table[0x210/4];
static unsigned char query_success;static int primary,enter_key,hidden,visibility_calls,detach_calls;
static float cursor_position[3],constraint_result[6];
static void TC cursor_hide(void*self,int hide){require(self==cursor,"cursor owner");hidden=hide;visibility_calls++;}
static void TC cursor_xyz(void*self,float x,float y,float z){require(self==cursor+0xc8,"cursor interface");cursor_position[0]=x;cursor_position[1]=y;cursor_position[2]=z;}
static void TC detach(void*self){require(self==object,"Jimmy detach owner");detach_calls++;}
static int primary_fire(void){return primary;}
static int enter(int key){require(key==13,"auxiliary primary key");return enter_key;}
static void relocate_query(uint32_t start,uint32_t end){
const uint32_t values[]={0x5cfc60,0x5cfc64,0x5cfc68,0x5cfc6c,0x4a3e68,0x695d54,
0x4f82b8,0x4a3e58,0x48d104,0x48d924,0x48d96c,0x4f8214,0x4f8218,0x4f821c,
0x4f82cc,0x4f82bc,0x4f82c0,0x48d404,0x4a3e8c,0x49d5b4};
for(uint32_t a=start;a+4<=end;a++){
uint32_t value;memcpy(&value,AT(a),4);
for(unsigned i=0;i<sizeof(values)/sizeof(values[0]);i++)if(value==values[i]){
uint32_t relocated=(uintptr_t)AT(value);memcpy(AT(a),&relocated,4);a+=3;break;
}
}
}
static void call_patch(uint32_t address,void*target){jump(AT(address),target);*AT(address)=0xe8;}
static void epilogue(unsigned char**p){
emit_byte(p,0x81);emit_byte(p,0xc4);word(p,0xa0);emit_byte(p,0x5f);emit_byte(p,0x5e);emit_byte(p,0x5d);emit_byte(p,0x5b);emit_byte(p,0xc3);
}
static void*frame_start(unsigned char**out){
unsigned char*c=VirtualAlloc(NULL,512,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE);require(c!=NULL,"frame shim");*out=c;
emit_byte(out,0x53);emit_byte(out,0x55);emit_byte(out,0x56);emit_byte(out,0x57);
emit_byte(out,0x81);emit_byte(out,0xec);word(out,0xa0);
emit_byte(out,0x8b);emit_byte(out,0x84);emit_byte(out,0x24);word(out,0xb4);
return c;
}
static void*aim_frame(void){
unsigned char*p,*c=frame_start(&p);
stack_copy(&p,0,0x2c);stack_copy(&p,4,0x30);stack_copy(&p,8,0x34);
stack_copy(&p,12,0x3c);stack_copy(&p,16,0x40);stack_copy(&p,20,0x44);stack_copy(&p,24,0x98);
emit_byte(&p,0xbe);word(&p,(uintptr_t)(object+0xc0));emit_byte(&p,0xbf);word(&p,(uintptr_t)object);
emit_byte(&p,0xa0);word(&p,(uintptr_t)&query_success);jump(p,AT(0x42a406));p+=5;
unsigned char*end=p;epilogue(&p);
jump(AT(0x42a48b),end);jump(AT(0x42a53d),end);jump(AT(0x42a635),end);
/* Skip source-frame pops, execute the original XOR AL,AL at42A654,
then return through our frame shim without manufacturing its result. */
*AT(0x42a652)=0xeb;*AT(0x42a653)=0; jump(AT(0x42a656),end);
return c;
}
static void save_stack(unsigned char**p,int offset,void*destination){
emit_byte(p,0x8b);emit_byte(p,0x84);emit_byte(p,0x24);word(p,offset);
emit_byte(p,0xa3);word(p,(uintptr_t)destination);
}
static void*constraint_frame(void){
unsigned char*p,*c=frame_start(&p);
stack_copy(&p,0,0x2c);stack_copy(&p,4,0x30);stack_copy(&p,8,0x34);stack_copy(&p,12,0x98);
emit_byte(&p,0xbe);word(&p,(uintptr_t)(object+0xc0));
emit_byte(&p,0xb8);word(&p,(uintptr_t)AT(0x4f8214));jump(p,AT(0x429ea0));p+=5;
unsigned char*end=p;emit_byte(&p,0x83);emit_byte(&p,0xc4);emit_byte(&p,4); /* pending root accessor argument */
for(int i=0;i<6;i++)save_stack(&p,i<3?0x0c+4*i:0x1c+4*(i-3),&constraint_result[i]);
epilogue(&p);jump(AT(0x429fa4),end);return c;
}
static void*impact_frame(void){
unsigned char*p,*c=frame_start(&p);emit_byte(&p,0xbe);word(&p,(uintptr_t)(object+0xc0));
jump(p,AT(0x42a69b));p+=5;unsigned char*end=p;epilogue(&p);
jump(AT(0x42a6f1),end);jump(AT(0x42a710),end);return c;
}
static void aim_case(const char*name,int hit,float distance,int kind,int id,int fire,int key,float length,float dt,void*fn){
float args[]={0,0,0,0,2400,2400,dt};query_success=hit;primary=fire;enter_key=key;
F(0x5cfc60)=0;F(0x5cfc64)=distance;F(0x5cfc68)=0;F(0x5cfc6c)=1;F(0x4f82b8)=length;
*(void**)AT(0x695d54)=kind==1?NULL:polygon;*(void**)(polygon+4)=kind==2?NULL:material;
*(void**)(material+0xc)=kind==3?NULL:definition;*(int*)(definition+8)=id;
hidden=-1;visibility_calls=0;for(int i=0;i<3;i++)cursor_position[i]=12345;
unsigned char consumed=((unsigned char(*)(float*))fn)(args);
printf("CASE aim %s in=%d,%.9g,%d,%d,%d,%d,%.9g,%.9g out=%u,%d,%d,%.9g,%.9g,%.9g,%.9g\n",name,hit,distance,kind,id,fire,key,length,dt,consumed,hidden,visibility_calls,cursor_position[0],cursor_position[1],cursor_position[2],F(0x4f82b8));
}
static void constraint_case(const char*name,float x,float y,float z,float ax,float ay,float az,float sx,float sz,float length,float dt,void*fn){
float pivot=y+116,args[]={x,pivot,z,dt};F(0x4f8214)=ax;F(0x4f8218)=ay;F(0x4f821c)=az;
F(0x4f82bc)=sx;F(0x4f82c0)=sz;F(0x4f82b8)=length;((run_fn)fn)(args);
printf("CASE constraint %s in=%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g,%.9g out=%.9g,%.9g,%.9g,%.9g,%.9g,%.9g\n",name,x,y,z,ax,ay,az,sx,sz,length,dt,constraint_result[0],constraint_result[1],constraint_result[2],constraint_result[3],constraint_result[4],constraint_result[5]);
}
static void impact_case(const char*name,float x,float z,void*fn){
float args[]={0};F(0x4f82bc)=x;F(0x4f82c0)=z;object[0x1e25]=0;detach_calls=0;((run_fn)fn)(args);
printf("CASE impact %s in=%.9g,%.9g out=%.9g,%.9g,%d,%u\n",name,x,z,F(0x4f82bc),F(0x4f82c0),detach_calls,object[0x1e25]);
}
int main(void){
map_source();HMODULE omt=LoadLibraryA("OMT2.dll");require(omt!=NULL,"copied original DLL");
FARPROC magnitude=GetProcAddress(omt,"?quick_magnitude@OMedia3DVector@@QBEMXZ");require(magnitude!=NULL,"native magnitude");*(FARPROC*)AT(0x48d104)=magnitude;
cursor_table[0x58/4]=(uintptr_t)cursor_hide;cursor_game_table[0x318/4]=(uintptr_t)cursor_xyz;
jimmy_table[0x204/4]=(uintptr_t)detach;*(void**)object=jimmy_table;
*(void**)cursor=cursor_table;*(void**)(cursor+0xc8)=cursor_game_table;*(int*)(cursor+0x70)=1;*(void**)(object+0xb14)=cursor;
relocate_query(0x42a406,0x42a652);relocate_query(0x429ea0,0x429fa4);relocate_query(0x42a69b,0x42a6f1);
call_patch(0x42a4f8,primary_fire);call_patch(0x42a503,enter);
void*aim=aim_frame(),*constraint=constraint_frame(),*impact=impact_frame();
aim_case("miss",0,700,0,0,1,0,300,.1f,aim);aim_case("near",1,449,0,0,1,0,300,.1f,aim);
aim_case("equal",1,450,0,0,0,0,300,.1f,aim);aim_case("far",1,700,0,0,0,0,300,.1f,aim);
int ids[]={60,69,70,80,89,90,210,219,220,-1,170};
for(unsigned i=0;i<sizeof(ids)/sizeof(ids[0]);i++){char name[32];sprintf(name,"material_%d",ids[i]);aim_case(name,1,700,0,ids[i],0,0,300,.1f,aim);}
aim_case("no_polygon",1,700,1,60,0,0,300,.1f,aim);aim_case("no_material",1,700,2,0,0,0,300,.1f,aim);
aim_case("no_definition",1,700,3,60,0,0,300,.1f,aim);aim_case("blocked_fire",1,700,0,60,1,0,300,.1f,aim);
aim_case("blocked_enter",1,700,0,60,0,1,300,.1f,aim);aim_case("blocked_idle",1,700,0,60,0,0,300,.1f,aim);
aim_case("blocked_equal",1,700,0,60,1,0,250,.1f,aim);aim_case("near_fire",1,449,0,60,1,0,300,.1f,aim);
constraint_case("vertical",0,0,0,0,1000,0,0,0,600,1.f/60,constraint);
constraint_case("diagonal",0,0,0,300,800,400,0,0,600,1.f/60,constraint);
constraint_case("perturbed",125,320,-210,-150,1200,450,12,-23,700,1.f/60,constraint);
constraint_case("long_tick",0,0,0,300,800,400,50,-50,350,.6f,constraint);
constraint_case("short",-40,300,15,280,500,-120,-20,35,125,.1f,constraint);
constraint_case("negative",0,0,0,300,800,400,10,20,-50,.1f,constraint);
constraint_case("fraction",12.125f,-37.25f,89.625f,317.875f,982.125f,-211.375f,3.25f,-1.75f,463.125f,.017f,constraint);
constraint_case("horizontal",0,0,0,600,116,0,0,0,400,.1f,constraint);
constraint_case("zero_length",0,0,0,300,800,400,1,2,0,.1f,constraint);
constraint_case("large",-13000,900,-12000,14000,19000,18000,-40,20,23000,1.f/60,constraint);
impact_case("zero",0,0,impact);impact_case("below",59.9f,0,impact);impact_case("equal_x",60,0,impact);
impact_case("equal_z",0,60,impact);impact_case("pythagoras",36,48,impact);impact_case("above",36,48.0001f,impact);
impact_case("diagonal",45,45,impact);impact_case("negative",-60,0,impact);impact_case("negative_above",0,-60.1f,impact);
puts("GRAPPLER_QUERY_CONSTRAINT_COMPLETE");return 0;
}