def compute_inview_distances(
    points: np.array,
    cameras: list[bpy.types.Object],
    dist_max,
    vis_margin,
    frame_start=None,
    frame_end=None,
    verbose=False,
):
    """
    Compute the minimum distance of each point to any of the cameras in the scene.

    Parameters:
    - points: an array of 3D points, in world space
    - cameras: a list of cameras in the scene
    - dist_max: the maximum distance to consider a point "in view"
    - vis_margin: how far outside the view frustum to consider a point "in view"

    Returns:
    - mask: boolean array of whether each point is within within vis_margin and dist_max of any frame of any camera
    - min_dists: the distance of each point the closest camera
    - min_vis_dists: the distance of each point to the nearest point in any camera's view frustum
    """

    assert len(points.shape) == 2 and points.shape[-1] == 3

    if frame_start is None:
        frame_start = bpy.context.scene.frame_start
    if frame_end is None:
        frame_end = bpy.context.scene.frame_end

    points = homogenize(points)

    mask = np.zeros(len(points), dtype=bool)
    min_dists = np.full(len(points), 1e7)
    min_vis_dists = np.full(len(points), 1e7)

    rangeiter = trange if verbose else range

    assert frame_start < frame_end + 1, (frame_start, frame_end)

    for frame in rangeiter(frame_start, frame_end + 1):
        bpy.context.scene.frame_set(frame)
        for cam in cameras:
            dists, vis_dists = compute_vis_dists(points, cam)

            frame_cam_mask = np.ones(len(points), dtype=bool)

            if dist_max is not None:
                frame_cam_mask &= dists < dist_max
            if vis_margin is not None:
                frame_cam_mask &= vis_dists < vis_margin

            if frame_cam_mask.any():
                min_vis_dists[frame_cam_mask] = np.minimum(
                    vis_dists[frame_cam_mask], min_vis_dists[frame_cam_mask]
                )
                min_dists[frame_cam_mask] = np.minimum(
                    dists[frame_cam_mask], min_dists[frame_cam_mask]
                )

            mask |= frame_cam_mask

    return mask, min_dists, min_vis_dists

    Compute the minimum distance of each point to any of the cameras in the scene.

    Parameters:
    - points: an array of 3D points, in world space
    - cameras: a list of cameras in the scene
    - dist_max: the maximum distance to consider a point "in view"
    - vis_margin: how far outside the view frustum to consider a point "in view"

    Returns:
    - mask: boolean array of whether each point is within within vis_margin and dist_max of any frame of any camera
    - min_dists: the distance of each point the closest camera
    - min_vis_dists: the distance of each point to the nearest point in any camera's view frustum
    
infinigen/core/placement/split_in_view.py