def walk_same_altitude(
    start_loc,
    sampler,
    bvh,
    filter_func=None,
    fall_ratio=1.5,
    retries=30,
    step_up_height=2,
    ignore_missed_rays=False,
    z_move_up=1,
):
    """
    fall_ratio: what is the slope at which the camera is willing to go down / glide
    """

    # retry until we find something that doesnt walk off the map
    for retry in range(retries):
        pos = start_loc + Vector(sampler())

        pos.z += z_move_up  # move it up a ways, so that it can raycast back down onto something
        curr_alt = get_altitude(start_loc, bvh)
        new_alt = get_altitude(pos, bvh)

        if ignore_missed_rays:
            if curr_alt is None:
                curr_alt = start_loc.z
            if new_alt is None:
                new_alt = pos.z

        if curr_alt is None or new_alt is None:
            if curr_alt is None:
                raise PolicyError()
            logger.debug(
                f"walk_same_altitude failed {retry=} with {curr_alt=}, {new_alt=}"
            )
            continue

        fall_dist = new_alt - curr_alt
        max_fall_dist = step_up_height + fall_ratio * (pos - start_loc).length
        fall_dist = np.clip(fall_dist, -100, max_fall_dist)

        pos.z = pos.z - fall_dist

        if filter_func is not None and not filter_func(pos):
            continue

        break
    else:
        raise PolicyError()

    return pos

    fall_ratio: what is the slope at which the camera is willing to go down / glide
    
infinigen/core/placement/animation_policy.py