How to check if face is being rendered on screen?

Started by fiendfan1, May 15, 2013, 03:11:23

Previous topic - Next topic

fiendfan1

I am using an expensive algorithm to do 3D collision detection between two faces - Face A and Face B, and I would like to make it faster. One of the first ways I thought of to do this is by basically see if Face A would be rendered or shown on screen of the camera was at the position of Face B.

The only way I could think of to do this is to basically ray-cast and see if that face is hit. But this would basically need another collision detection check, so that would only slow it down.

I heard of someone literally rendering Face A from Face B's point of view and seeing if it was culled by GL_CULL_FACE(GL_BACK), but I'm not sure how.

Does anyone have any ideas on this specifically or any other ways to speed up collision detection?


quew8

What you are talking about there is frustum culling (at least the testing part of it) and I don't think that is going to be at all quicker than your expensive (and conclusive) algorithm. For something like this, I recommend using axis aligned bounding boxes encompassing the two faces. Test the bounding boxes intersect and only go onto the expensive algorithm if they do. This should increase speed quite a lot provided that a fair amount of the time, the faces won't be intersecting.

fiendfan1

Quote from: quew8 on May 15, 2013, 17:46:17
What you are talking about there is frustum culling (at least the testing part of it) and I don't think that is going to be at all quicker than your expensive (and conclusive) algorithm. For something like this, I recommend using axis aligned bounding boxes encompassing the two faces. Test the bounding boxes intersect and only go onto the expensive algorithm if they do. This should increase speed quite a lot provided that a fair amount of the time, the faces won't be intersecting.
Thanks so much, doing AABB is way faster. And it's so simple!

quew8

The more you know... The simpler life gets.