Spatial.CollideWith efficiency question

The function is defined as returning all collisions with the Collidable you define. I am wondering if their is a way to force it to exit after the first and not to waste time on additional collisions. What i would be using it for would be for a 3D cursor in a terrain editor and in the game so it would be called at least 3-5 times a second. I looked through the docs and class definitions and saw nothing and was wondering if i missed something or if my understanding of the BIH and scene graph is lacking. If not, would the performance gain be worth editing the function assuming rather complex scenes such as a world with buildings, a terrain mesh, and other objects/players?

Also first post so looking forward to being in the community, coming from XNA and before that BlitzBASIC.

I think maybe you misunderstand what “first” is in this case. The first collision found is not necessarily the nearest collision.

Ok, i am used to a raycasting method and i must have assumed that is what is going on, is their a name for the algorithm/method i can google to read up on more to better understand how to implement it efficiently? Much appreciated

It traverses the scene graph doing bounding shape collisions until it finds a hit… then does the more detailed BVH collisions when it gets to the Geometry. By then it is already reasonably certain that there is a hit.

3-5 times a second should be no problem, though. If it is too slow then something else is wrong.

Yeah, whats the actual problem anyway? Without a game it makes few sense to talk about “performance”.