Currently, in the
collisionCoordinator we loop through all meshes in the scene - Babylon.js/collisionCoordinator.ts at master · BabylonJS/Babylon.js · GitHub.
I have an intention to extend
moveWithCollisions method to be able to pass manually an array of meshes against which collision detection should be tested.
My rationale for this I that this way I can drastically improve performance in the multiplayer game I’m developing. The world in my game is tile-based. So for example, the ground is not a single mesh but it rather consists of a large number of instanced tile meshes, which can be destructed during gameplay.
Thus, I have an efficient way to get an array of all meshes that surround a player. Then these meshes could be passed to the
moveWithCollisions method, which would pass those down to the
_collideWithWorld method and finally, that method would iterate only over that array of meshes that were passed in rather than all meshes in the scene.
If there are no concerns about such an extension of the
moveWithCollisions method I’m happy to work on a PR.
In case if there are any concerns, maybe a good alternative for me would be a way to be able to extend or override