Skip to content

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

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 1 commit into from
Mar 13, 2025

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 8bc96df to 3b78ff5 Compare January 25, 2025 11:19
@mihe mihe changed the title Refactor Jolt-related project settings to only be read as-needed Refactor Jolt-related project settings to only be loaded as needed Jan 25, 2025
Copy link
Member

@rburing rburing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice cleanup, and reloading the settings on change will make things work more like users would expect.

@mihe mihe modified the milestones: 4.x, 4.5 Mar 10, 2025
@Repiteo Repiteo merged commit 768d75a into godotengine:master Mar 13, 2025
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Mar 13, 2025

Thanks!

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.

3 participants