Sub Chunks
This class uses the mesh method to divide the space to optimize collision detection by reducing the number of calculations, but the worst-case time complexity of the algorithm when all objects are in dense space is still O(n^2 - n), which is same as the traversal algorithm.
A mesh in the mesh method is called Chunk/SubChunk here.
The implementation builds a two-dimensional array to store all the entities there (actually the UUID of the entity) and represent the mesh that divides the space, and within each logical frame, update the mesh in which the entities are located. Each time when an entity is processing collide testing, only those that are in the same meshes where it is located, might be more than one mesh, as the entity are detected, reducing the number of collision checks.
The default meshing number is 12*14, you can use the provided functions to automatically mesh, or set the number of divisions on the x-axis and y-axis yourself.
Author
KKoishi_
Functions
Returns if an entity which has the given UUID is in the SubChunks where the player located in.
When debug mode on, will render the meshes.
Set the baseSubChunkLength to the given value.
Reindex the space.