currently I think about a problem of one of my projects. The problem is, I generate a world with some objects and a player object, that's able to walk inside this world. The first question I've is how I can detect collisions in a simple way?
All of my objects have a bounding box. So I'm able to detect intersections with every game tick between two or more objects. I guess, this is the simplest of all ways, but my problem is now, if I have a world with more than hundred objects? Here a small description ...
My idea is, to divide the objects into static and dynamic objects. That means, static objects don't move, like a rock or tree. Dynamic objects are able to move, like a cow or a human NPC's.
For this moment we only handle static objects and we leave dynamic objects out. I've a rendered view (sight distance of the player) of 12 blocks (means bounding boxes; objects) in one direction. I would render all blocks in any angle around of the player position. Means 12 blocks before, behind, over and under the player. In two dimensions (x and z axis) this are 24 blocks from left to right and 576 blocks on one dimension. I guess, this isn't that much, but if I add the y axis, then I've to render 13.874 blocks. I guess, for collision detection with bounding boxes that would be hard. And to be honest: A view distance of 12 blocks are not really much. So it would be better to increase the distance to 30 or 50 blocks in one direction. But that increases also the calculation problem!
The question is, how can I detect collision, with static objects in the world in a good way with many objects? For me, an iteration through all objects to calculate the euclidean distance (which object is the nearest and with which of this objects is a collision possible) seems really hard in cost of calculation?
Is there a good way to calculate this collisions?
That is more the simple way to calculate a collision between many static objects and one movable player object, but what if there are some more dynamic objects in the same area like my player object?
I would be glad to get some information/resources how to manage this problem in a good way. (-:
Thank you so much!