feat: SH-027 v2 — the gun points where the camera points (EN-039) - #22
Conversation
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
|
Warning Review limit reached
Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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 thebarrel 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 rotationconvention puts column 2 of the model matrix wherever local +Z points. That's
confirmed against the code being replaced: it passed
θ = π − yaw, and theengine's
rotYsends +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 shotray 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) — thetakeScreenshotFFI writes no file on Windows (EN-038) and
shot-window.ps1hands back staleframes, so neither is trustworthy here:
Under
drawModelRotatedthose two frames were identical by construction.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