Skip to content

fix: ignore scale in directional light orientation - #28

Merged
kolkov merged 1 commit into
gogpu:mainfrom
besmpl:agent/directional-light-rotation-only
Aug 11, 2026
Merged

fix: ignore scale in directional light orientation#28
kolkov merged 1 commit into
gogpu:mainfrom
besmpl:agent/directional-light-rotation-only

Conversation

@besmpl

@besmpl besmpl commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • derive directional-light direction from composed local and ancestor rotations
  • ignore translation and scale, including nonuniform, zero, and negative scale
  • add local, parent, and degenerate-scale regressions

Why

DirectionalLight.Direction extracted a quaternion from the complete world matrix. The matrix's linear component also contains scale and hierarchy-induced shear, so changing a light or ancestor's nonuniform scale changed the reported direction even when every rotation stayed identical.

Node transforms use T * R * S. The new helper composes quaternions in the same parent-then-local order and rotates the default forward vector without allowing scale to contaminate orientation.

Verification

  • baseline local and parent nonuniform-scale tests fail with distorted directions
  • zero and negative scale remain rotation-defined instead of collapsing or flipping orientation
  • nested rotation composition matches the world-matrix rotation when scales are identity
  • reparenting and direct rotation updates are reflected immediately
  • go test ./...
  • go test -race ./...
  • go build ./...
  • go vet ./...
  • Linux, Windows, and Darwin cross-builds
  • gofmt and git diff --check

The helper recomputes the ancestor rotation chain when Direction is queried; this is O(hierarchy depth) and avoids coupling direction correctness to matrix cache state.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@besmpl
besmpl marked this pull request as ready for review August 10, 2026 18:33
@besmpl
besmpl requested a review from kolkov as a code owner August 10, 2026 18:33
@besmpl
besmpl force-pushed the agent/directional-light-rotation-only branch from b60fa63 to 87fff3b Compare August 10, 2026 20:31

@kolkov kolkov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code reviewed: worldRotation() composes quaternions directly, bypassing world matrix — scale-independent by design. Unexported helper, correct recursion. 3 tests with non-uniform scale cases. LGTM.

@kolkov
kolkov merged commit 79ff997 into gogpu:main Aug 11, 2026
10 checks passed
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.

2 participants