Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve issue #2333 (Camera viewport dimensions not checked) #2388

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stephengold
Copy link
Member

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

The new checks throw IllegalArgumentException and affect 5 setters:

  • settViewPort(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
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
1 participant