Camera fixes: clamp scrolling by view target, ignore minimap clicks outside the map - #18
Merged
tomluchowski merged 2 commits intoAug 1, 2026
Conversation
Scrolling ran past the map edge on one side while stopping short of it on the opposite side, in gameplay and in the map editor alike. updateCameraFrameTime() clamped the camera node's own position to [0, mapSize], but the camera is pitched DEFAULT_X_AXIS_VIEW (25 degrees) off vertical, so the ground point it looks at lies z * tan(pitch) ahead of it: between 1.4 and 7.5 tiles for z within [MIN_CAMERA_Z, MAX_CAMERA_Z]. Clamping the position therefore shifted the whole reachable view window by that offset, overshooting the edge the camera faces and falling short of the one behind it, for a total asymmetry of twice the offset. Clamp so the view target stays inside the map instead, deriving the offset from the camera's derived direction and the height it is about to end up at, the same way getCameraViewTarget() does. Keeping the offset signed leaves the limits correct under camera yaw, not just at the default orientation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit 4d81fe4)
Clicking near the border of the minimap moves the camera there and leaves it shuddering against the map edge for the rest of the game. The minimap is a view of the ground around the camera, not of the map, so when the camera is near an edge the minimap shows ground past it, and a click there asks the camera to fly somewhere it cannot go: updateCameraFrameTime() keeps the point the camera looks at inside the map. The flight is never within the 0.25 stopping distance of its destination, so it never ends, and every frame it pushes the camera past the edge for the clamp to pull it back on the next one. Hence the bouncing, and hence it outlasting the click. flyTo() now aims at the nearest point on the map, which is where the camera was going to stop anyway. Two things back that up. The clamp moved into clampToMap() and is applied a second time just before the camera is placed, so the flight, the circle and the spline modes, which all add to the position after the first clamp, can no longer put the camera off the map even for the single frame it took to be pulled back. And a flight that brings the view target no closer than the frame before now gives up rather than press on, so no destination the clamp does not predict can hang the camera again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit 0474176)
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.
Two camera defects, one commit each:
Split out of #16 so each topic can be reviewed on its own. Merging all of the split PRs reproduces the tree of #16 exactly.
🤖 Generated with Claude Code