bool Frustum::Intersects( const Bounds &bounds ) const { // Has the frustum planes been built? if (!initialized_) { ASSERT(false); return false; } // Are the frustum planes up to date? if (needs_rebuild_) { // TODO Warn them! } // Null boxes always invisible if (bounds.is_null()) { return false; } // Infinite boxes always visible if (bounds.is_infinite()) { return true; } // Get center of the box Vector3 center = bounds.center(); // Get the half-size of the box Vector3 half = bounds.half_size(); // For each plane, see if all points are on the negative side // If so, object is not visible for (int32 plane = 0; plane < 6; ++plane) { // Skip far plane if infinite view frustum if ((plane == FRUSTUM_PLANE_FAR) && far_distance_ == 0) { continue; } int32 side = frustum_planes_[plane].Side(center, half); if (side == Plane::NEGATIVE_SIDE) { return false; } } return true; }