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

Refactor Jolt-related project settings to only be read as-needed #101254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mihe
Copy link
Contributor

@mihe mihe commented Jan 8, 2025

As suggested in #101237, this refactors the JoltProjectSettings class to not just be a class of getters that themselves just call GLOBAL_GET (which in some cases also get cached as a static variable) but instead a class of actual values.

This is then coupled with ProjectSettings::get_singleton()->connect("settings_changed", ...); to read the settings again whenever they're changed, ensuring that we have up-to-date values without needing to call GLOBAL_GET all the time.

This might perhaps provide a tiny performance boost, but mostly just cleans things up a bit and lets us get rid of the caveat in the documentation about certain settings only being read once.

It should probably be noted that bounce_velocity_threshold can now technically be read from the physics thread (when using physics/3d/run_on_separate_thread) while the main thread is writing to it, but given that it's a float I would assume that there are no concern about "torn reads" or anything like that, and having the most up-to-date value when reading it isn't really a concern in this case.

@mihe mihe force-pushed the jolt/better-settings branch from 6d05679 to 8bc96df Compare January 8, 2025 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant