This pull request fixes the specific threading issue encountered in #37, where a PartContainer's shape cache was cleared while it was building a new one. In #37, this caused a NullPointerException when the PartContainer attempted to union the, now null, incomplete culling shape cache with a part's culling shape.
This PR fixes the threading issue by doing two things: first, this changes the cache building functions to deal with local VoxelShapes instead of the PartContainer's global ones; second, this changes PartContainer to keep its cached shapes in AtomicReferences, allowing them to be safely read and modified by multiple threads, even on architectures where 32-bit simple operations are not necessarily atomic, like ARM.
Testing
This PR was quickly run in an environment with VanillaParts and WiredRedstone. Due to the nature of this issue, it is not really possible to easily reproduce and therefore not easy to test if this PR actually fixes it.
This PR
This pull request fixes the specific threading issue encountered in #37, where a
PartContainer
's shape cache was cleared while it was building a new one. In #37, this caused aNullPointerException
when thePartContainer
attempted to union the, nownull
, incomplete culling shape cache with a part's culling shape.This PR fixes the threading issue by doing two things: first, this changes the cache building functions to deal with local
VoxelShape
s instead of thePartContainer
's global ones; second, this changesPartContainer
to keep its cached shapes inAtomicReference
s, allowing them to be safely read and modified by multiple threads, even on architectures where 32-bit simple operations are not necessarily atomic, like ARM.Testing
This PR was quickly run in an environment with VanillaParts and WiredRedstone. Due to the nature of this issue, it is not really possible to easily reproduce and therefore not easy to test if this PR actually fixes it.
Related Issues
This PR fixes #37