本文整理汇总了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)