feat(rig lab): drag the anchors themselves, not just the gun under them

The lab could move the GUN and not the anchor points the hands are solved onto.
`grip_offset` slides the weapon around inside the fist; `gun_fore` and
`gun_stock` are distances ALONG the barrel, so the trigger and support hands
could travel up and down the weapon's own axis and nowhere else. Nothing could
take a hand off that axis, which is what a handguard below the bore, an angled
foregrip, or a pistol whose grip is nowhere near its barrel line all need.

Two things fix that.

`grip_shift` and `fore_shift` give the two hand anchors real three-dimensional
freedom, expressed in the GUN's own across/up/along frame so a sideways nudge
stays sideways as the weapon pitches between low ready and ADS. Zero is exactly
the old behaviour. Their z overlaps the along-axis distances, which is redundant
and deliberate: keeping those separate is what lets the reach solver slide the
support hand back down the handguard without undoing a considered sideways
offset.

And the markers are now draggable. They already showed the anchors; now they
are handles. The one under the mouse swells and draws through the body — depth
testing is right for judging whether a hand reached its target and wrong for a
handle, because at any useful framing the hands occlude all three.

Verified three ways, and each one had to be rebuilt once:

  anchor_shift_check first compared absolute positions and reported a 3.5 mm
  error that was the character BREATHING — there is a sin() on the muzzle pitch,
  so no anchor is ever in the same place twice. Measuring each anchor relative
  to the one it hangs off, rotated into the current gun basis, cancels the
  breathing, the ADS blend and the recoil exactly. 48 checks, six characters,
  both poses.

  anchor_drag_check asserts the drag writes the knob the MOUSE asked for,
  derived independently from the camera: 0.00-0.01 mm on all three. It does not
  assert the marker lands under the cursor, because it does not — the anchors
  hang off the shoulder and the arm chasing them moves the shoulder, so a drag
  settles at 0.77x-1.13x. Small enough to ignore interactively.

  That feedback first read as 1.5x-1.8x, because the cases were compounding on
  each other, and waiting LONGER for the pose to settle made it worse rather
  than better — which is the opposite of how a settling error behaves and is
  what gave it away.

The buttstock case also failed for a while on a bug entirely in the test: it
read an absent knob as zero when `pocket_hip` defaults to (30, -70, 60) mm. The
lab has a note about that trap in `_reset`. It is just as easy to walk into from
a test, and now has one there too.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
Nicholas Butzke
2026-07-28 01:05:37 -04:00
co-authored by Claude Opus 5
parent 700d0925d7
commit b1c8bab714
9 changed files with 566 additions and 11 deletions
+19
View File
@@ -52,6 +52,25 @@ const KNOBS := [
Vector3(0.03, -0.07, 0.06)],
["pocket_ads", "Stock pocket, aiming", -0.30, 0.30, true,
Vector3(0.05, 0.01, 0.07)],
# The two hand anchors, off the barrel line.
#
# `gun_stock` and `gun_fore` above are DISTANCES ALONG the barrel, and for a
# long time that was the only freedom either anchor had: the trigger hand
# could slide up and down the gun's own axis and nowhere else, and so could
# the support hand. That is fine for where along a handguard to hold, and
# useless for a handguard that sits below the bore, an angled foregrip, or a
# pistol whose grip is nowhere near its barrel line.
#
# These are in the GUN's frame — x across, y up, z along the barrel — so they
# stay meaningful as the weapon pitches between low ready and ADS. Zero is
# exactly the old behaviour. Their z overlaps `gun_stock`/`gun_fore`, which
# is redundant but harmless, and keeping the along-axis distances separate is
# what lets the reach solver slide the support hand back down the handguard
# without also undoing a deliberate sideways nudge.
["grip_shift", "Trigger-hand anchor, off the barrel line", -0.15, 0.15, true,
Vector3.ZERO],
["fore_shift", "Support-hand anchor, off the barrel line", -0.15, 0.15, true,
Vector3.ZERO],
# Zero means "use the code's own hip/ADS blend" for these two — see _tv in
# ShooterPoseModifier, which treats a zero-length vector as unset.
["pole_r", "Firing elbow (0 = auto)", -1.5, 1.5, true, Vector3.ZERO],