Skip to content

Refactor: optimize FlyByCamera and reduce object allocations + javadoc #2498

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

Merged
merged 3 commits into from
Jun 24, 2025

Conversation

capdevon
Copy link
Contributor

@capdevon capdevon commented Jun 14, 2025

The main differences between the two versions of the FlyByCamera.java file are as follows:

  • Copyright Update: The copyright year was updated from 2023 to 2025.
  • Improved Documentation: Many Javadoc comments were rewritten for clarity, accuracy, and better parameter descriptions.
  • Initialization and Memory Optimization: Temporary objects (matrices, vectors, quaternions) were added as reusable fields to reduce object allocations during camera updates, improving performance.
  • Method Refactoring: Several methods (such as rotateCamera, riseCamera, and moveCamera) were refactored to use the new reusable temporary fields instead of creating new objects every time, resulting in more efficient and cleaner code.
  • Input Handling Changes: In the onAction method, the boolean parameter was renamed for clarity, and usage was updated accordingly.
  • Minor Logic Adjustments: Small changes were made to logic, such as adding checks to prevent near-zero field of view values in zoomCamera, and clarifying joystick mapping and input unregistration handling.

Overall, the updated file focuses on performance improvements, clearer documentation, and minor logic corrections, with no major functional changes to the camera’s behavior.

@yaRnMcDonuts yaRnMcDonuts added this to the v3.9.0 milestone Jun 14, 2025
@richardTingle
Copy link
Member

This section might be worth a second option (i.e. I'm not qualified to decide if this is a good change

        if (newFov > 0.01f) {
            cam.setFov(newFov);
        }

Otherwise I have reviewed and this looks good

@yaRnMcDonuts yaRnMcDonuts merged commit a6fbad5 into jMonkeyEngine:master Jun 24, 2025
16 checks passed
@capdevon capdevon deleted the capdevon-FlyByCamera branch June 25, 2025 07:12
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.

3 participants