spicylobstergames / astratomic

Survival game inspired by Noita and Starbound, fueled by Rust and Bevy.
Other
91 stars 6 forks source link

refactor: make multi-threading more efficient. #3

Closed zicklag closed 7 months ago

zicklag commented 8 months ago

Current status. Working pretty well, but there are two issues:

zicklag commented 8 months ago

OK, I pushed an update that makes all the borrows ahead of time.

Each thread will do this for it's active chunk and work at the same time.

I implemented Index and IndexMut for ChunkGroup, so you can use it almost like the vec you had earlier, and it will panic if you try to mutably access the surrounding non-mutable chunks.

Running the game, it will immediately panic because something is trying to mutate the sleeping chunks. I think maybe now ( whenever you get the chance ) would be a good time for you to check it out and see if you can figure out why it's writing to the immutable chunks.

Other than that, I think this design should work pretty well and be nice and fast.