def has_line_of_sight(
    scene: trimesh.Scene,
    a: Union[str, list[str]],
    b: Union[str, list[str]],
    num_samples: int = 100,
) -> bool:
    """
    Check if any object in list 'a' in the scene has a line of sight to any object in list 'b'.

    Parameters:
    - scene: The trimesh.Scene instance.
    - a: Name or list of names of objects from which line of sight is checked.
    - b: Name or list of names of objects to which line of sight is checked.
    - num_samples: Number of points to sample from each object for ray casting.

    Returns:
    - True if any object in list 'a' has a line of sight to any object in list 'b', False otherwise.
    """

    # Ensure 'a' and 'b' are lists
    if isinstance(a, str):
        a = [a]
    if isinstance(b, str):
        b = [b]

    a = iu.meshes_from_names(scene, a)
    b = iu.meshes_from_names(scene, b)

    # Check line of sight for each object in 'a' against any object in 'b'
    for obj_a in a:
        # Sample points from the surface of object 'a'
        points_a = obj_a.sample(num_samples)

        combined_mesh = trimesh.util.concatenate(
            [mesh for name, mesh in scene.geometry.items() if mesh != obj_a]
        )

        for obj_b in b:
            # Sample points from the surface of object 'b'
            points_b = obj_b.sample(num_samples)

            # Create rays from points on 'a' to points on 'b'
            ray_origins = np.tile(points_a, (num_samples, 1))
            ray_directions = np.repeat(points_b, num_samples, axis=0) - ray_origins
            ray_directions /= np.linalg.norm(ray_directions, axis=1)[:, None]

            # Check for intersections with the combined mesh
            locations, index_ray, index_tri = (
                combined_mesh.ray_pyembree.intersects_location(
                    ray_origins, ray_directions, multiple_hits=False
                )
            )

            # Check if point is reached
            for i in range(index_ray.shape[0]):
                index = index_ray[i]
                hit_location = locations[i]

                # Check if any intersection is close to the point
                if np.linalg.norm(points_b[index // num_samples] - hit_location) < 1e-6:
                    return True

    return False

    Check if any object in list 'a' in the scene has a line of sight to any object in list 'b'.

    Parameters:
    - scene: The trimesh.Scene instance.
    - a: Name or list of names of objects from which line of sight is checked.
    - b: Name or list of names of objects to which line of sight is checked.
    - num_samples: Number of points to sample from each object for ray casting.

    Returns:
    - True if any object in list 'a' has a line of sight to any object in list 'b', False otherwise.
    
infinigen/core/constraints/evaluator/node_impl/trimesh_geometry.py