-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Reduce object allocations in AudioListener #2501
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
base: master
Are you sure you want to change the base?
Conversation
|
I've reverted the changes to the existing getters. Since the listener isn't only an internal API, changing their behavior could break existing code, and because the defect isn't severe, it isn't worth risking hard-to-debug regressions for developers, imo. Instead, I added new getters that populate the passed store object (a pattern used frequently elsewhere in jME), and updated the Audio Renderer to use these new getters. I think this is a good resolution. |
|
Refactor |
Reduce object allocations when
ALAudioRendererupdate listener each time theCamerais moved:This pull request refactors the Listener class in the jMonkeyEngine audio system. The main changes include initializing the
location,velocity, androtationfields at declaration instead of in the constructor, removing redundant constructor assignments, and introducing reusableVector3finstances (left,up,direction) for direction calculations.Methods that return direction vectors now store results in these fields rather than creating new objects, improving memory efficiency and reducing unnecessary allocations. Overall, the changes streamline object management and optimize performance in the Listener class.
https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/audio/openal/ALAudioRenderer.java#L768