bool Frustum::cull_sphere( const float* pos, float radius ) const { // Check the distance of the center to the planes for( uint32_t i = 0; i < 6; ++i ) { if(plane_dist_to_point(m_planes[i].m_data, pos) > radius) return true; } return false; }
static unsigned int calc_lod(heightfield hf, vector3 *patch_pos) { int i; float d = plane_dist_to_point(&hf->cam->ftm.near, patch_pos); i = (int)((d/1000)*4); if(i>3) i = 3; else if(i<0) i=0; return i; }
bool Frustum::cull_box( const float* min, const float* max ) const { // Idea for optimized AABB testing from www.lighthouse3d.com for( uint32_t i = 0; i < 6; ++i ) { const float* n = m_planes[i].m_data; float positive[3] = { min[0], min[1], min[2] }; if( n[0] <= 0 ) positive[0] = max[0]; if( n[1] <= 0 ) positive[1] = max[1]; if( n[2] <= 0 ) positive[2] = max[2]; if(plane_dist_to_point(n, positive) > 0) return true; } return false; }
bool Frustum::cull_frustum( const Frustum &frust ) const { for( uint32_t i = 0; i < 6; ++i ) { bool allOut = true; for( uint32_t j = 0; j < 8; ++j ) { if(plane_dist_to_point(m_planes[i].m_data, frust.m_corners[j].m_vec) < 0) { allOut = false; break; } } if( allOut ) return true; } return false; }