Fix Camera::setFront() having no effect - #92
Open
killerdevildog wants to merge 1 commit into
Open
killerdevildog wants to merge 1 commit into
killerdevildog wants to merge 1 commit into
Conversation
updateView() recomputes front from yaw/pitch without reading the previous value, so the assignment in setFront was a dead store and the function had no effect. Set yaw/pitch from the direction instead, inverting the same euler convention updateView uses. Regression from 7f7229a, which replaced the quaternion updateView (where front was an input) with the euler one (where it is an output). Fixes hotstreams#91
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.
Fixes #91.
Camera::setFront()writes the incoming vector tofront, butupdateView()recomputesfrontfromyaw/pitchon the very next statement without reading the previous value. The assignment is a dead store, so the function has no effect for any input.Since
yaw/pitchare only written by the constructor and bymouseMove()(relative deltas), there is currently no way to set an absolute camera orientation from a direction vector.Fix
Derive
yaw/pitchfrom the direction, inverting the same euler conventionupdateView()already uses, so there is only one orientation representation in the class:Regression origin
setFront()worked when it was introduced. The originalupdateView()was quaternion-based and tookfrontas an input:7f7229a ("cube demo") replaced that with the euler formulation, moving
frontfrom the right-hand side to the left. The store insetFront()became dead at that point, silently and with no compiler warning.Verification
Built a headless harness against the real
Cameraclass (its constructor andupdateView()are pure glm, no GL context required), linkingcamera.cppbefore and after the change. Same test binary, only the object file swapped:setFront({1,0,0})→getFront()(0, -0.866, -0.5)(1, 0, 0)getView()(0, -0.866, -0.5)(1, 0, 0)Before the change every input returns the identical constructor default
(0, -0.866, -0.5), including{0,1,0}and{0,-1,0}— the function is provably input-independent. After, all nine directions round-trip to within1e-6.The
getView()row checks that the fix reaches the matrix that actually feedsscene_data,Frustum::fromCamera()and the cascade shadow splits, not just the member.Notes
glm::cos(glm::radians(90.0f))is≈ -4.37e-8rather than exactly zero, socross(front, world_up)does not degenerate and the straight-up/straight-down cases stay finite and exact. Verified in the table above.samples/gltf_viewer/gltf_viewer.cpp:110, which asks to look down +X and currently keeps the constructor defaults.src/limitless/camera.cppcompiles clean under-Wall -Wextrawith no new warnings.Happy to add a Catch2 case under
tests/for this if you would like it covered by the suite.