bool Frustum::intersectAABB( const float3 & pos, const float3 & e, uint & outClipMask, uint inClipMask ) { const Plane * plane = frust; uint p = 0; uint mk = 1; outClipMask = 0; // init outclip mask // loop while there are active planes.. while ( (mk <= inClipMask) && (p < 6) ) { // if clip plane is active... if ( inClipMask & mk ) { const float3 & n = plane[p].normal(); float NP = e.getX() * fabs( n.getX() ) + e.getY() * fabs( n.getY() ) + e.getZ() * fabs( n.getZ() ); float MP = plane[p].distance(pos); //m.X*p->X+m.y*p->y+m.z*p->z+p->w; if ( (MP + NP) < 0.0f ) { return false; // behind clip plane } if ( (MP - NP) < 0.0f ) { outClipMask |= mk; } } mk += mk; p++; // next plane } return true; // AABB intersects frustum }