This is not really an OpenGL question, but I wanted to see what some of the people have to say about this.
What I want to know is what is the best way to implement collision detection in c++ with as little violation of encapsulation as possible? I want to avoid having to rewrite collision code for all of my existing objects when a new type of collidable geometry is introduced to the engine.
Since collision detection neccessarily involves at least two objects, it becomes very difficult to encapsulate the functionality into a single object.
It seems there is no way to implement collision detection without having every type of collidable object know the details of every other type of collidable object, and as an OO c++ programmer, this troubles me greatly.
I guess the best solution would involve abstracting away the data neccessary for collisions. For instance, have a class that handles box collisions, another that handles cylinder collisions, and another that handles polygonal collisions. The hope would be that each new type of geometry would fall into one of these categories, and be derived from the appropriate object. This way there would be a limited number of cases that would have to be acounted for. I have a lot of unanswered questions about how this could best work though.
Anyway, if anyone has any ideas or suggestions at all, I would really appreciate your input.