Skip to content

Some improvements to ScatterCache#239

Merged
HungryProton merged 2 commits into
HungryProton:v4from
AShiningRay:improve_scattercache
Nov 23, 2025
Merged

Some improvements to ScatterCache#239
HungryProton merged 2 commits into
HungryProton:v4from
AShiningRay:improve_scattercache

Conversation

@AShiningRay

Copy link
Copy Markdown
Contributor

After expanding my main scene (and littering it with objects populated by scatter), i began to notice that the cache was taking a while to save, freezing the whole editor in the process.

This commit solves that by saving the cache file on a separate thread unless the "dbg_disable_thread" variable is enabled on the ScatterCache node... the "Clear Cache" button now has a use as well, as it now saves a cleared cache file (that is, no transforms or scatter nodes) onto the disk. I can't think of an use for it that's not debugging the saved file or cleaning up garbage data on it, so that's why it saves an effectively empty file.

Also, loading the cache file can now be done on the main thread if "dbg_disable_thread" is set to true as well.

I haven't found any issues on my end after using these changes for about a week, but i'm still open to discussions and suggestions.

Previously the "Clear Cache" button had no function due to the cleared
cache not being saved to disk. This commit solves that.

Furthermore, saving was done on the main thread, which can cause
the editor to become unresponsive if there are many objects being
generated by Scatter nodes (files over 100MB were sure to freeze
the editor for a second or two), so now it is saved on a separate
thread unless the "dbg_disable_thread" variable is enabled... and
the same now applies to loading the scatter cache as well, which
did not load on the main thread if that was enabled previously.

Related to issue HungryProton#238
@HungryProton

HungryProton commented Nov 23, 2025

Copy link
Copy Markdown
Owner

Thanks for the PR! Looks good to me, the only thing you would need to change is to check if the thread has actually started before calling wait_to_finish() to avoid these errors in the console
image

For example , exit tree should become

func _exit_tree():
	if saveThread.is_started():
		saveThread.wait_to_finish()

And same for the other two places

(Also, saveThread should be called _save_thread for consistency)

Following up on adjustments requested on the PR.
@AShiningRay

Copy link
Copy Markdown
Contributor Author

And done. If there's anything else, please do share.

@HungryProton
HungryProton merged commit 23893a7 into HungryProton:v4 Nov 23, 2025
2 of 6 checks passed
@HungryProton

Copy link
Copy Markdown
Owner

All good, thank you!

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.

2 participants