Skip to content

Conversation

@stephengold
Copy link
Member

@stephengold stephengold commented Mar 6, 2025

This PR attempts to address issue #2333 by adding runtime checks to the Camera class.

The new checks throw IllegalArgumentException and affect 5 setters:

  • setViewPort(float, float, float, float)
  • setViewPortBottom(float)
  • setViewPortLeft(float)
  • setViewPortRight(float)
  • setViewPortTop(float)

For ease of maintenance, the checks are actually centralized in onViewPortChange(). This assumes onViewPortChange() isn't called often enough for this to cause a measurable performance impact.

In addition to testing for negative widths and heights, I decided to also test for zero-width viewports and zero-height viewports. I found at one instance of division by height, and I can't think of a use case for a zero-width viewport.

Automated tests (using JUnit4) are included in the PR.

@stephengold stephengold added this to the v3.8.0 milestone Mar 6, 2025
@stephengold stephengold linked an issue Mar 6, 2025 that may be closed by this pull request
@stephengold
Copy link
Member Author

This PR is ready to be reviewed.

@yaRnMcDonuts
Copy link
Member

Looks good to me. The code changes look safe and I don't foresee it causing any potential issue.

So I will wait a bit and then merge this in ~48 hours in case anyone else wants do anymore review before it's integrated.

@yaRnMcDonuts yaRnMcDonuts merged commit 09b862d into master Mar 13, 2025
15 checks passed
@stephengold stephengold deleted the sgold/issue/2333 branch December 9, 2025 01:17
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.

Camera Viewport Dimensions not Checked

3 participants