So I am writing a JOGL application that requires some collision detection, but I am unsure what the best practice is as far as when and where to implement your collision detection code.
This program is a real time simulation that needs to check for collision very quickly and accurately, so when should I run my collision detection algorithm? Should I run it once every rendering, in my display() function, Or should collision detection be separated from rendering, in some sort of main loop?
for example;
mainloop() {
while( !done ) {
collisionDetection();
render();
}
}
I am currently using the Animator class that contains its own main loop to continually call my display(), so I would have to either extend the Animator class to include my collision detection in the main loop, or make my own animator type class, but since JOGL is all thready and I would really not like to do that.
So what do you guys typically do? Checking once per frame seems fine as far as accuracy, but the application needs to do a lot of computation once a collision happens, so I am thinking if collision detection is in the same thread as the renderer that it will create a pretty tight bottleneck.