Question

I am at the stage of my development process where I want to implement collision. Now i can think of a simple way of doing it, if the "camera"'s x,y or z are inside the position of a certain cube then don't let the camera move in the direction it hit the object. Seems simple enough.

the thing is i think this will be pretty intensive for collision detection. I am using a 3-D array for my cubes, and I think there maybe is a way to simplify it by using this array... I just don't know how.. If there isn't a way because the camera can move freely is the idea that I suggested a good way of doing collision? it will only be ran on 1 group of cubes, the one you are above at X point in time..

Was it helpful?

Solution

Try the simple approach first. Make it right, then make it fast. And modern computers are so fast you may find that the simple approach works well enough anyway.

Beyond that there are two useful techniques in collision detection.

  1. Assume that movement is gradual rather than jumpy, so always test first to see if the same cube that matched last time is still a match.

  2. Organize your scene graph, or at least the objects you can collide with, into a spatial hierarchy so you can eliminate whole groups of objects with a single test.

For more info, chapter 17 of the 'Real-Time Rendering' book. Useful keywords for searching are BSP tree, quadtree, octtree.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top