fix: stabilize LookAt for parallel up vectors - #29
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
besmpl
marked this pull request as ready for review
August 10, 2026 19:30
besmpl
force-pushed
the
agent/fix-lookat-parallel-up
branch
from
August 10, 2026 20:37
be43ffa to
2738613
Compare
kolkov
approved these changes
Aug 11, 2026
kolkov
left a comment
Contributor
There was a problem hiding this comment.
Code reviewed: robust LookAt degenerate case handling — zero direction, zero up, parallel up/forward fallbacks. Bitwise epsilon comparison correct. 10 tests with orthonormal basis validation. LGTM.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Why
Mat4LookAtpreviously normalizedforward × upwithout handling a zero cross product. A camera directly above or below its target with the conventional{0,1,0}up vector therefore produced a singular view matrix. This includes the top-down camera arrangement shown in the project documentation; projected points could end up with an invalid clip-spacew.The fix constructs a stable, right-handed orthonormal basis while keeping ordinary non-degenerate views unchanged.
Impact
Top-down and bottom-up cameras now orient correctly instead of producing a zero basis. Up-vector magnitude no longer affects the result, and boundary inputs remain finite and deterministic.
Verification
go test ./...go test -race ./...go build ./...go vet ./...gofmtandgit diff --check