bool VoxelProjectedPolygon::occludes(const VoxelProjectedPolygon& occludee, bool checkAllInView) const { // if we are completely out of view, then we definitely don't occlude! // if the occludee is completely out of view, then we also don't occlude it // // this is true, but unfortunately, we're not quite handling projects in the // case when SOME points are in view and others are not. So, we will not consider // occlusion for any shadows that are partially in view. if (checkAllInView && (!getAllInView() || !occludee.getAllInView())) { return false; } // first check the bounding boxes, the occludee must be fully within the boounding box of this shadow if ((occludee.getMaxX() > getMaxX()) || (occludee.getMaxY() > getMaxY()) || (occludee.getMinX() < getMinX()) || (occludee.getMinY() < getMinY())) { return false; } // if we got this far, then check each vertex of the occludee, if all those points // are inside our polygon, then the tested occludee is fully occluded for(int i = 0; i < occludee.getVertexCount(); i++) { if (!pointInside(occludee.getVertex(i))) { return false; } } // if we got this far, then indeed the occludee is fully occluded by us return true; }