Skip to content

feat: SH-027 v2 — the gun points where the camera points (EN-039) - #22

Merged
proggeramlug merged 1 commit into
mainfrom
feat/sh-027-v2-gun-tilts-with-aim
Jul 15, 2026
Merged

feat: SH-027 v2 — the gun points where the camera points (EN-039)#22
proggeramlug merged 1 commit into
mainfrom
feat/sh-027-v2-gun-tilts-with-aim

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Closes the v2 half of SH-027, which has been gated on EN-039 (now merged as
Bloom-Engine/engine#100).

The weapon drew through drawModelRotated — a single Y rotation — so the
barrel stayed level while you aimed up or down
. The old comment at this call
site said as much and ended "a full-transform immediate draw is EN-039".

How the matrix is derived (not guessed)

The barrel is local +Z (build-weapons.ts), and the engine's rotation
convention puts column 2 of the model matrix wherever local +Z points. That's
confirmed against the code being replaced: it passed θ = π − yaw, and the
engine's rotY sends +Z to (sin θ, 0, cos θ) = (sin yaw, 0, −cos yaw)
camera-forward at zero pitch. So column 2 becomes the aim vector, with an
orthonormal basis built around it.

That aim vector is (fwx, fwy, fwz)the same one the muzzle, tracer and shot
ray already use
. The gun and the bullet now agree by construction rather than
by coincidence.

The cross with world-up can't collapse: camera pitch is clamped well short of
vertical (TP_PITCH_MIN/MAX), so the aim is never parallel to up.

Verification

Via the engine's own F12 capture (tools/f12-shot.ps1) — the takeScreenshot
FFI writes no file on Windows (EN-038) and shot-window.ps1 hands back stale
frames, so neither is trustworthy here:

  • pitch 0.30 → 1.15 rad, nothing else changed: the weapon visibly re-orients.
    Under drawModelRotated those two frames were identical by construction.
  • The gun still draws at all. That's the real risk: Perry silently no-ops a
    native missing from the manifest, so a botched registration shows up as the gun
    quietly vanishing — no error, no crash.

Consumers need a .perry-cache/ clear for the manifest change.

https://claude.ai/code/session_01J1UWgMcrTNvwWeXcJ1T3Fp

The weapon drew through drawModelRotated, which takes only a Y rotation: the
barrel stayed level while you aimed up or down. No yaw-only draw can fix that,
which is why the old comment here ended "a full-transform immediate draw is
EN-039". That landed, so this consumes it.

The barrel is local +Z (build-weapons.ts), and the engine's rotation convention
puts COLUMN 2 of the model matrix wherever local +Z points — confirmed against
the code being replaced: it passed θ = π - yaw, and the engine's rotY sends +Z to
(sin θ, 0, cos θ) = (sin yaw, 0, -cos yaw), i.e. camera-forward at zero pitch. So
column 2 becomes the aim vector and an orthonormal basis is built around it.

That aim vector is (fwx, fwy, fwz) — the SAME one the muzzle, the tracer and the
shot ray are already computed from. The gun and the bullet now agree by
construction rather than by coincidence.

The cross with world-up cannot collapse: camera pitch is clamped well short of
vertical (TP_PITCH_MIN/MAX), so the aim is never parallel to up.

Verified in-game with the engine's own F12 capture (tools/f12-shot.ps1 — the
takeScreenshot FFI writes no file on Windows, and shot-window.ps1 hands back
stale frames): with only the camera pitch changed, 0.30 -> 1.15 rad, the weapon
visibly re-orients. It also still DRAWS, which is the real risk — Perry silently
no-ops a native missing from the manifest, so a botched registration shows up as
the gun quietly vanishing rather than as an error.

Claude-Session: https://claude.ai/code/session_01J1UWgMcrTNvwWeXcJ1T3Fp
@proggeramlug
proggeramlug merged commit 61a11bc into main Jul 15, 2026
@proggeramlug
proggeramlug deleted the feat/sh-027-v2-gun-tilts-with-aim branch July 15, 2026 16:18
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proggeramlug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 47aa9b8e-0151-4a5a-b07d-7deda55aedd8

📥 Commits

Reviewing files that changed from the base of the PR and between 7897f57 and 7765c8c.

📒 Files selected for processing (1)
  • src/combat.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sh-027-v2-gun-tilts-with-aim

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant