當前位置: 首頁>>代碼示例>>Python>>正文


Python Vec.iter_line方法代碼示例

本文整理匯總了Python中srctools.Vec.iter_line方法的典型用法代碼示例。如果您正苦於以下問題:Python Vec.iter_line方法的具體用法?Python Vec.iter_line怎麽用?Python Vec.iter_line使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在srctools.Vec的用法示例。


在下文中一共展示了Vec.iter_line方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: beam_hole_split

# 需要導入模塊: from srctools import Vec [as 別名]
# 或者: from srctools.Vec import iter_line [as 別名]
def beam_hole_split(axis: str, min_pos: Vec, max_pos: Vec):
    """Break up floor beams to fit around holes."""

    # Go along the shape. For each point, check if a hole is present,
    # and split at that.
    # Our positions are centered, but we return ones at the ends.

    # Inset in 4 units from each end to not overlap with the frames.
    start_pos = min_pos - Vec.with_axes(axis, 60)
    if HOLES:
        hole_size_large = vbsp_options.get(float, 'glass_hole_size_large') / 2
        hole_size_small = vbsp_options.get(float, 'glass_hole_size_small') / 2

        # Extract normal from the z-axis.
        grid_height = min_pos.z // 128 * 128 + 64
        if grid_height < min_pos.z:
            normal = (0, 0, 1)
        else:
            normal = (0, 0, -1)
        import vbsp
        for pos in min_pos.iter_line(max_pos, 128):
            try:
                hole_type = HOLES[(pos.x, pos.y, grid_height), normal]
            except KeyError:
                continue
            else:
                if hole_type is HoleType.SMALL:
                    size = hole_size_small
                elif hole_type is HoleType.LARGE:
                    size = hole_size_large
                else:
                    raise AssertionError(hole_type)

                yield start_pos, pos - Vec.with_axes(axis, size)
                start_pos = pos + Vec.with_axes(axis, size)

    # Last segment, or all if no holes.
    yield start_pos, max_pos + Vec.with_axes(axis, 60)
開發者ID:BenVlodgi,項目名稱:BEE2.4,代碼行數:40,代碼來源:barriers.py


注:本文中的srctools.Vec.iter_line方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。