PDA

View Full Version : IsInFrustum implementation



devdept
02-10-2012, 01:37 AM
Hi All,

Anybody can help me to understand what the 'findOpposingPointsMostPerpendicularToPlane' function does in this code snippet? Does it check the distance of each corner (8 times) of the AABB from the frustum plane and returns the min and max one?

http://stackoverflow.com/questions/9187871/frustum-culling-when-bounding-box-is-really-big

Thanks,

Alberto

Dark Photon
02-12-2012, 11:07 AM
Anybody can help me to understand what the 'findOpposingPointsMostPerpendicularToPlane' function does in this code snippet (http://stackoverflow.com/questions/9187871/frustum-culling-when-bounding-box-is-really-big)?
I think what it's doing is returning 2 AABB corners: one which is the furthest along the positive direction of the plane normal, and one which is the furthest along the negative direction of the plane normal.

devdept
02-15-2012, 03:03 PM
Thanks Dark Photon,

In this case they are computing 8 signed distance and sorting them, it's quite expensive...

Dark Photon
02-16-2012, 12:52 PM
In this case they are computing 8 signed distance and sorting them, it's quite expensive...

They could, but that'd be very inefficient.

For instance, to find furthest positive point:


pt.x = (normal.x > 0) ? max.x : min.x;
pt.y = (normal.y > 0) ? max.y : min.y;
pt.z = (normal.z > 0) ? max.z : min.z;

Make min/max a 2-element array and you can nuke the conditionals.

devdept
02-20-2012, 03:09 AM
Wow, I will try immediately...

Thanks,

Alberto